default copy constructor and assignment operator in Point2 and Point3

This commit is contained in:
alemuntoni 2020-11-17 19:19:54 +01:00
parent 6228d92fec
commit c7fd93063e
2 changed files with 29 additions and 10 deletions

View File

@ -127,14 +127,20 @@ public:
_v[0] = nx; _v[1] = ny;
}
/// copy constructor
inline Point2 ( const Point2 & p)
inline Point2 ( const Point2 & p) = default;
/// copy constructor
template<class Q>
inline Point2 ( const Point2<Q> & p)
{
_v[0]= p._v[0]; _v[1]= p._v[1];
_v[0]= p[0]; _v[1]= p[1];
}
/// copy
inline Point2 & operator =( const Point2 & p)
inline Point2 & operator =( const Point2 & p) = default;
/// copy
template<class Q>
inline Point2 & operator =( const Point2<Q> & p)
{
_v[0]= p._v[0]; _v[1]= p._v[1];
_v[0]= p[0]; _v[1]= p[1];
return *this;
}
/// sets the point to (0,0)

View File

@ -133,21 +133,34 @@ public:
_v[1] = ny;
_v[2] = nz;
}
inline Point3 ( Point3 const & p )
/** Default copy constructor */
inline Point3 ( Point3 const & p ) = default;
/** Copy from Point with different template */
template<class Q>
inline Point3 ( Point3<Q> const & p )
{
_v[0]= p._v[0];
_v[1]= p._v[1];
_v[2]= p._v[2];
_v[0]= p[0];
_v[1]= p[1];
_v[2]= p[2];
}
inline Point3 ( const P3ScalarType nv[3] )
{
_v[0] = nv[0];
_v[1] = nv[1];
_v[2] = nv[2];
}
inline Point3 & operator =(Point3 const & p)
/** Default copy assignment */
inline Point3 & operator =(Point3 const & p) = default;
/** Copy assignment from Point with different template */
template<class Q>
inline Point3 & operator =(Point3<Q> const & p)
{
_v[0] = p._v[0]; _v[1] = p._v[1]; _v[2] = p._v[2];
_v[0] = p[0]; _v[1] = p[1]; _v[2] = p[2];
return *this;
}
inline void SetZero()