From c7fd93063ef2bc3b426148e2eb05ee9f50f4114b Mon Sep 17 00:00:00 2001 From: alemuntoni Date: Tue, 17 Nov 2020 19:19:54 +0100 Subject: [PATCH] default copy constructor and assignment operator in Point2 and Point3 --- vcg/space/deprecated_point2.h | 14 ++++++++++---- vcg/space/deprecated_point3.h | 25 +++++++++++++++++++------ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/vcg/space/deprecated_point2.h b/vcg/space/deprecated_point2.h index 8085d6ed..6241e78d 100644 --- a/vcg/space/deprecated_point2.h +++ b/vcg/space/deprecated_point2.h @@ -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 + inline Point2 ( const Point2 & 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 + inline Point2 & operator =( const Point2 & 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) diff --git a/vcg/space/deprecated_point3.h b/vcg/space/deprecated_point3.h index 1468e9bb..dd32ebfd 100644 --- a/vcg/space/deprecated_point3.h +++ b/vcg/space/deprecated_point3.h @@ -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 + inline Point3 ( Point3 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 + inline Point3 & operator =(Point3 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()