From b5a180d9df940ea12e9ac9174ebf568f00216fa6 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 26 Sep 2025 10:22:15 +0200 Subject: [PATCH] fix the confusion between `handle` and `const_handle` --- .../Conforming_constrained_Delaunay_triangulation_3.h | 2 +- STL_Extension/include/CGAL/iterator.h | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h b/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h index 241f0e0eb30..21b63c5eb3a 100644 --- a/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h +++ b/Constrained_triangulation_3/include/CGAL/Conforming_constrained_Delaunay_triangulation_3.h @@ -2227,7 +2227,7 @@ private: if(it != e) { return *it; } else { - return std::as_const(vertices_of_cavity_union_find).end(); + return vertices_of_cavity_union_find.end(); } }); CGAL_assertion(vertex_below_handle == vertices_of_cavity_union_find.end() || diff --git a/STL_Extension/include/CGAL/iterator.h b/STL_Extension/include/CGAL/iterator.h index 8f8a2228b07..9deb7a73ea0 100644 --- a/STL_Extension/include/CGAL/iterator.h +++ b/STL_Extension/include/CGAL/iterator.h @@ -82,8 +82,14 @@ Iterator_range > make_prevent_deref_range(const I& begin, const } template -auto make_prevent_deref_range(const R& range) +auto make_prevent_deref_range(R&& range) { + static_assert( !std::is_rvalue_reference_v, + "make_prevent_deref_range cannot be used with" + " rvalue references to avoid dangling references"); + // Note: If CGAL were allowed to use C++20, we could use `std::ranges::begin/end`. + // That would allow this to work with rvalue ranges when `std::borrowed_range` is `true`. + // See https://en.cppreference.com/w/cpp/ranges/begin.html#Notes using std::begin; using std::end; return make_range(make_prevent_deref(begin(range)), make_prevent_deref(end(range)));