From 4261d4635bc76ac19d51a495d7e6ff26641ac8c4 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 4 Feb 2020 10:12:29 +0100 Subject: [PATCH] Less use of swap --- ...angulation_cell_base_with_circumcenter_3.h | 7 +++---- .../include/CGAL/Regular_triangulation_3.h | 21 ++++++++----------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h b/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h index 44610ed6de8..7c4239af9b2 100644 --- a/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h +++ b/Triangulation_3/include/CGAL/Delaunay_triangulation_cell_base_with_circumcenter_3.h @@ -65,9 +65,8 @@ public: Delaunay_triangulation_cell_base_with_circumcenter_3 (Delaunay_triangulation_cell_base_with_circumcenter_3 &&c) - : Cb(std::move(c)), circumcenter_(nullptr) + : Cb(std::move(c)), circumcenter_(std::exchange(c.circumcenter_, nullptr)) { - std::swap(circumcenter_, c.circumcenter_); } Delaunay_triangulation_cell_base_with_circumcenter_3& @@ -81,8 +80,8 @@ public: Delaunay_triangulation_cell_base_with_circumcenter_3& operator=(Delaunay_triangulation_cell_base_with_circumcenter_3 &&c) { - Delaunay_triangulation_cell_base_with_circumcenter_3 tmp=std::move(c); - std::swap(tmp, *this); + Cb::operator=(std::move(c)); + circumcenter_ = std::exchange(c.circumcenter_, nullptr); return *this; } diff --git a/Triangulation_3/include/CGAL/Regular_triangulation_3.h b/Triangulation_3/include/CGAL/Regular_triangulation_3.h index 22122a53e41..8502a68264d 100644 --- a/Triangulation_3/include/CGAL/Regular_triangulation_3.h +++ b/Triangulation_3/include/CGAL/Regular_triangulation_3.h @@ -205,14 +205,13 @@ public: void swap(Regular_triangulation_3& tr) noexcept(noexcept(this->Tr_Base::swap(tr))) { - // The 'vertices' and 'hidden_points' members of 'hidden_point_visitor' should be empty - // as they are only filled (and cleared) during the insertion of a point. - // Hidden points are not stored there, but rather in cells. Thus, the only thing that must be set - // is the triangulation pointer. - Hidden_point_visitor new_hpv(this); - using std::swap; - swap(hidden_point_visitor, new_hpv); - + // The 'vertices' and 'hidden_points' members of + // 'hidden_point_visitor' should be empty as they are only filled + // (and cleared) during the insertion of a point. Hidden points + // are not stored there, but rather in cells. Thus, the only thing + // that must be set is the triangulation pointer, and it is + // already correctly set. There is nothing to do about + // 'hidden_point_visitor'. Tr_Base::swap(tr); } @@ -224,11 +223,9 @@ public: } Regular_triangulation_3& operator=(Regular_triangulation_3&& tr) - noexcept(noexcept(Regular_triangulation_3(std::move(tr))) && - noexcept(std::declval().swap(*this))) + noexcept(noexcept(Regular_triangulation_3(std::move(tr)))) { - Regular_triangulation_3 copy(std::move(tr)); - copy.swap(*this); + Tr_Base::operator=(std::move(tr)); return *this; }