From b3c2bac1643150844d6c6168f0256b271b9670b5 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 25 Apr 2023 14:20:56 +0100 Subject: [PATCH 01/15] Add issue --- .../test/STL_Extension/CMakeLists.txt | 1 + .../test/STL_Extension/issue_7400.cpp | 54 +++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 STL_Extension/test/STL_Extension/issue_7400.cpp diff --git a/STL_Extension/test/STL_Extension/CMakeLists.txt b/STL_Extension/test/STL_Extension/CMakeLists.txt index d25906091092..20faace78027 100644 --- a/STL_Extension/test/STL_Extension/CMakeLists.txt +++ b/STL_Extension/test/STL_Extension/CMakeLists.txt @@ -12,6 +12,7 @@ if(NOT TARGET CGAL::TBB_support) message(STATUS "NOTICE: Tests are not using TBB.") endif() +create_single_source_cgal_program("issue_7400.cpp") create_single_source_cgal_program("test_Boolean_tag.cpp") create_single_source_cgal_program("test_Cache.cpp") create_single_source_cgal_program("test_Compact_container.cpp") diff --git a/STL_Extension/test/STL_Extension/issue_7400.cpp b/STL_Extension/test/STL_Extension/issue_7400.cpp new file mode 100644 index 000000000000..8a90ee3bc278 --- /dev/null +++ b/STL_Extension/test/STL_Extension/issue_7400.cpp @@ -0,0 +1,54 @@ +#include +#include +// Add C++20 utilities to C++14 +template< class T > +struct remove_cvref { + typedef std::remove_cv_t> type; +}; + +template< class T > +using remove_cvref_t = typename remove_cvref::type; + +template +using iter_value_t = std::remove_reference_t())>; + +template +using range_value_t = iter_value_t()))>>; + +template< class T, class U > +constexpr bool is_same_v = std::is_same::value; + +template< class T, class U > +constexpr bool is_convertible_v = std::is_convertible::value; + + +#include +#include + +using Triangulation = CGAL::Triangulation_3; + +using Vertex_handle = Triangulation::Vertex_handle; + +Triangulation t; + +// Tds::vertex_handles() -> Vertex_handle +static_assert(is_same_v, Vertex_handle>); + +// Triangulation::all_vertex_handles() -> Vertex_handle +static_assert(is_same_v, Vertex_handle>); + +// Triangulation::finite_vertex_handles() -> convertible to Vertex_handle +static_assert(is_convertible_v); + +// But not equal to Vertex_handle +// static_assert(is_same_v, Vertex_handle>); + +int main() +{ + Vertex_handle v_inf = t.infinite_vertex(); + for(auto v: t.finite_vertex_handles()) { + Vertex_handle v2 = v; + if(v == v_inf) return 1; + } + return 0; +} From 68261eb0f18bf1da3254d09f740e9c88f6b6c5f8 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 26 Apr 2023 10:55:59 +0100 Subject: [PATCH 02/15] STL_extension: Add parameter for value type to Prevent_deref --- STL_Extension/include/CGAL/iterator.h | 23 ++++++++++++++----- .../CGAL/Triangulation_data_structure_2.h | 4 ++-- .../CGAL/Triangulation_data_structure_3.h | 4 ++-- .../include/CGAL/Regular_triangulation_2.h | 8 +++---- .../include/CGAL/Triangulation_2.h | 8 +++---- .../include/CGAL/Triangulation_3.h | 16 ++++++------- 6 files changed, 36 insertions(+), 27 deletions(-) diff --git a/STL_Extension/include/CGAL/iterator.h b/STL_Extension/include/CGAL/iterator.h index ea9a964c8a38..8d4bc0097475 100644 --- a/STL_Extension/include/CGAL/iterator.h +++ b/STL_Extension/include/CGAL/iterator.h @@ -37,19 +37,23 @@ namespace CGAL { -template + template class Prevent_deref : public boost::iterator_adaptor< - Prevent_deref + Prevent_deref , I // base - , I // value + , VT // value + , boost::use_default + , VT // ref > { public: typedef boost::iterator_adaptor< - Prevent_deref + Prevent_deref , I // base - , I // value + , VT // value + , boost::use_default + , VT // ref > Base; typedef typename Base::reference reference; typedef typename std::pair range; @@ -58,9 +62,16 @@ class Prevent_deref Prevent_deref(const I& i) : Base(i) {} private: friend class boost::iterator_core_access; - reference dereference() const { return const_cast::type&>(this->base_reference()); } + reference dereference() const { + return this->base_reference(); + } }; + + + + + template Iterator_range > make_prevent_deref_range(const Iterator_range& range) { diff --git a/TDS_2/include/CGAL/Triangulation_data_structure_2.h b/TDS_2/include/CGAL/Triangulation_data_structure_2.h index 322e6cef1b81..aff81d0302c4 100644 --- a/TDS_2/include/CGAL/Triangulation_data_structure_2.h +++ b/TDS_2/include/CGAL/Triangulation_data_structure_2.h @@ -183,7 +183,7 @@ class Triangulation_data_structure_2 } Face_handles face_handles() const { - return make_prevent_deref_range(faces_begin(),faces_end()); + return { faces_begin(),faces_end() }; } Vertex_iterator vertices_begin() const { @@ -195,7 +195,7 @@ class Triangulation_data_structure_2 } Vertex_handles vertex_handles() const { - return make_prevent_deref_range(vertices_begin(),vertices_end()); + return { vertices_begin(),vertices_end() }; } Edge_iterator edges_begin() const { diff --git a/TDS_3/include/CGAL/Triangulation_data_structure_3.h b/TDS_3/include/CGAL/Triangulation_data_structure_3.h index 6333387f28bd..ab4806a9abc4 100644 --- a/TDS_3/include/CGAL/Triangulation_data_structure_3.h +++ b/TDS_3/include/CGAL/Triangulation_data_structure_3.h @@ -661,7 +661,7 @@ class Triangulation_data_structure_3 Cell_handles cell_handles() const { - return make_prevent_deref_range(cells_begin(), cells_end()); + return {cells_begin(), cells_end()}; } Cell_iterator raw_cells_begin() const @@ -720,7 +720,7 @@ class Triangulation_data_structure_3 Vertex_handles vertex_handles() const { - return make_prevent_deref_range(vertices_begin(), vertices_end()); + return {vertices_begin(), vertices_end()}; } // CIRCULATOR METHODS diff --git a/Triangulation_2/include/CGAL/Regular_triangulation_2.h b/Triangulation_2/include/CGAL/Regular_triangulation_2.h index 145b387263fe..553f6b502857 100644 --- a/Triangulation_2/include/CGAL/Regular_triangulation_2.h +++ b/Triangulation_2/include/CGAL/Regular_triangulation_2.h @@ -183,7 +183,7 @@ class Regular_triangulation_2 operator Vertex_handle() const { return Base::base(); } }; - typedef Iterator_range > Finite_vertex_handles; + typedef Iterator_range > Finite_vertex_handles; class Hidden_vertices_iterator : public Filter_iterator @@ -200,7 +200,7 @@ class Regular_triangulation_2 operator Vertex_handle() const { return Base::base(); } }; - typedef Iterator_range > Hidden_vertex_handles; + typedef Iterator_range > Hidden_vertex_handles; //for backward compatibility typedef Finite_faces_iterator Face_iterator; @@ -2236,7 +2236,7 @@ typename Regular_triangulation_2::Finite_vertex_handles Regular_triangulation_2:: finite_vertex_handles() const { - return make_prevent_deref_range(finite_vertices_begin(),finite_vertices_end()); + return { finite_vertices_begin(),finite_vertices_end() }; } template < class Gt, class Tds > @@ -2263,7 +2263,7 @@ typename Regular_triangulation_2::Hidden_vertex_handles Regular_triangulation_2:: hidden_vertex_handles() const { - return make_prevent_deref_range(hidden_vertices_begin(),hidden_vertices_end()); + return { hidden_vertices_begin(),hidden_vertices_end() }; } template < class Gt, class Tds > diff --git a/Triangulation_2/include/CGAL/Triangulation_2.h b/Triangulation_2/include/CGAL/Triangulation_2.h index 6b1de4b4f19d..26d6006820e6 100644 --- a/Triangulation_2/include/CGAL/Triangulation_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_2.h @@ -213,8 +213,8 @@ class Triangulation_2 typedef typename Tds::Vertex_handles All_vertex_handles; typedef typename Tds::Edges All_edges; - typedef Iterator_range > Finite_face_handles; - typedef Iterator_range > Finite_vertex_handles; + typedef Iterator_range > Finite_face_handles; + typedef Iterator_range > Finite_vertex_handles; typedef Iterator_range Finite_edges; typedef Iterator_range Points; @@ -3206,7 +3206,7 @@ typename Triangulation_2::Finite_face_handles Triangulation_2:: finite_face_handles() const { - return make_prevent_deref_range(finite_faces_begin(),finite_faces_end()); + return { finite_faces_begin(),finite_faces_end() }; } template @@ -3235,7 +3235,7 @@ typename Triangulation_2::Finite_vertex_handles Triangulation_2:: finite_vertex_handles() const { - return make_prevent_deref_range(finite_vertices_begin(),finite_vertices_end()); + return { finite_vertices_begin(),finite_vertices_end() }; } template diff --git a/Triangulation_3/include/CGAL/Triangulation_3.h b/Triangulation_3/include/CGAL/Triangulation_3.h index cbad6e031830..86102bacc567 100644 --- a/Triangulation_3/include/CGAL/Triangulation_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_3.h @@ -517,8 +517,8 @@ class Triangulation_3 operator Vertex_handle() const { return Base::base(); } }; - typedef Iterator_range > Finite_cell_handles; - typedef Iterator_range > Finite_vertex_handles; + typedef Iterator_range > Finite_cell_handles; + typedef Iterator_range > Finite_vertex_handles; typedef Filter_iterator Finite_edges_iterator; typedef Filter_iterator Finite_facets_iterator; @@ -529,7 +529,7 @@ class Triangulation_3 typedef Triangulation_segment_cell_iterator_3 Segment_cell_iterator; typedef Triangulation_segment_simplex_iterator_3 Segment_simplex_iterator; - typedef Iterator_range > Segment_traverser_cell_handles; + typedef Iterator_range > Segment_traverser_cell_handles; typedef Iterator_range Segment_traverser_simplices; private: @@ -1803,7 +1803,7 @@ class Triangulation_3 Finite_cell_handles finite_cell_handles() const { - return make_prevent_deref_range(finite_cells_begin(), finite_cells_end()); + return {finite_cells_begin(), finite_cells_end()}; } @@ -1833,7 +1833,7 @@ class Triangulation_3 Finite_vertex_handles finite_vertex_handles() const { - return make_prevent_deref_range(finite_vertices_begin(), finite_vertices_end()); + return { finite_vertices_begin(), finite_vertices_end()}; } Vertex_iterator vertices_begin() const { return _tds.vertices_begin(); } @@ -2245,15 +2245,13 @@ class Triangulation_3 Segment_traverser_cell_handles segment_traverser_cell_handles(Vertex_handle vs, Vertex_handle vt) const { - return make_prevent_deref_range(segment_traverser_cells_begin(vs, vt), - segment_traverser_cells_end()); + return {segment_traverser_cells_begin(vs, vt),segment_traverser_cells_end()}; } Segment_traverser_cell_handles segment_traverser_cell_handles(const Point& ps, const Point& pt, Cell_handle hint = Cell_handle()) const { - return make_prevent_deref_range(segment_traverser_cells_begin(ps, pt, hint), - segment_traverser_cells_end()); + return { segment_traverser_cells_begin(ps, pt, hint), segment_traverser_cells_end()}; } //// Segment Simplex Iterator From 2a41598bd70f38e5c754e08c48c82264988ef306 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 27 Apr 2023 12:04:02 +0200 Subject: [PATCH 03/15] cosmetic changes (indent, spaces, naming) --- STL_Extension/include/CGAL/iterator.h | 21 +++++++------------ .../CGAL/Triangulation_data_structure_2.h | 4 ++-- .../CGAL/Triangulation_data_structure_3.h | 4 ++-- .../include/CGAL/Regular_triangulation_2.h | 10 +++++---- .../include/CGAL/Triangulation_2.h | 10 +++++---- .../include/CGAL/Triangulation_3.h | 13 +++++++----- 6 files changed, 32 insertions(+), 30 deletions(-) diff --git a/STL_Extension/include/CGAL/iterator.h b/STL_Extension/include/CGAL/iterator.h index 8d4bc0097475..5e86e9c4561f 100644 --- a/STL_Extension/include/CGAL/iterator.h +++ b/STL_Extension/include/CGAL/iterator.h @@ -37,28 +37,28 @@ namespace CGAL { - template +template class Prevent_deref : public boost::iterator_adaptor< - Prevent_deref + Prevent_deref , I // base - , VT // value + , Value_type // value , boost::use_default - , VT // ref + , Value_type // ref > { public: typedef boost::iterator_adaptor< - Prevent_deref + Prevent_deref , I // base - , VT // value + , Value_type // value , boost::use_default - , VT // ref + , Value_type // ref > Base; typedef typename Base::reference reference; typedef typename std::pair range; - Prevent_deref() : Base() {} + Prevent_deref() = default; Prevent_deref(const I& i) : Base(i) {} private: friend class boost::iterator_core_access; @@ -67,11 +67,6 @@ class Prevent_deref } }; - - - - - template Iterator_range > make_prevent_deref_range(const Iterator_range& range) { diff --git a/TDS_2/include/CGAL/Triangulation_data_structure_2.h b/TDS_2/include/CGAL/Triangulation_data_structure_2.h index aff81d0302c4..f7c386b9d3f4 100644 --- a/TDS_2/include/CGAL/Triangulation_data_structure_2.h +++ b/TDS_2/include/CGAL/Triangulation_data_structure_2.h @@ -183,7 +183,7 @@ class Triangulation_data_structure_2 } Face_handles face_handles() const { - return { faces_begin(),faces_end() }; + return { faces_begin(), faces_end() }; } Vertex_iterator vertices_begin() const { @@ -195,7 +195,7 @@ class Triangulation_data_structure_2 } Vertex_handles vertex_handles() const { - return { vertices_begin(),vertices_end() }; + return { vertices_begin(), vertices_end() }; } Edge_iterator edges_begin() const { diff --git a/TDS_3/include/CGAL/Triangulation_data_structure_3.h b/TDS_3/include/CGAL/Triangulation_data_structure_3.h index ab4806a9abc4..62885f68043d 100644 --- a/TDS_3/include/CGAL/Triangulation_data_structure_3.h +++ b/TDS_3/include/CGAL/Triangulation_data_structure_3.h @@ -661,7 +661,7 @@ class Triangulation_data_structure_3 Cell_handles cell_handles() const { - return {cells_begin(), cells_end()}; + return { cells_begin(), cells_end() }; } Cell_iterator raw_cells_begin() const @@ -720,7 +720,7 @@ class Triangulation_data_structure_3 Vertex_handles vertex_handles() const { - return {vertices_begin(), vertices_end()}; + return { vertices_begin(), vertices_end() }; } // CIRCULATOR METHODS diff --git a/Triangulation_2/include/CGAL/Regular_triangulation_2.h b/Triangulation_2/include/CGAL/Regular_triangulation_2.h index 553f6b502857..38a46d938265 100644 --- a/Triangulation_2/include/CGAL/Regular_triangulation_2.h +++ b/Triangulation_2/include/CGAL/Regular_triangulation_2.h @@ -183,7 +183,8 @@ class Regular_triangulation_2 operator Vertex_handle() const { return Base::base(); } }; - typedef Iterator_range > Finite_vertex_handles; + typedef Iterator_range > Finite_vertex_handles; class Hidden_vertices_iterator : public Filter_iterator @@ -200,7 +201,8 @@ class Regular_triangulation_2 operator Vertex_handle() const { return Base::base(); } }; - typedef Iterator_range > Hidden_vertex_handles; + typedef Iterator_range > Hidden_vertex_handles; //for backward compatibility typedef Finite_faces_iterator Face_iterator; @@ -2236,7 +2238,7 @@ typename Regular_triangulation_2::Finite_vertex_handles Regular_triangulation_2:: finite_vertex_handles() const { - return { finite_vertices_begin(),finite_vertices_end() }; + return { finite_vertices_begin(), finite_vertices_end() }; } template < class Gt, class Tds > @@ -2263,7 +2265,7 @@ typename Regular_triangulation_2::Hidden_vertex_handles Regular_triangulation_2:: hidden_vertex_handles() const { - return { hidden_vertices_begin(),hidden_vertices_end() }; + return { hidden_vertices_begin(), hidden_vertices_end() }; } template < class Gt, class Tds > diff --git a/Triangulation_2/include/CGAL/Triangulation_2.h b/Triangulation_2/include/CGAL/Triangulation_2.h index 26d6006820e6..6cce9ed2d4e4 100644 --- a/Triangulation_2/include/CGAL/Triangulation_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_2.h @@ -213,8 +213,10 @@ class Triangulation_2 typedef typename Tds::Vertex_handles All_vertex_handles; typedef typename Tds::Edges All_edges; - typedef Iterator_range > Finite_face_handles; - typedef Iterator_range > Finite_vertex_handles; + typedef Iterator_range > Finite_face_handles; + typedef Iterator_range > Finite_vertex_handles; typedef Iterator_range Finite_edges; typedef Iterator_range Points; @@ -3206,7 +3208,7 @@ typename Triangulation_2::Finite_face_handles Triangulation_2:: finite_face_handles() const { - return { finite_faces_begin(),finite_faces_end() }; + return { finite_faces_begin(), finite_faces_end() }; } template @@ -3235,7 +3237,7 @@ typename Triangulation_2::Finite_vertex_handles Triangulation_2:: finite_vertex_handles() const { - return { finite_vertices_begin(),finite_vertices_end() }; + return { finite_vertices_begin(), finite_vertices_end() }; } template diff --git a/Triangulation_3/include/CGAL/Triangulation_3.h b/Triangulation_3/include/CGAL/Triangulation_3.h index 86102bacc567..e0ff1bfa01b7 100644 --- a/Triangulation_3/include/CGAL/Triangulation_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_3.h @@ -517,8 +517,10 @@ class Triangulation_3 operator Vertex_handle() const { return Base::base(); } }; - typedef Iterator_range > Finite_cell_handles; - typedef Iterator_range > Finite_vertex_handles; + typedef Iterator_range > Finite_cell_handles; + typedef Iterator_range > Finite_vertex_handles; typedef Filter_iterator Finite_edges_iterator; typedef Filter_iterator Finite_facets_iterator; @@ -529,7 +531,8 @@ class Triangulation_3 typedef Triangulation_segment_cell_iterator_3 Segment_cell_iterator; typedef Triangulation_segment_simplex_iterator_3 Segment_simplex_iterator; - typedef Iterator_range > Segment_traverser_cell_handles; + typedef Iterator_range > Segment_traverser_cell_handles; typedef Iterator_range Segment_traverser_simplices; private: @@ -1833,7 +1836,7 @@ class Triangulation_3 Finite_vertex_handles finite_vertex_handles() const { - return { finite_vertices_begin(), finite_vertices_end()}; + return {finite_vertices_begin(), finite_vertices_end()}; } Vertex_iterator vertices_begin() const { return _tds.vertices_begin(); } @@ -2251,7 +2254,7 @@ class Triangulation_3 const Point& pt, Cell_handle hint = Cell_handle()) const { - return { segment_traverser_cells_begin(ps, pt, hint), segment_traverser_cells_end()}; + return {segment_traverser_cells_begin(ps, pt, hint), segment_traverser_cells_end()}; } //// Segment Simplex Iterator From b86667726c9bebad70ac3ea59427ba6cea5cef7b Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 27 Apr 2023 12:04:31 +0200 Subject: [PATCH 04/15] add the last static_assert to the test --- STL_Extension/test/STL_Extension/issue_7400.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/STL_Extension/test/STL_Extension/issue_7400.cpp b/STL_Extension/test/STL_Extension/issue_7400.cpp index 8a90ee3bc278..0232dd1b2983 100644 --- a/STL_Extension/test/STL_Extension/issue_7400.cpp +++ b/STL_Extension/test/STL_Extension/issue_7400.cpp @@ -40,14 +40,15 @@ static_assert(is_same_v, Vertex_ // Triangulation::finite_vertex_handles() -> convertible to Vertex_handle static_assert(is_convertible_v); -// But not equal to Vertex_handle -// static_assert(is_same_v, Vertex_handle>); +// But is it equal to Vertex_handle +static_assert(is_same_v, Vertex_handle>); int main() { Vertex_handle v_inf = t.infinite_vertex(); for(auto v: t.finite_vertex_handles()) { Vertex_handle v2 = v; + CGAL_USE(v2); if(v == v_inf) return 1; } return 0; From 04a9026d37f35f32b3539f21c85cd2e594530ad8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 28 Jun 2023 09:58:07 +0200 Subject: [PATCH 05/15] make sure the iterator is bidirectional (even if it's not strictly conforming to the C++ standard) --- STL_Extension/include/CGAL/iterator.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/STL_Extension/include/CGAL/iterator.h b/STL_Extension/include/CGAL/iterator.h index 5e86e9c4561f..29780907260b 100644 --- a/STL_Extension/include/CGAL/iterator.h +++ b/STL_Extension/include/CGAL/iterator.h @@ -43,7 +43,7 @@ class Prevent_deref Prevent_deref , I // base , Value_type // value - , boost::use_default + , typename std::iterator_traits::iterator_category , Value_type // ref > { @@ -52,7 +52,7 @@ class Prevent_deref Prevent_deref , I // base , Value_type // value - , boost::use_default + , typename std::iterator_traits::iterator_category , Value_type // ref > Base; typedef typename Base::reference reference; From 33969b79299917fed52ed21aa7b02a546c819456 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 28 Jun 2023 11:21:16 +0100 Subject: [PATCH 06/15] Why does this compile without the second template parameter??? --- STL_Extension/test/STL_Extension/issue_7400.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/STL_Extension/test/STL_Extension/issue_7400.cpp b/STL_Extension/test/STL_Extension/issue_7400.cpp index 0232dd1b2983..1ce1ce750ddb 100644 --- a/STL_Extension/test/STL_Extension/issue_7400.cpp +++ b/STL_Extension/test/STL_Extension/issue_7400.cpp @@ -51,5 +51,10 @@ int main() CGAL_USE(v2); if(v == v_inf) return 1; } + for (auto v : t.all_vertex_handles()) { + Vertex_handle v2 = v; + CGAL_USE(v2); + if (v == v_inf) std::cout << "found inf" << std::endl; + } return 0; } From 74b8ddf1ec73283e89b5fd7d2789ee1cc03d7af7 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 28 Jun 2023 11:42:55 +0100 Subject: [PATCH 07/15] Fix ToS_2 --- .../include/CGAL/Triangulation_on_sphere_2.h | 4 ++-- .../test/Triangulation_on_sphere_2/test_dtos.cpp | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h index 8b3fb4f448e1..57f8117a7f25 100644 --- a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h +++ b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h @@ -275,7 +275,7 @@ class Triangulation_on_sphere_2 // solid edges: both incident faces are solid typedef Filter_iterator Solid_edges_iterator; typedef Iterator_range Solid_edges; - typedef Iterator_range > Solid_face_handles; + typedef Iterator_range > Solid_face_handles; typedef Project_point Pt_proj; typedef boost::transform_iterator Point_iterator; @@ -321,7 +321,7 @@ class Triangulation_on_sphere_2 Solid_face_handles solid_faces() const { - return make_prevent_deref_range(solid_faces_begin(), solid_faces_end()); + return { solid_faces_begin(), solid_faces_end() }; } Solid_edges_iterator solid_edges_begin() const diff --git a/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/test_dtos.cpp b/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/test_dtos.cpp index e3c665707923..06f8ce3c2908 100644 --- a/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/test_dtos.cpp +++ b/Triangulation_on_sphere_2/test/Triangulation_on_sphere_2/test_dtos.cpp @@ -98,6 +98,12 @@ int main(int, char**) assert(sfs.size() == 4); assert(tr.number_of_solid_faces() + tr.number_of_ghost_faces() == tr.number_of_faces()); + Tr::Face_handle fh = *tr.solid_faces().begin(); + for(auto f: tr.solid_faces()) { + assert(f == fh); + break; + } + Tr::Points pts = tr.points(); assert(pts.size() == tr.number_of_vertices() && pts.size() == 5); From 57b2b7bceb5ba5387a32c60e9520a47d4801ac53 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 28 Jun 2023 12:20:15 +0100 Subject: [PATCH 08/15] Partial fix for SMDS_3. What is different for cells_in_complex() ? --- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 14 ++++++-------- SMDS_3/test/SMDS_3/test_c3t3.cpp | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 643de3ff7da8..a88bbe0e0149 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -1052,10 +1052,10 @@ class Mesh_complex_3_in_triangulation_3 operator Cell_handle() const { return Cell_handle(this->base()); } }; // end class Cells_in_complex_iterator - typedef Iterator_range > Vertices_in_complex; - typedef Iterator_range Edges_in_complex; - typedef Iterator_range Facets_in_complex; - typedef Iterator_range > Cells_in_complex; + typedef Iterator_range > Vertices_in_complex; + typedef Iterator_range Edges_in_complex; + typedef Iterator_range Facets_in_complex; + typedef Iterator_range > Cells_in_complex; #endif @@ -1163,8 +1163,7 @@ class Mesh_complex_3_in_triangulation_3 */ Vertices_in_complex vertices_in_complex() const { - return make_prevent_deref_range(vertices_in_complex_begin(), - vertices_in_complex_end()); + return { vertices_in_complex_begin(), vertices_in_complex_end() }; } /*! returns a range of iterators over the edges of the 1D complex, @@ -1194,8 +1193,7 @@ class Mesh_complex_3_in_triangulation_3 */ Cells_in_complex cells_in_complex() const { - return make_prevent_deref_range(cells_in_complex_begin(), - cells_in_complex_end()); + return { cells_in_complex_begin(), cells_in_complex_end() }; } /// @} diff --git a/SMDS_3/test/SMDS_3/test_c3t3.cpp b/SMDS_3/test/SMDS_3/test_c3t3.cpp index 78835c78fdaf..3899c6107f4a 100644 --- a/SMDS_3/test/SMDS_3/test_c3t3.cpp +++ b/SMDS_3/test/SMDS_3/test_c3t3.cpp @@ -49,6 +49,9 @@ struct Tester typedef typename C3t3::Facets_in_complex_iterator Facet_iterator; typedef typename C3t3::Vertex_handle Vertex_handle; + typedef typename C3t3::Vertices_in_complex Vertices_in_complex; + typedef typename C3t3::Cells_in_complex Cells_in_complex; + typedef typename C3t3::Subdomain_index Subdomain_index; typedef typename C3t3::Surface_patch_index Surface_patch_index; typedef typename C3t3::Index Index; @@ -120,6 +123,22 @@ struct Tester assert(c3t3.is_in_complex(ch)); assert(c3t3.subdomain_index(ch) == subdomain_index); + { + Cell_handle ch = *c3t3.cells_in_complex().begin(); + for (auto c : c3t3.cells_in_complex()) { + assert(c == ch); + break; + } + } + /* + { + Vertex_handle vh = *c3t3.vertices_in_complex().begin(); + for (auto v : c3t3.vertices_in_complex()) { + assert(v == vh); + break; + } + } + */ //------------------------------------------------------- // Test move construction //------------------------------------------------------- From 54b7ae45cb611d631fbc909e4a33c00631427879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 28 Jun 2023 13:41:08 +0200 Subject: [PATCH 09/15] add missing const --- SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h | 2 +- SMDS_3/test/SMDS_3/test_c3t3.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index a88bbe0e0149..a46d7903ac3d 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -984,7 +984,7 @@ class Mesh_complex_3_in_triangulation_3 pointer operator->() const { return *(this->base()); } reference operator*() const { return **(this->base()); } - operator Vertex_handle() { return Vertex_handle(*(this->base())); } + operator Vertex_handle() const { return Vertex_handle(*(this->base())); } }; public: diff --git a/SMDS_3/test/SMDS_3/test_c3t3.cpp b/SMDS_3/test/SMDS_3/test_c3t3.cpp index 3899c6107f4a..7f8ab928b33b 100644 --- a/SMDS_3/test/SMDS_3/test_c3t3.cpp +++ b/SMDS_3/test/SMDS_3/test_c3t3.cpp @@ -130,7 +130,7 @@ struct Tester break; } } - /* + { Vertex_handle vh = *c3t3.vertices_in_complex().begin(); for (auto v : c3t3.vertices_in_complex()) { @@ -138,7 +138,7 @@ struct Tester break; } } - */ + //------------------------------------------------------- // Test move construction //------------------------------------------------------- From 5e0e0216ff7b6db77b97c28c151e7ceb23d81659 Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Wed, 28 Jun 2023 12:48:48 +0100 Subject: [PATCH 10/15] Remove blank in front of point ending a comment --- .../include/CGAL/Arrangement_on_surface_2.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Arrangement_on_surface_2/include/CGAL/Arrangement_on_surface_2.h b/Arrangement_on_surface_2/include/CGAL/Arrangement_on_surface_2.h index 438f46ced1cf..e133a3251834 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arrangement_on_surface_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arrangement_on_surface_2.h @@ -1041,7 +1041,7 @@ class Arrangement_on_surface_2 { } /*! - returns a range over handles of the arrangement vertices . + returns a range over handles of the arrangement vertices. */ Iterator_range > vertex_handles() @@ -1066,7 +1066,7 @@ class Arrangement_on_surface_2 { } /*! - returns a const range (model of `ConstRange`) over handles of the arrangement vertices . + returns a const range (model of `ConstRange`) over handles of the arrangement vertices. */ Iterator_range > vertex_handles() const @@ -1096,7 +1096,7 @@ class Arrangement_on_surface_2 { } /*! - returns a range over handles of the arrangement halfedges . + returns a range over handles of the arrangement halfedges. */ Iterator_range > halfedge_handles() @@ -1120,7 +1120,7 @@ class Arrangement_on_surface_2 { _Is_valid_halfedge(&m_topol_traits))); } /*! - returns a const range (model of `ConstRange`) over handles of the arrangement halfedges . + returns a const range (model of `ConstRange`) over handles of the arrangement halfedges. */ Iterator_range > halfedge_handles() const @@ -1147,7 +1147,7 @@ class Arrangement_on_surface_2 { } /*! - returns a range over handles of the arrangement edges . + returns a range over handles of the arrangement edges. */ Iterator_range > edge_handles() @@ -1170,7 +1170,7 @@ class Arrangement_on_surface_2 { } /*! - returns a const range (model of `ConstRange`) over handles of the arrangement edges . + returns a const range (model of `ConstRange`) over handles of the arrangement edges. */ Iterator_range > edge_handles() const @@ -1197,7 +1197,7 @@ class Arrangement_on_surface_2 { } /*! - returns a range over handles of the arrangement faces . + returns a range over handles of the arrangement faces. */ Iterator_range > face_handles() @@ -1219,7 +1219,7 @@ class Arrangement_on_surface_2 { } /*! - returns a const range (model of `ConstRange`) over handles of the arrangement faces . + returns a const range (model of `ConstRange`) over handles of the arrangement faces. */ Iterator_range > face_handles() const From 134909378cef63218676eb0b3324ca2d0766d7b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 29 Jun 2023 14:57:55 +0200 Subject: [PATCH 11/15] fix test --- SMDS_3/test/SMDS_3/test_c3t3.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/SMDS_3/test/SMDS_3/test_c3t3.cpp b/SMDS_3/test/SMDS_3/test_c3t3.cpp index 7f8ab928b33b..c06443308d6d 100644 --- a/SMDS_3/test/SMDS_3/test_c3t3.cpp +++ b/SMDS_3/test/SMDS_3/test_c3t3.cpp @@ -132,10 +132,13 @@ struct Tester } { - Vertex_handle vh = *c3t3.vertices_in_complex().begin(); - for (auto v : c3t3.vertices_in_complex()) { - assert(v == vh); - break; + if (!c3t3.vertices_in_complex().empty()) + { + Vertex_handle vh = *c3t3.vertices_in_complex().begin(); + for (auto v : c3t3.vertices_in_complex()) { + assert(v == vh); + break; + } } } From 13cf0b677dac1ba6e1b8c1f8f66e2e678eb96ddd Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 29 Jun 2023 14:47:57 +0100 Subject: [PATCH 12/15] Move a range test --- SMDS_3/test/SMDS_3/test_c3t3.cpp | 12 +----------- SMDS_3/test/SMDS_3/test_c3t3_with_features.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/SMDS_3/test/SMDS_3/test_c3t3.cpp b/SMDS_3/test/SMDS_3/test_c3t3.cpp index c06443308d6d..9fe7b744aae2 100644 --- a/SMDS_3/test/SMDS_3/test_c3t3.cpp +++ b/SMDS_3/test/SMDS_3/test_c3t3.cpp @@ -123,6 +123,7 @@ struct Tester assert(c3t3.is_in_complex(ch)); assert(c3t3.subdomain_index(ch) == subdomain_index); + // Test iterator range { Cell_handle ch = *c3t3.cells_in_complex().begin(); for (auto c : c3t3.cells_in_complex()) { @@ -131,17 +132,6 @@ struct Tester } } - { - if (!c3t3.vertices_in_complex().empty()) - { - Vertex_handle vh = *c3t3.vertices_in_complex().begin(); - for (auto v : c3t3.vertices_in_complex()) { - assert(v == vh); - break; - } - } - } - //------------------------------------------------------- // Test move construction //------------------------------------------------------- diff --git a/SMDS_3/test/SMDS_3/test_c3t3_with_features.cpp b/SMDS_3/test/SMDS_3/test_c3t3_with_features.cpp index 737bfcacb334..713d0f6ac9bd 100644 --- a/SMDS_3/test/SMDS_3/test_c3t3_with_features.cpp +++ b/SMDS_3/test/SMDS_3/test_c3t3_with_features.cpp @@ -218,6 +218,18 @@ struct Tester || ( v == vp4 && tr.point(vit) == p4 ) ); assert ( tv1.in_dimension() == tv2.in_dimension() ); + + + // Test iterator range + { + Vertex_handle vh = *c3t3.vertices_in_complex().begin(); + for (auto v : c3t3.vertices_in_complex()) { + assert(v == vh); + break; + } + } + + //------------------------------------------------------- // Check adjacencies //------------------------------------------------------- From 797c05657788608128be8d27012c4c0adda8f19f Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 21 May 2024 08:53:48 +0200 Subject: [PATCH 13/15] Prevent_deref, major changes Now the second parameter is the `reference` type and no longer the `value_type`. --- STL_Extension/include/CGAL/iterator.h | 27 ++++++++++--------- .../test/STL_Extension/issue_7400.cpp | 18 +++++-------- .../include/CGAL/IO/PLY/PLY_reader.h | 2 +- .../include/CGAL/Regular_triangulation_2.h | 10 +++---- .../include/CGAL/Triangulation_2.h | 8 +++--- .../include/CGAL/Triangulation_3.h | 12 ++++----- .../CGAL/Triangulation_segment_traverser_3.h | 2 +- .../include/CGAL/Triangulation_on_sphere_2.h | 4 +-- 8 files changed, 39 insertions(+), 44 deletions(-) diff --git a/STL_Extension/include/CGAL/iterator.h b/STL_Extension/include/CGAL/iterator.h index ab7db5b4f3e6..0e72a1ed44e2 100644 --- a/STL_Extension/include/CGAL/iterator.h +++ b/STL_Extension/include/CGAL/iterator.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -37,32 +38,32 @@ namespace CGAL { -template +template class Prevent_deref : public boost::iterator_adaptor< - Prevent_deref + Prevent_deref , I // base - , Value_type // value - , typename std::iterator_traits::iterator_category - , Value_type // ref + , CGAL::cpp20::remove_cvref_t // value + , boost::use_default // category + , Reference_type // ref > { public: - typedef boost::iterator_adaptor< - Prevent_deref + using Value_type = CGAL::cpp20::remove_cvref_t; + using Base = boost::iterator_adaptor< + Prevent_deref , I // base , Value_type // value - , typename std::iterator_traits::iterator_category - , Value_type // ref - > Base; - typedef typename Base::reference reference; + , boost::use_default // category + , Reference_type // ref + >; typedef typename std::pair range; Prevent_deref() = default; Prevent_deref(const I& i) : Base(i) {} private: friend class boost::iterator_core_access; - reference dereference() const { + Reference_type dereference() const { return this->base_reference(); } }; @@ -614,7 +615,7 @@ struct Filter_iterator { reference operator*() const { return *c_; } pointer operator->() const { return &*c_; } const Predicate& predicate() const { return p_; } - Iterator base() const { return c_; } + const Iterator& base() const { return c_; } Iterator end() const { return e_; } bool is_end() const { return (c_ == e_); } diff --git a/STL_Extension/test/STL_Extension/issue_7400.cpp b/STL_Extension/test/STL_Extension/issue_7400.cpp index 1ce1ce750ddb..d77871166106 100644 --- a/STL_Extension/test/STL_Extension/issue_7400.cpp +++ b/STL_Extension/test/STL_Extension/issue_7400.cpp @@ -1,19 +1,13 @@ #include #include -// Add C++20 utilities to C++14 -template< class T > -struct remove_cvref { - typedef std::remove_cv_t> type; -}; - -template< class T > -using remove_cvref_t = typename remove_cvref::type; +#include +// Add C++20 utilities to C++14 template using iter_value_t = std::remove_reference_t())>; template -using range_value_t = iter_value_t()))>>; +using range_value_t = iter_value_t()))>>; template< class T, class U > constexpr bool is_same_v = std::is_same::value; @@ -32,16 +26,16 @@ using Vertex_handle = Triangulation::Vertex_handle; Triangulation t; // Tds::vertex_handles() -> Vertex_handle -static_assert(is_same_v, Vertex_handle>); +static_assert(is_same_v, const Vertex_handle>); // Triangulation::all_vertex_handles() -> Vertex_handle -static_assert(is_same_v, Vertex_handle>); +static_assert(is_same_v, const Vertex_handle>); // Triangulation::finite_vertex_handles() -> convertible to Vertex_handle static_assert(is_convertible_v); // But is it equal to Vertex_handle -static_assert(is_same_v, Vertex_handle>); +static_assert(is_same_v, const Vertex_handle>); int main() { diff --git a/Stream_support/include/CGAL/IO/PLY/PLY_reader.h b/Stream_support/include/CGAL/IO/PLY/PLY_reader.h index ee8b18ef59c0..c35bc6d4141d 100644 --- a/Stream_support/include/CGAL/IO/PLY/PLY_reader.h +++ b/Stream_support/include/CGAL/IO/PLY/PLY_reader.h @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include diff --git a/Triangulation_2/include/CGAL/Regular_triangulation_2.h b/Triangulation_2/include/CGAL/Regular_triangulation_2.h index 6fd315e14906..54938928e5c4 100644 --- a/Triangulation_2/include/CGAL/Regular_triangulation_2.h +++ b/Triangulation_2/include/CGAL/Regular_triangulation_2.h @@ -162,7 +162,7 @@ class Regular_triangulation_2 Self & operator--() { Base::operator--(); return *this; } Self operator++(int) { Self tmp(*this); ++(*this); return tmp; } Self operator--(int) { Self tmp(*this); --(*this); return tmp; } - operator Vertex_handle() const { return Base::base(); } + operator const Vertex_handle&() const { return Base::base(); } }; typedef Iterator_range > All_vertex_handles; @@ -179,11 +179,11 @@ class Regular_triangulation_2 Self & operator--() { Base::operator--(); return *this; } Self operator++(int) { Self tmp(*this); ++(*this); return tmp; } Self operator--(int) { Self tmp(*this); --(*this); return tmp; } - operator Vertex_handle() const { return Base::base(); } + operator const Vertex_handle&() const { return Base::base(); } }; typedef Iterator_range > Finite_vertex_handles; + const Vertex_handle&>> Finite_vertex_handles; class Hidden_vertices_iterator : public Filter_iterator @@ -197,11 +197,11 @@ class Regular_triangulation_2 Self & operator--() { Base::operator--(); return *this; } Self operator++(int) { Self tmp(*this); ++(*this); return tmp; } Self operator--(int) { Self tmp(*this); --(*this); return tmp; } - operator Vertex_handle() const { return Base::base(); } + operator const Vertex_handle&() const { return Base::base(); } }; typedef Iterator_range > Hidden_vertex_handles; + const Vertex_handle&>> Hidden_vertex_handles; //for backward compatibility typedef Finite_faces_iterator Face_iterator; diff --git a/Triangulation_2/include/CGAL/Triangulation_2.h b/Triangulation_2/include/CGAL/Triangulation_2.h index 3c2df49dddd6..5ae5f1602b35 100644 --- a/Triangulation_2/include/CGAL/Triangulation_2.h +++ b/Triangulation_2/include/CGAL/Triangulation_2.h @@ -172,7 +172,7 @@ class Triangulation_2 Self & operator--() { Base::operator--(); return *this; } Self operator++(int) { Self tmp(*this); ++(*this); return tmp; } Self operator--(int) { Self tmp(*this); --(*this); return tmp; } - operator Vertex_handle() const { return Base::base(); } + operator const Vertex_handle&() const { return Base::base(); } }; class Finite_faces_iterator @@ -187,7 +187,7 @@ class Triangulation_2 Self & operator--() { Base::operator--(); return *this; } Self operator++(int) { Self tmp(*this); ++(*this); return tmp; } Self operator--(int) { Self tmp(*this); --(*this); return tmp; } - operator Face_handle() const { return Base::base(); } + operator const Face_handle&() const { return Base::base(); } }; typedef Filter_iterator > Finite_face_handles; + const Face_handle&>> Finite_face_handles; typedef Iterator_range > Finite_vertex_handles; + const Vertex_handle&>> Finite_vertex_handles; typedef Iterator_range Finite_edges; typedef Iterator_range Points; diff --git a/Triangulation_3/include/CGAL/Triangulation_3.h b/Triangulation_3/include/CGAL/Triangulation_3.h index 6e9e6417ed67..01750a20d063 100644 --- a/Triangulation_3/include/CGAL/Triangulation_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_3.h @@ -495,7 +495,7 @@ class Triangulation_3 Self operator++(int) { Self tmp(*this); ++(*this); return tmp; } Self operator--(int) { Self tmp(*this); --(*this); return tmp; } - operator Cell_handle() const { return Base::base(); } + operator const Cell_handle&() const { return Base::base(); } }; // We derive in order to add a conversion to handle. @@ -514,13 +514,13 @@ class Triangulation_3 Self operator++(int) { Self tmp(*this); ++(*this); return tmp; } Self operator--(int) { Self tmp(*this); --(*this); return tmp; } - operator Vertex_handle() const { return Base::base(); } + operator const Vertex_handle&() const { return Base::base(); } }; typedef Iterator_range > Finite_cell_handles; + const Cell_handle&> > Finite_cell_handles; typedef Iterator_range > Finite_vertex_handles; + const Vertex_handle&> > Finite_vertex_handles; typedef Filter_iterator Finite_edges_iterator; typedef Filter_iterator Finite_facets_iterator; @@ -532,7 +532,7 @@ class Triangulation_3 typedef Triangulation_segment_simplex_iterator_3 Segment_simplex_iterator; typedef Iterator_range > Segment_traverser_cell_handles; + const Cell_handle&> > Segment_traverser_cell_handles; typedef Iterator_range Segment_traverser_simplices; private: @@ -2269,7 +2269,7 @@ class Triangulation_3 Segment_traverser_cell_handles segment_traverser_cell_handles(Vertex_handle vs, Vertex_handle vt) const { - return {segment_traverser_cells_begin(vs, vt),segment_traverser_cells_end()}; + return {segment_traverser_cells_begin(vs, vt), segment_traverser_cells_end()}; } Segment_traverser_cell_handles segment_traverser_cell_handles(const Point& ps, const Point& pt, diff --git a/Triangulation_3/include/CGAL/Triangulation_segment_traverser_3.h b/Triangulation_3/include/CGAL/Triangulation_segment_traverser_3.h index c098ec429d33..6f25e793fda1 100644 --- a/Triangulation_3/include/CGAL/Triangulation_segment_traverser_3.h +++ b/Triangulation_3/include/CGAL/Triangulation_segment_traverser_3.h @@ -328,7 +328,7 @@ class Triangulation_segment_cell_iterator_3 // provides a conversion operator. /* \return a handle to the current cell. */ - operator Cell_handle() const + operator const Cell_handle&() const { return _cur.cell; } diff --git a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h index 57f8117a7f25..a9e74f5a4eda 100644 --- a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h +++ b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h @@ -275,7 +275,7 @@ class Triangulation_on_sphere_2 // solid edges: both incident faces are solid typedef Filter_iterator Solid_edges_iterator; typedef Iterator_range Solid_edges; - typedef Iterator_range > Solid_face_handles; + typedef Iterator_range> Solid_face_handles; typedef Project_point Pt_proj; typedef boost::transform_iterator Point_iterator; @@ -321,7 +321,7 @@ class Triangulation_on_sphere_2 Solid_face_handles solid_faces() const { - return { solid_faces_begin(), solid_faces_end() }; + return { solid_faces_begin(), solid_faces_end() }; } Solid_edges_iterator solid_edges_begin() const From 1289cadc7a7d5052f743454a360717f43a29b233 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 21 May 2024 18:01:11 +0200 Subject: [PATCH 14/15] fix iterators types in c3t3 --- .../CGAL/Mesh_complex_3_in_triangulation_3.h | 14 +++++++------- SMDS_3/test/SMDS_3/test_c3t3_with_features.cpp | 7 ++++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h index 461f784aa6ed..db0cc2fa28d0 100644 --- a/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h +++ b/SMDS_3/include/CGAL/Mesh_complex_3_in_triangulation_3.h @@ -444,8 +444,8 @@ class Mesh_complex_3_in_triangulation_3 */ void remove_from_complex(const Vertex_handle& v) { - corners_.erase(v); v->set_dimension(-1); + corners_.erase(v); } /** sets the index of vertex \p vertex to \p index @@ -983,7 +983,7 @@ class Mesh_complex_3_in_triangulation_3 pointer operator->() const { return *(this->base()); } reference operator*() const { return **(this->base()); } - operator Vertex_handle() const { return Vertex_handle(*(this->base())); } + operator const Vertex_handle&() const { return *(this->base()); } }; public: @@ -1048,13 +1048,13 @@ class Mesh_complex_3_in_triangulation_3 Self operator++(int) { Self tmp(*this); ++(*this); return tmp; } Self operator--(int) { Self tmp(*this); --(*this); return tmp; } - operator Cell_handle() const { return Cell_handle(this->base()); } + operator const Cell_handle&() const { return this->base(); } }; // end class Cells_in_complex_iterator - typedef Iterator_range > Vertices_in_complex; - typedef Iterator_range Edges_in_complex; - typedef Iterator_range Facets_in_complex; - typedef Iterator_range > Cells_in_complex; + typedef Iterator_range> Vertices_in_complex; + typedef Iterator_range Edges_in_complex; + typedef Iterator_range Facets_in_complex; + typedef Iterator_range> Cells_in_complex; #endif diff --git a/SMDS_3/test/SMDS_3/test_c3t3_with_features.cpp b/SMDS_3/test/SMDS_3/test_c3t3_with_features.cpp index 713d0f6ac9bd..4373da1fdc02 100644 --- a/SMDS_3/test/SMDS_3/test_c3t3_with_features.cpp +++ b/SMDS_3/test/SMDS_3/test_c3t3_with_features.cpp @@ -347,8 +347,13 @@ struct Tester //------------------------------------------------------- std::cout << "Test vertex iterators\n"; const Vertex_handle& vertex_to_modify = c3t3.vertices_in_complex_begin(); + Vertex_handle vertex_to_modify_copy = vertex_to_modify; + c3t3.remove_from_complex(vertex_to_modify); - c3t3.add_to_complex(vertex_to_modify,corner_index_bis); + // now `vertex_to_modify` is a dangling ref to a `Vertex_handle` + + // use a copy of it: `vertex_to_modify_copy` + c3t3.add_to_complex(vertex_to_modify_copy,corner_index_bis); typename C3t3::Vertices_in_complex_iterator corner_vit = c3t3.vertices_in_complex_begin(corner_index); From ce164362e145575ad403d5919e5fcd69a3199bb2 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 21 May 2024 18:37:13 +0200 Subject: [PATCH 15/15] fix for ToS ``` 100% tests passed, 0 tests failed out of 17 Label Time Summary: CGAL_build_system = 0.78 sec*proc (1 test) Installation = 0.78 sec*proc (1 test) Triangulation_on_sphere_2_Tests = 102.51 sec*proc (16 tests) ``` --- .../include/CGAL/Triangulation_on_sphere_2.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h index a9e74f5a4eda..35c2ef8d7e00 100644 --- a/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h +++ b/Triangulation_on_sphere_2/include/CGAL/Triangulation_on_sphere_2.h @@ -262,7 +262,7 @@ class Triangulation_on_sphere_2 Self& operator--() { Base::operator--(); return *this; } Self operator++(int) { Self tmp(*this); ++(*this); return tmp; } Self operator--(int) { Self tmp(*this); --(*this); return tmp; } - operator const Face_handle() const { return Base::base(); } + operator const Face_handle&() const { return Base::base(); } }; typedef Iterator_range > Vertex_handles;