Added missing copy constructor && assignmnet

This commit is contained in:
Efi Fogel 2022-02-21 17:17:34 +02:00
parent a331ede932
commit 414103f286
5 changed files with 124 additions and 0 deletions

View File

@ -51,12 +51,34 @@ protected:
bool m_own_traits; // inidicates whether the kernel should be freed up. bool m_own_traits; // inidicates whether the kernel should be freed up.
public: public:
// The pointer to the traits and the flag that indicate ownership should be
// replaced with a smart pointer. Meanwhile, the copy constructor and
// copy assignment prevent double delition. Notice that once a copy
// constructor (assignment) is present, the move constructor (assignment)
// is implicitly not generated anyway.
/*! Default constructor. */ /*! Default constructor. */
Polygon_decomposition_strategy_adapter() : Polygon_decomposition_strategy_adapter() :
m_traits(nullptr), m_traits(nullptr),
m_own_traits(false) m_own_traits(false)
{ init(); } { init(); }
/*! Copy constructor. */
Polygon_decomposition_strategy_adapter
(const Polygon_decomposition_strategy_adapter& other) :
m_traits((other.m_own_traits) ? new Traits_2 : other.m_traits),
m_own_traits(other.m_own_traits)
{ init(); }
/*! Copy assignment. */
Polygon_decomposition_strategy_adapter&
operator=(const Polygon_decomposition_strategy_adapter& other) {
m_traits = (other.m_own_traits) ? new Traits_2 : other.m_traits;
m_own_traits = other.m_own_traits;
init();
return *this;
}
/*! Constructor. */ /*! Constructor. */
Polygon_decomposition_strategy_adapter(const Traits_2& traits) : Polygon_decomposition_strategy_adapter(const Traits_2& traits) :
m_traits(traits), m_traits(traits),

View File

@ -117,12 +117,34 @@ private:
Ccw_in_between_2 f_ccw_in_between; Ccw_in_between_2 f_ccw_in_between;
public: public:
// The pointer to the kernel and the flag that indicate ownership should be
// replaced with a smart pointer. Meanwhile, the copy constructor and
// copy assignment prevent double delition. Notice that once a copy
// constructor (assignment) is present, the move constructor (assignment)
// is implicitly not generated anyway.
/*! Default constructor. */ /*! Default constructor. */
Minkowski_sum_by_convolution_2() : Minkowski_sum_by_convolution_2() :
m_kernel(new Kernel), m_kernel(new Kernel),
m_own_kernel(true) m_own_kernel(true)
{ init(); } { init(); }
/*! Copy constructor. */
Minkowski_sum_by_convolution_2
(const Minkowski_sum_by_convolution_2& other) :
m_kernel((other.m_own_kernel) ? new Kernel : other.m_kernel),
m_own_kernel(other.m_own_kernel)
{ init(); }
/*! Copy assignment. */
Minkowski_sum_by_convolution_2&
operator=(const Minkowski_sum_by_convolution_2& other) {
m_kernel = (other.m_own_kernel) ? new Kernel : other.m_kernel;
m_own_kernel = other.m_own_kernel;
init();
return *this;
}
/*! Constructor. */ /*! Constructor. */
Minkowski_sum_by_convolution_2(const Kernel& kernel) : Minkowski_sum_by_convolution_2(const Kernel& kernel) :
m_kernel(&kernel), m_kernel(&kernel),

View File

@ -90,6 +90,12 @@ private:
Compare_xy_2 f_compare_xy; Compare_xy_2 f_compare_xy;
public: public:
// The pointers and the corresponding flags that indicate ownerships should
// be replaced with smart pointers. Meanwhile, the copy constructor and
// copy assignment prevent double delition. Notice that once a copy
// constructor (assignment) is present, the move constructor (assignment)
// is implicitly not generated anyway.
//! Default constructor. //! Default constructor.
Minkowski_sum_by_decomposition_2() : Minkowski_sum_by_decomposition_2() :
m_decomposition_strategy1(nullptr), m_decomposition_strategy1(nullptr),
@ -100,6 +106,36 @@ public:
m_own_traits(false) m_own_traits(false)
{ init(); } { init(); }
//! Copy constructor.
Minkowski_sum_by_decomposition_2
(const Minkowski_sum_by_decomposition_2& other) :
m_decomposition_strategy1((other.m_own_strategy1) ?
new Decomposition_strategy1 :
other.m_decomposition_strategy1),
m_decomposition_strategy2((other.m_own_strategy2) ?
new Decomposition_strategy2 :
other.m_decomposition_strategy2),
m_own_strategy1(other.m_own_strategy1),
m_own_strategy2(other.m_own_strategy2),
m_traits((other.m_own_traits) ? new Traits_2 : other.m_traits),
m_own_traits(other.m_own_traits)
{ init(); }
//! Copy assignment.
Minkowski_sum_by_decomposition_2&
operator=(const Minkowski_sum_by_decomposition_2& other) {
m_decomposition_strategy1 = (other.m_own_strategy1) ?
new Decomposition_strategy1 : other.m_decomposition_strategy1;
m_decomposition_strategy2 = (other.m_own_strategy2) ?
new Decomposition_strategy2 : other.m_decomposition_strategy2;
m_own_strategy1 = other.m_own_strategy1;
m_own_strategy2 = other.m_own_strategy2;
m_traits = (other.m_own_traits) ? new Traits_2 : other.m_traits;
m_own_traits = other.m_own_traits;
init();
return *this;
}
//! Constructor. //! Constructor.
Minkowski_sum_by_decomposition_2(const Decomposition_strategy1& strategy1, Minkowski_sum_by_decomposition_2(const Decomposition_strategy1& strategy1,
const Decomposition_strategy2& strategy2, const Decomposition_strategy2& strategy2,

View File

@ -100,12 +100,34 @@ private:
Equal_2 f_equal; Equal_2 f_equal;
public: public:
// The pointer to the traits and the flag that indicate ownership should be
// replaced with a smart pointer. Meanwhile, the copy constructor and
// copy assignment prevent double delition. Notice that once a copy
// constructor (assignment) is present, the move constructor (assignment)
// is implicitly not generated anyway.
/*! Default constructor. */ /*! Default constructor. */
Polygon_vertical_decomposition_2() : Polygon_vertical_decomposition_2() :
m_traits(nullptr), m_traits(nullptr),
m_own_traits(false) m_own_traits(false)
{ init(); } { init(); }
/*! Copy constructor. */
Polygon_vertical_decomposition_2
(const Polygon_vertical_decomposition_2& other) :
m_traits((other.m_own_traits) ? new Traits_2 : other.m_traits),
m_own_traits(other.m_own_traits)
{ init(); }
/*! Copy assignment. */
Polygon_vertical_decomposition_2&
operator=(const Polygon_vertical_decomposition_2& other) {
m_traits = (other.m_own_traits) ? new Traits_2 : other.m_traits;
m_own_traits = other.m_own_traits;
init();
return *this;
}
/*! Constructor */ /*! Constructor */
Polygon_vertical_decomposition_2(const Traits_2& traits) : Polygon_vertical_decomposition_2(const Traits_2& traits) :
m_traits(&traits), m_traits(&traits),

View File

@ -106,12 +106,34 @@ private:
Ccw_in_between_2 f_ccw_in_between; Ccw_in_between_2 f_ccw_in_between;
public: public:
// The pointer to the kernel and the flag that indicate ownership should be
// replaced with a smart pointer. Meanwhile, the copy constructor and
// copy assignment prevent double delition. Notice that once a copy
// constructor (assignment) is present, the move constructor (assignment)
// is implicitly not generated anyway.
/*! Default constructor. */ /*! Default constructor. */
Small_side_angle_bisector_decomposition_2() : Small_side_angle_bisector_decomposition_2() :
m_kernel(new Kernel), m_kernel(new Kernel),
m_own_kernel(true) m_own_kernel(true)
{ init(); } { init(); }
/*! Copy constructor. */
Small_side_angle_bisector_decomposition_2
(const Small_side_angle_bisector_decomposition_2& other) :
m_kernel((other.m_own_kernel) ? new Kernel : other.m_kernel),
m_own_kernel(other.m_own_kernel)
{ init(); }
/*! Copy assignment. */
Small_side_angle_bisector_decomposition_2&
operator=(const Small_side_angle_bisector_decomposition_2& other) {
m_kernel = (other.m_own_kernel) ? new Kernel : other.m_kernel;
m_own_kernel = other.m_own_kernel;
init();
return *this;
}
/*! Constructor. */ /*! Constructor. */
Small_side_angle_bisector_decomposition_2(const Kernel& kernel) : Small_side_angle_bisector_decomposition_2(const Kernel& kernel) :
m_kernel(&kernel), m_kernel(&kernel),