From d29baab36307a75b0807366b713c4be8d83309c9 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Sun, 6 Dec 2020 10:27:15 +0000 Subject: [PATCH 1/6] Add a move assignment operator to Handle.h --- STL_Extension/include/CGAL/Handle.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/STL_Extension/include/CGAL/Handle.h b/STL_Extension/include/CGAL/Handle.h index 0d652ccb4cb..efe7c849587 100644 --- a/STL_Extension/include/CGAL/Handle.h +++ b/STL_Extension/include/CGAL/Handle.h @@ -68,6 +68,13 @@ class Handle return *this; } + Handle& + operator=(Handle&& x) noexcept + { + swap(*this,x); + return *this; + } + friend void swap(Handle& a, Handle& b) noexcept { std::swap(a.PTR, b.PTR); } void reset() From f5563a73d04f38b48ff806e97d23305bd568c7cc Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Sun, 6 Dec 2020 10:28:10 +0000 Subject: [PATCH 2/6] Add a move assignment operator to Nef_Polyhedron.h --- Nef_3/include/CGAL/Nef_polyhedron_3.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Nef_3/include/CGAL/Nef_polyhedron_3.h b/Nef_3/include/CGAL/Nef_polyhedron_3.h index 3eb723d37b7..457e0afdc7b 100644 --- a/Nef_3/include/CGAL/Nef_polyhedron_3.h +++ b/Nef_3/include/CGAL/Nef_polyhedron_3.h @@ -369,11 +369,18 @@ protected: } Nef_polyhedron_3& operator=(const Nef_polyhedron_3& N1) { - Base::operator=(N1); + Base::operator=(N1); // copy the handle set_snc(snc()); return (*this); } + Nef_polyhedron_3& operator=(Nef_polyhedron_3&& N1) noexcept { + N1.set_snc(snc()); // N1.set_snc sets N1.sncp_ not N1.snc_ + Base::operator=(std::move(N1)); // swap the handles + set_snc(snc()); // snc() will return N1.snc_ + return (*this); + } + ~Nef_polyhedron_3() { CGAL_NEF_TRACEN("~Nef_polyhedron_3: destructor called for snc "<<&snc()<< ", pl "< Date: Sun, 13 Dec 2020 09:04:40 +0000 Subject: [PATCH 3/6] Add a move constructor to Handle.h --- STL_Extension/include/CGAL/Handle.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/STL_Extension/include/CGAL/Handle.h b/STL_Extension/include/CGAL/Handle.h index efe7c849587..6139c314425 100644 --- a/STL_Extension/include/CGAL/Handle.h +++ b/STL_Extension/include/CGAL/Handle.h @@ -51,6 +51,12 @@ class Handle PTR->count++; } + Handle(Handle&& x) noexcept + : PTR(x.PTR) + { + x.PTR = static_cast(0); + } + ~Handle() { if ( PTR && (--PTR->count == 0)) From c85e94243dd8bdb5946e5ff524b5e92cdf2b5f35 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Sun, 13 Dec 2020 13:49:37 +0000 Subject: [PATCH 4/6] Add move assignment operator to SHalfloop.h --- Nef_3/include/CGAL/Nef_3/SHalfloop.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Nef_3/include/CGAL/Nef_3/SHalfloop.h b/Nef_3/include/CGAL/Nef_3/SHalfloop.h index c4abb9ebcdc..e6cc98bf944 100644 --- a/Nef_3/include/CGAL/Nef_3/SHalfloop.h +++ b/Nef_3/include/CGAL/Nef_3/SHalfloop.h @@ -75,6 +75,15 @@ class SHalfloop_base { return *this; } + SHalfloop_base& operator=(SHalfloop_base&& l) noexcept + { twin_ = std::move(l.twin_); + incident_sface_ = std::move(l.incident_sface_); + facet_ = std::move(l.facet_); + mark_ = std::move(l.mark_); + circle_ = std::move(l.circle_); + return *this; + } + Mark& mark() { return mark_;} const Mark& mark() const { return mark_; } From 70887f532d0f88c14a1a6e4211f52e0591c4374b Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Sun, 13 Dec 2020 15:30:35 +0000 Subject: [PATCH 5/6] Add move assignment operator to Halfedge.h --- Nef_3/include/CGAL/Nef_3/Halfedge.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Nef_3/include/CGAL/Nef_3/Halfedge.h b/Nef_3/include/CGAL/Nef_3/Halfedge.h index 3903477b915..21506e7db3b 100644 --- a/Nef_3/include/CGAL/Nef_3/Halfedge.h +++ b/Nef_3/include/CGAL/Nef_3/Halfedge.h @@ -100,6 +100,17 @@ class Halfedge_base return *this; } + Halfedge_base& operator=(Halfedge_base&& e) noexcept + { center_vertex_ = std::move(e.center_vertex_); + point_ = std::move(e.point_); + mark_ = std::move(e.mark_); + twin_ = std::move(e.twin_); + out_sedge_ = std::move(e.out_sedge_); + incident_sface_ = std::move(e.incident_sface_); + info_ = 0; + return *this; + } + Vertex_handle& center_vertex() { return center_vertex_; } Vertex_const_handle center_vertex() const { return center_vertex_; } From 6b9fd0c2df9714e2a7472ee14cf952b7e3624474 Mon Sep 17 00:00:00 2001 From: Giles Bathgate Date: Sun, 13 Dec 2020 16:07:45 +0000 Subject: [PATCH 6/6] Add move assignment operator to SHalfedge.h --- Nef_3/include/CGAL/Nef_3/SHalfedge.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Nef_3/include/CGAL/Nef_3/SHalfedge.h b/Nef_3/include/CGAL/Nef_3/SHalfedge.h index f390132078f..ddf5b382b1d 100644 --- a/Nef_3/include/CGAL/Nef_3/SHalfedge.h +++ b/Nef_3/include/CGAL/Nef_3/SHalfedge.h @@ -114,6 +114,22 @@ class SHalfedge_base { return *this; } + SHalfedge_base& operator=(SHalfedge_base&& e) noexcept + { + source_ = std::move(e.source_); + sprev_ = std::move(e.sprev_); + snext_ = std::move(e.snext_); + incident_sface_ = std::move(e.incident_sface_); + twin_ = std::move(e.twin_); + prev_ = std::move(e.prev_); + next_ = std::move(e.next_); + facet_ = std::move(e.facet_); + info_ = 0; + mark_ = std::move(e.mark_); + circle_ = std::move(e.circle_); + return *this; + } + Mark& mark() { return mark_; } const Mark& mark() const { return mark_; }