From 8d062a88ce2f9880974d99651d036f1381a81608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Thu, 6 Apr 2023 17:25:17 +0200 Subject: [PATCH 01/32] example of perfect forwarding for Point_3 --- Cartesian_kernel/include/CGAL/Cartesian/Point_3.h | 5 +++++ Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h | 5 ++++- .../include/CGAL/Cartesian/function_objects.h | 8 ++++++++ Kernel_23/include/CGAL/Point_3.h | 9 ++++++++- 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h index 1bd80cdb016..205a9af6346 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h @@ -45,6 +45,11 @@ public: PointC3(const FT &x, const FT &y, const FT &z) : base(x, y, z) {} + PointC3(FT &&x, FT &&y, FT &&z) + : base(std::forward(x), std::forward(y), std::forward(z)) + {} + + PointC3(const FT &x, const FT &y, const FT &z, const FT &w) : base(x, y, z, w) {} diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h index 5b03e8d0fb3..55862b39bc8 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h @@ -65,7 +65,10 @@ public: { *this = R().construct_vector_3_object()(l); } VectorC3(const FT_ &x, const FT_ &y, const FT_ &z) - : base(CGAL::make_array(x, y, z)) {} + : base(Rep{x, y, z}) {} + + VectorC3(FT_ &&x, FT_ &&y, FT_ &&z) + : base(Rep{x, y, z}) {} VectorC3(const FT_ &x, const FT_ &y, const FT_ &z, const FT_ &w) : base( w != FT_(1) ? CGAL::make_array(x/w, y/w, z/w) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index 737a52dfc14..effe3bf68a9 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -3160,6 +3160,10 @@ namespace CartesianKernelFunctors { operator()(Return_base_tag, const RT& x, const RT& y, const RT& z) const { return Rep(x, y, z); } + Rep // Point_3 + operator()(Return_base_tag, RT&& x, RT&& y, RT&& z) const + { return Rep(std::forward(x), std::forward(y), std::forward(z)); } + Rep // Point_3 operator()(Return_base_tag, const RT& x, const RT& y, const RT& z, const RT& w) const { return Rep(x, y, z, w); } @@ -3180,6 +3184,10 @@ namespace CartesianKernelFunctors { operator()(const RT& x, const RT& y, const RT& z) const { return Point_3(x, y, z); } + Point_3 + operator()(RT&& x, RT&& y, RT&& z) const + { return Point_3(std::forward(x), std::forward(y), std::forward(z)); } + Point_3 operator()(const RT& x, const RT& y, const RT& z, const RT& w) const { return Point_3(x, y, z, w); } diff --git a/Kernel_23/include/CGAL/Point_3.h b/Kernel_23/include/CGAL/Point_3.h index 03d00f78f3f..127e7746089 100644 --- a/Kernel_23/include/CGAL/Point_3.h +++ b/Kernel_23/include/CGAL/Point_3.h @@ -79,6 +79,13 @@ public: : Rep(typename R::Construct_point_3()(Return_base_tag(), x, y, z)) {} + template < typename T1, typename T2, typename T3 > + Point_3(T1&& x, T2&& y, T3&& z) + : Rep(typename R::Construct_point_3()(Return_base_tag(), std::forward(x), + std::forward(y), + std::forward(z))) + {} + Point_3(const RT& hx, const RT& hy, const RT& hz, const RT& hw) : Rep(typename R::Construct_point_3()(Return_base_tag(), hx, hy, hz, hw)) {} @@ -283,7 +290,7 @@ extract(std::istream& is, Point_3& p, const Cartesian_tag&) break; } if (is) - p = Point_3(x, y, z); + p = Point_3(std::move(x), std::move(y), std::move(z)); return is; } From 6dec6c320dc8eb2e2b55e2e359a3dfc0e856e18c Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Thu, 6 Apr 2023 17:49:24 +0100 Subject: [PATCH 02/32] More forwarding --- Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h | 2 +- Cartesian_kernel/include/CGAL/Cartesian/function_objects.h | 4 ++++ Kernel_23/include/CGAL/Vector_3.h | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h index 55862b39bc8..cf0df15df76 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h @@ -68,7 +68,7 @@ public: : base(Rep{x, y, z}) {} VectorC3(FT_ &&x, FT_ &&y, FT_ &&z) - : base(Rep{x, y, z}) {} + : base(Rep{std::forward(x), std::forward(y), std::forward(z)}) {} VectorC3(const FT_ &x, const FT_ &y, const FT_ &z, const FT_ &w) : base( w != FT_(1) ? CGAL::make_array(x/w, y/w, z/w) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index effe3bf68a9..0425e888b54 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -3679,6 +3679,10 @@ namespace CartesianKernelFunctors { operator()(Return_base_tag, const RT& x, const RT& y, const RT& z) const { return Rep(x, y, z); } + Rep // Vector_3 + operator()(Return_base_tag, RT&& x, RT&& y, RT&& z) const + { return Rep(std::forward(x), std::forward(y), std::forward(z)); } + Rep // Vector_3 operator()(Return_base_tag, const RT& x, const RT& y, const RT& z, const RT& w) const { return Rep(x, y, z, w); } diff --git a/Kernel_23/include/CGAL/Vector_3.h b/Kernel_23/include/CGAL/Vector_3.h index f81aee480f4..e8cf72bdf87 100644 --- a/Kernel_23/include/CGAL/Vector_3.h +++ b/Kernel_23/include/CGAL/Vector_3.h @@ -91,6 +91,13 @@ public: Vector_3(const T1 &x, const T2 &y, const T3 &z) : Rep(typename R::Construct_vector_3()(Return_base_tag(), x, y, z)) {} + template < typename T1, typename T2, typename T3 > + Vector_3(T1&& x, T2&& y, T3&& z) + : Rep(typename R::Construct_vector_3()(Return_base_tag(), std::forward(x), + std::forward(y), + std::forward(z))) + {} + Vector_3(const RT& x, const RT& y, const RT& z, const RT& w) : Rep(typename R::Construct_vector_3()(Return_base_tag(), x, y, z, w)) {} From c0ec1b96f5eac0bcdacb59d191b21c94efc041f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Fri, 7 Apr 2023 11:28:20 +0200 Subject: [PATCH 03/32] fix after Laurent's comment --- Cartesian_kernel/include/CGAL/Cartesian/Point_3.h | 5 +++-- .../include/CGAL/Cartesian/Vector_3.h | 5 +++-- .../include/CGAL/Cartesian/function_objects.h | 15 +++++++++------ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h index 205a9af6346..dbf142967b7 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h @@ -45,8 +45,9 @@ public: PointC3(const FT &x, const FT &y, const FT &z) : base(x, y, z) {} - PointC3(FT &&x, FT &&y, FT &&z) - : base(std::forward(x), std::forward(y), std::forward(z)) + template + PointC3(T1 &&x, T2 &&y, T3 &&z) + : base(std::forward(x), std::forward(y), std::forward(z)) {} diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h index cf0df15df76..9d9d1bfdb6f 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h @@ -67,8 +67,9 @@ public: VectorC3(const FT_ &x, const FT_ &y, const FT_ &z) : base(Rep{x, y, z}) {} - VectorC3(FT_ &&x, FT_ &&y, FT_ &&z) - : base(Rep{std::forward(x), std::forward(y), std::forward(z)}) {} + template + VectorC3(T1 &&x, T2 &&y, T3 &&z) + : base(Rep{std::forward(x), std::forward(y), std::forward(z)}) {} VectorC3(const FT_ &x, const FT_ &y, const FT_ &z, const FT_ &w) : base( w != FT_(1) ? CGAL::make_array(x/w, y/w, z/w) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index 0425e888b54..cbdbfe22ac7 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -3160,9 +3160,10 @@ namespace CartesianKernelFunctors { operator()(Return_base_tag, const RT& x, const RT& y, const RT& z) const { return Rep(x, y, z); } + template Rep // Point_3 - operator()(Return_base_tag, RT&& x, RT&& y, RT&& z) const - { return Rep(std::forward(x), std::forward(y), std::forward(z)); } + operator()(Return_base_tag, T1&& x, T2&& y, T3&& z) const + { return Rep(std::forward(x), std::forward(y), std::forward(z)); } Rep // Point_3 operator()(Return_base_tag, const RT& x, const RT& y, const RT& z, const RT& w) const @@ -3184,9 +3185,10 @@ namespace CartesianKernelFunctors { operator()(const RT& x, const RT& y, const RT& z) const { return Point_3(x, y, z); } + template Point_3 - operator()(RT&& x, RT&& y, RT&& z) const - { return Point_3(std::forward(x), std::forward(y), std::forward(z)); } + operator()(T1&& x, T2&& y, T3&& z) const + { return Point_3(std::forward(x), std::forward(y), std::forward(z)); } Point_3 operator()(const RT& x, const RT& y, const RT& z, const RT& w) const @@ -3679,9 +3681,10 @@ namespace CartesianKernelFunctors { operator()(Return_base_tag, const RT& x, const RT& y, const RT& z) const { return Rep(x, y, z); } + template Rep // Vector_3 - operator()(Return_base_tag, RT&& x, RT&& y, RT&& z) const - { return Rep(std::forward(x), std::forward(y), std::forward(z)); } + operator()(Return_base_tag, T1&& x, T2&& y, T3&& z) const + { return Rep(std::forward(x), std::forward(y), std::forward(z)); } Rep // Vector_3 operator()(Return_base_tag, const RT& x, const RT& y, const RT& z, const RT& w) const From 72624bb0f10bf269ed9e88d0c296bf3b23bcb196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 26 Apr 2023 09:55:14 +0200 Subject: [PATCH 04/32] fix narrowing --- Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h | 2 +- STL_Extension/include/CGAL/array.h | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h index 9d9d1bfdb6f..00c23440cbe 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h @@ -69,7 +69,7 @@ public: template VectorC3(T1 &&x, T2 &&y, T3 &&z) - : base(Rep{std::forward(x), std::forward(y), std::forward(z)}) {} + : base(fwd_make_array(std::forward(x), std::forward(y), std::forward(z))) {} VectorC3(const FT_ &x, const FT_ &y, const FT_ &z, const FT_ &w) : base( w != FT_(1) ? CGAL::make_array(x/w, y/w, z/w) diff --git a/STL_Extension/include/CGAL/array.h b/STL_Extension/include/CGAL/array.h index ff234183f99..56fa985bdf7 100644 --- a/STL_Extension/include/CGAL/array.h +++ b/STL_Extension/include/CGAL/array.h @@ -54,6 +54,15 @@ make_array(const T & t, const Args & ... args) return a; } +template< typename T, typename... Args > +BOOST_CXX14_CONSTEXPR +std::array< T, sizeof...(Args) > +fwd_make_array(Args && ... args) +{ + std::array< T, sizeof...(Args) > a = { { static_cast(args)... } }; + return a; +} + // Functor version struct Construct_array From a6098368a9d11a6d7e7a5fc2b3a0f2be32a2bd0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 26 Apr 2023 13:24:36 +0200 Subject: [PATCH 05/32] really move it --- STL_Extension/include/CGAL/array.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/STL_Extension/include/CGAL/array.h b/STL_Extension/include/CGAL/array.h index 56fa985bdf7..95798883e37 100644 --- a/STL_Extension/include/CGAL/array.h +++ b/STL_Extension/include/CGAL/array.h @@ -59,7 +59,7 @@ BOOST_CXX14_CONSTEXPR std::array< T, sizeof...(Args) > fwd_make_array(Args && ... args) { - std::array< T, sizeof...(Args) > a = { { static_cast(args)... } }; + std::array< T, sizeof...(Args) > a = { T(std::forward(args))... }; return a; } From 661512b28479752eee59185fc5c5bf2fb978829c Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 26 Apr 2023 16:48:30 +0200 Subject: [PATCH 06/32] add a test of CGAL::fwd_make_array --- STL_Extension/include/CGAL/array.h | 2 +- .../test/STL_Extension/CMakeLists.txt | 6 +++++ .../STL_Extension/test_fwd_make_array.cpp | 23 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 STL_Extension/test/STL_Extension/test_fwd_make_array.cpp diff --git a/STL_Extension/include/CGAL/array.h b/STL_Extension/include/CGAL/array.h index 95798883e37..dee843611c3 100644 --- a/STL_Extension/include/CGAL/array.h +++ b/STL_Extension/include/CGAL/array.h @@ -59,7 +59,7 @@ BOOST_CXX14_CONSTEXPR std::array< T, sizeof...(Args) > fwd_make_array(Args && ... args) { - std::array< T, sizeof...(Args) > a = { T(std::forward(args))... }; + std::array< T, sizeof...(Args) > a = { static_cast(std::forward(args))... }; return a; } diff --git a/STL_Extension/test/STL_Extension/CMakeLists.txt b/STL_Extension/test/STL_Extension/CMakeLists.txt index d2590609109..b4b85819e6c 100644 --- a/STL_Extension/test/STL_Extension/CMakeLists.txt +++ b/STL_Extension/test/STL_Extension/CMakeLists.txt @@ -50,6 +50,12 @@ create_single_source_cgal_program("test_Uncertain.cpp") create_single_source_cgal_program("test_vector.cpp") create_single_source_cgal_program("test_join_iterators.cpp") create_single_source_cgal_program("test_for_each.cpp") + +if(cxx_std_17 IN_LIST CMAKE_CXX_COMPILE_FEATURES) + create_single_source_cgal_program("test_fwd_make_array.cpp") + target_compile_features(test_fwd_make_array PUBLIC cxx_std_17) +endif() + if(TARGET CGAL::TBB_support) message(STATUS "Found TBB") target_link_libraries(test_for_each PUBLIC CGAL::TBB_support) diff --git a/STL_Extension/test/STL_Extension/test_fwd_make_array.cpp b/STL_Extension/test/STL_Extension/test_fwd_make_array.cpp new file mode 100644 index 00000000000..305b09d3f1c --- /dev/null +++ b/STL_Extension/test/STL_Extension/test_fwd_make_array.cpp @@ -0,0 +1,23 @@ +#include +#include +#include + +struct B {}; + +struct A // move-only class, move-constructible from B +{ + A(B&&) {} + + A(const A&) = delete; + A(A&&) = default; +}; + +int main() +{ + // this test requires C++17 mandatory return-value optimization (RVO) + std::array a = CGAL::fwd_make_array(B()); + std::array b = CGAL::fwd_make_array(1u); + CGAL_USE(a); + CGAL_USE(b); + return 0; +} From 74a0aa8c20606c2c4b606b8523c39e16585703dd Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 26 Apr 2023 17:10:19 +0200 Subject: [PATCH 07/32] Cstr_point_[23]: simplify the different overloads One perfect forwarding is enough. --- .../include/CGAL/Cartesian/function_objects.h | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index cbdbfe22ac7..1a014253fd6 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -3075,9 +3075,10 @@ namespace CartesianKernelFunctors { typedef const Point_2& type; }; + template Rep // Point_2 - operator()(Return_base_tag, Origin o) const - { return Rep(o); } + operator()(Return_base_tag, Args&& ...args) const + { return Rep(std::forward(args)...); } Rep // Point_2 operator()(Return_base_tag, const RT& x, const RT& y) const @@ -3151,23 +3152,10 @@ namespace CartesianKernelFunctors { typedef const Point_3& type; }; - + template Rep // Point_3 - operator()(Return_base_tag, Origin o) const - { return Rep(o); } - - Rep // Point_3 - operator()(Return_base_tag, const RT& x, const RT& y, const RT& z) const - { return Rep(x, y, z); } - - template - Rep // Point_3 - operator()(Return_base_tag, T1&& x, T2&& y, T3&& z) const - { return Rep(std::forward(x), std::forward(y), std::forward(z)); } - - Rep // Point_3 - operator()(Return_base_tag, const RT& x, const RT& y, const RT& z, const RT& w) const - { return Rep(x, y, z, w); } + operator()(Return_base_tag, Args&& ...args) const + { return Rep(std::forward(args)...); } const Point_3& operator()(const Point_3 & p) const From fbd24d665d6d5947bfca85eadbc2584809d62d46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Mon, 9 Oct 2023 12:30:37 +0200 Subject: [PATCH 08/32] add version for Point_2/Vector_2 --- .../include/CGAL/Cartesian/Point_2.h | 5 +++++ .../include/CGAL/Cartesian/Vector_2.h | 6 +++++- .../include/CGAL/Cartesian/function_objects.h | 18 ++++++++++++++++-- Kernel_23/include/CGAL/Point_2.h | 8 +++++++- Kernel_23/include/CGAL/Vector_2.h | 6 ++++++ 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Point_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Point_2.h index 92a71f42557..0869bd792aa 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Point_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Point_2.h @@ -47,6 +47,11 @@ public: PointC2(const FT &x, const FT &y) : base(x, y) {} + template + PointC2(T1 &&x, T2 &&y) + : base(std::forward(x), std::forward(y)) + {} + PointC2(const FT &hx, const FT &hy, const FT &hw) : base(hx, hy, hw) {} diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h index 575df5d0728..04c71866631 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h @@ -50,7 +50,11 @@ public: VectorC2() {} VectorC2(const FT &x, const FT &y) - : base(CGAL::make_array(x, y)) {} + : base(Rep{x, y}) {} + + template + VectorC2(T1 &&x, T2 &&y) + : base(fwd_make_array(std::forward(x), std::forward(y))) {} VectorC2(const FT &hx, const FT &hy, const FT &hw) : base( hw != FT(1) ? CGAL::make_array(hx/hw, hy/hw) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index 1a014253fd6..4af46fbcbd8 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -3084,6 +3084,11 @@ namespace CartesianKernelFunctors { operator()(Return_base_tag, const RT& x, const RT& y) const { return Rep(x, y); } + template + Rep + operator()(T1&& x, T2&& y) const + { return Rep(std::forward(x), std::forward(y)); } + Rep // Point_2 operator()(Return_base_tag, const RT& x, const RT& y, const RT& w) const { return Rep(x, y, w); } @@ -3533,6 +3538,12 @@ namespace CartesianKernelFunctors { operator()(Return_base_tag, const Point_2& p, const Point_2& q) const { return Rep(q.x() - p.x(), q.y() - p.y()); } + // note that compared to Vector_3 this one is needed as it could be ambiguous + // with operator()(Rbt,FT,FT) version + Rep // Vector_2 + operator()(Return_base_tag, Point_2&& p, Point_2&& q) const + { return Rep(q.x() - p.x(), q.y() - p.y()); } + Rep // Vector_2 operator()(Return_base_tag, const Origin&, const Point_2& q) const { return Rep(q.x(), q.y()); } @@ -3565,12 +3576,15 @@ namespace CartesianKernelFunctors { operator()(Return_base_tag, const RT& x, const RT& y) const { return Rep(x, y); } + template + Rep // Vector_2 + operator()(Return_base_tag, T1&& x, T2&& y) const + { return Rep(/* std::forward(x), std::forward(y) */); } + Rep // Vector_2 operator()(Return_base_tag, const RT& x, const RT& y, const RT& w) const { return Rep(x, y, w); } - - Vector_2 operator()( const Point_2& p, const Point_2& q) const { return this->operator()(Return_base_tag(), p, q); } diff --git a/Kernel_23/include/CGAL/Point_2.h b/Kernel_23/include/CGAL/Point_2.h index 87728264781..497354ded42 100644 --- a/Kernel_23/include/CGAL/Point_2.h +++ b/Kernel_23/include/CGAL/Point_2.h @@ -84,6 +84,12 @@ public: : Rep(typename R::Construct_point_2()(Return_base_tag(), x, y)) {} + template < typename T1, typename T2> + Point_2(T1&& x, T2&& y) + : Rep(typename R::Construct_point_2()(Return_base_tag(), std::forward(x), + std::forward(y))) + {} + Point_2(const RT& hx, const RT& hy, const RT& hw) : RPoint_2(typename R::Construct_point_2()(Return_base_tag(), hx, hy, hw)) {} @@ -255,7 +261,7 @@ extract(std::istream& is, Point_2& p, const Cartesian_tag&) break; } if (is) - p = Point_2(x, y); + p = Point_2(std::move(x), std::move(y)); return is; } diff --git a/Kernel_23/include/CGAL/Vector_2.h b/Kernel_23/include/CGAL/Vector_2.h index 6e62f77fa5d..6066d684716 100644 --- a/Kernel_23/include/CGAL/Vector_2.h +++ b/Kernel_23/include/CGAL/Vector_2.h @@ -91,6 +91,12 @@ public: Vector_2(const T1 &x, const T2 &y) : RVector_2(typename R::Construct_vector_2()(Return_base_tag(), x,y)) {} + template < typename T1, typename T2 > + Vector_2(T1&& x, T2&& y) + : RVector_2(typename R::Construct_vector_2()(Return_base_tag(), std::forward(x), + std::forward(y))) + {} + Vector_2(const RT &x, const RT &y, const RT &w) : RVector_2(typename R::Construct_vector_2()(Return_base_tag(), x,y,w)) {} From 098df72644c8416c6c2cab6c5a1c8631f20533ad Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 27 Mar 2024 10:49:18 +0100 Subject: [PATCH 09/32] remove a useless constructor --- Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h index 00c23440cbe..5733f9165d0 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h @@ -64,9 +64,6 @@ public: explicit VectorC3(const Line_3 &l) { *this = R().construct_vector_3_object()(l); } - VectorC3(const FT_ &x, const FT_ &y, const FT_ &z) - : base(Rep{x, y, z}) {} - template VectorC3(T1 &&x, T2 &&y, T3 &&z) : base(fwd_make_array(std::forward(x), std::forward(y), std::forward(z))) {} From 9c5653dedc8c0fd543b7f5b6698d45b827693403 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 27 Mar 2024 10:49:53 +0100 Subject: [PATCH 10/32] fix the dimension 2 --- Cartesian_kernel/include/CGAL/Cartesian/function_objects.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index 4af46fbcbd8..ed04cdf62cf 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -3085,7 +3085,7 @@ namespace CartesianKernelFunctors { { return Rep(x, y); } template - Rep + std::enable_if_t, Rep> operator()(T1&& x, T2&& y) const { return Rep(std::forward(x), std::forward(y)); } @@ -3579,7 +3579,7 @@ namespace CartesianKernelFunctors { template Rep // Vector_2 operator()(Return_base_tag, T1&& x, T2&& y) const - { return Rep(/* std::forward(x), std::forward(y) */); } + { return Rep(std::forward(x), std::forward(y)); } Rep // Vector_2 operator()(Return_base_tag, const RT& x, const RT& y, const RT& w) const From 87bc0c8ad12c6dcc268e582259a0b78f3a50ff96 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 27 Mar 2024 11:05:41 +0100 Subject: [PATCH 11/32] C++17 is now required since CGAL-6.0 --- STL_Extension/test/STL_Extension/CMakeLists.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/STL_Extension/test/STL_Extension/CMakeLists.txt b/STL_Extension/test/STL_Extension/CMakeLists.txt index b4b85819e6c..73a9b0cc5bf 100644 --- a/STL_Extension/test/STL_Extension/CMakeLists.txt +++ b/STL_Extension/test/STL_Extension/CMakeLists.txt @@ -50,11 +50,7 @@ create_single_source_cgal_program("test_Uncertain.cpp") create_single_source_cgal_program("test_vector.cpp") create_single_source_cgal_program("test_join_iterators.cpp") create_single_source_cgal_program("test_for_each.cpp") - -if(cxx_std_17 IN_LIST CMAKE_CXX_COMPILE_FEATURES) - create_single_source_cgal_program("test_fwd_make_array.cpp") - target_compile_features(test_fwd_make_array PUBLIC cxx_std_17) -endif() +create_single_source_cgal_program("test_fwd_make_array.cpp") if(TARGET CGAL::TBB_support) message(STATUS "Found TBB") From d6c39e52bd8b2ee4902832acc9ba89c981e8654a Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 27 Mar 2024 15:18:32 +0100 Subject: [PATCH 12/32] fixes Use: - perfect forwarding in objects of the kernel (`Point_2`, `Point_3`, `Vector_2`, `Vector_3`), and also in `PointC2`, and `PointC3` (that forward to the equivalent vector) - constructors with rvalue references in `VectorC2` and `VectorC3`. --- .../include/CGAL/Cartesian/Point_2.h | 8 +++---- .../include/CGAL/Cartesian/Point_3.h | 10 ++++----- .../include/CGAL/Cartesian/Vector_2.h | 7 +++--- .../include/CGAL/Cartesian/Vector_3.h | 8 ++++--- .../include/CGAL/Cartesian/function_objects.h | 22 ++++++++----------- Kernel_23/include/CGAL/Point_2.h | 10 +++------ Kernel_23/include/CGAL/Point_3.h | 5 ----- Kernel_23/include/CGAL/Vector_2.h | 9 +++----- Kernel_23/include/CGAL/Vector_3.h | 4 ---- 9 files changed, 31 insertions(+), 52 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Point_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Point_2.h index 0869bd792aa..d11db7d4d68 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Point_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Point_2.h @@ -44,16 +44,14 @@ public: PointC2(const Origin &) : base(NULL_VECTOR) {} - PointC2(const FT &x, const FT &y) - : base(x, y) {} - template PointC2(T1 &&x, T2 &&y) : base(std::forward(x), std::forward(y)) {} - PointC2(const FT &hx, const FT &hy, const FT &hw) - : base(hx, hy, hw) {} + template + PointC2(T1 &&hx, T2 &&hy, T3 &&hw) + : base(std::forward(hx), std::forward(hy), std::forward(hw)) {} friend void swap(Self& a, Self& b) #if !defined(__INTEL_COMPILER) && defined(__cpp_lib_is_swappable) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h index dbf142967b7..e4dcd3357d8 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Point_3.h @@ -42,17 +42,17 @@ public: PointC3(const Origin &) : base(NULL_VECTOR) {} - PointC3(const FT &x, const FT &y, const FT &z) - : base(x, y, z) {} template PointC3(T1 &&x, T2 &&y, T3 &&z) : base(std::forward(x), std::forward(y), std::forward(z)) {} - - PointC3(const FT &x, const FT &y, const FT &z, const FT &w) - : base(x, y, z, w) {} + template + PointC3(T1 &&x, T2 &&y, T3 &&z, T4 &&w) + : base(std::forward(x), std::forward(y), + std::forward(z), std::forward(w)) + {} friend void swap(Self& a, Self& b) #if !defined(__INTEL_COMPILER) && defined(__cpp_lib_is_swappable) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h index 04c71866631..a45cee3fe71 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h @@ -50,11 +50,10 @@ public: VectorC2() {} VectorC2(const FT &x, const FT &y) - : base(Rep{x, y}) {} + : base(CGAL::make_array(x, y)) {} - template - VectorC2(T1 &&x, T2 &&y) - : base(fwd_make_array(std::forward(x), std::forward(y))) {} + VectorC2(FT&& x, FT&& y) + : base(CGAL::fwd_make_array(x, y)) {} VectorC2(const FT &hx, const FT &hy, const FT &hw) : base( hw != FT(1) ? CGAL::make_array(hx/hw, hy/hw) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h index 5733f9165d0..ff9ef65bb7d 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h @@ -64,9 +64,11 @@ public: explicit VectorC3(const Line_3 &l) { *this = R().construct_vector_3_object()(l); } - template - VectorC3(T1 &&x, T2 &&y, T3 &&z) - : base(fwd_make_array(std::forward(x), std::forward(y), std::forward(z))) {} + VectorC3(const FT_ &x, const FT_ &y, const FT_ &z) + : base(CGAL::make_array(x, y, z)) {} + + VectorC3(FT_&& x, FT_&& y, FT_&& z) + : base(CGAL::fwd_make_array(x, y, z)) {} VectorC3(const FT_ &x, const FT_ &y, const FT_ &z, const FT_ &w) : base( w != FT_(1) ? CGAL::make_array(x/w, y/w, z/w) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index ed04cdf62cf..2fc9f5c3acf 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -3538,12 +3538,6 @@ namespace CartesianKernelFunctors { operator()(Return_base_tag, const Point_2& p, const Point_2& q) const { return Rep(q.x() - p.x(), q.y() - p.y()); } - // note that compared to Vector_3 this one is needed as it could be ambiguous - // with operator()(Rbt,FT,FT) version - Rep // Vector_2 - operator()(Return_base_tag, Point_2&& p, Point_2&& q) const - { return Rep(q.x() - p.x(), q.y() - p.y()); } - Rep // Vector_2 operator()(Return_base_tag, const Origin&, const Point_2& q) const { return Rep(q.x(), q.y()); } @@ -3576,15 +3570,18 @@ namespace CartesianKernelFunctors { operator()(Return_base_tag, const RT& x, const RT& y) const { return Rep(x, y); } - template - Rep // Vector_2 - operator()(Return_base_tag, T1&& x, T2&& y) const - { return Rep(std::forward(x), std::forward(y)); } + Rep + operator()(Return_base_tag, RT&& x, RT&& y) const + { return Rep(std::move(x), std::move(y)); } Rep // Vector_2 operator()(Return_base_tag, const RT& x, const RT& y, const RT& w) const { return Rep(x, y, w); } + Rep + operator()(Return_base_tag, RT&& x, RT&& y, RT&& w) const + { return Rep(std::move(x), std::move(y), std::move(w)); } + Vector_2 operator()( const Point_2& p, const Point_2& q) const { return this->operator()(Return_base_tag(), p, q); } @@ -3683,10 +3680,9 @@ namespace CartesianKernelFunctors { operator()(Return_base_tag, const RT& x, const RT& y, const RT& z) const { return Rep(x, y, z); } - template Rep // Vector_3 - operator()(Return_base_tag, T1&& x, T2&& y, T3&& z) const - { return Rep(std::forward(x), std::forward(y), std::forward(z)); } + operator()(Return_base_tag, RT&& x, RT&& y, RT&& z) const + { return Rep(std::move(x), std::move(y), std::move(z)); } Rep // Vector_3 operator()(Return_base_tag, const RT& x, const RT& y, const RT& z, const RT& w) const diff --git a/Kernel_23/include/CGAL/Point_2.h b/Kernel_23/include/CGAL/Point_2.h index 497354ded42..aaa85e81446 100644 --- a/Kernel_23/include/CGAL/Point_2.h +++ b/Kernel_23/include/CGAL/Point_2.h @@ -79,15 +79,11 @@ public: : Rep(wp.point()) {} - template < typename T1, typename T2 > - Point_2(const T1 &x, const T2 &y) - : Rep(typename R::Construct_point_2()(Return_base_tag(), x, y)) - {} - template < typename T1, typename T2> Point_2(T1&& x, T2&& y) - : Rep(typename R::Construct_point_2()(Return_base_tag(), std::forward(x), - std::forward(y))) + : Rep(typename R::Construct_point_2()(Return_base_tag(), + std::forward(x), + std::forward(y))) {} Point_2(const RT& hx, const RT& hy, const RT& hw) diff --git a/Kernel_23/include/CGAL/Point_3.h b/Kernel_23/include/CGAL/Point_3.h index 127e7746089..05f25d8e691 100644 --- a/Kernel_23/include/CGAL/Point_3.h +++ b/Kernel_23/include/CGAL/Point_3.h @@ -74,11 +74,6 @@ public: : Rep(wp.point()) {} - template < typename T1, typename T2, typename T3 > - Point_3(const T1& x, const T2& y, const T3& z) - : Rep(typename R::Construct_point_3()(Return_base_tag(), x, y, z)) - {} - template < typename T1, typename T2, typename T3 > Point_3(T1&& x, T2&& y, T3&& z) : Rep(typename R::Construct_point_3()(Return_base_tag(), std::forward(x), diff --git a/Kernel_23/include/CGAL/Vector_2.h b/Kernel_23/include/CGAL/Vector_2.h index 6066d684716..2b03f194a4f 100644 --- a/Kernel_23/include/CGAL/Vector_2.h +++ b/Kernel_23/include/CGAL/Vector_2.h @@ -87,14 +87,11 @@ public: Vector_2(const Null_vector &v) : RVector_2(typename R::Construct_vector_2()(Return_base_tag(), v)) {} - template < typename T1, typename T2 > - Vector_2(const T1 &x, const T2 &y) - : RVector_2(typename R::Construct_vector_2()(Return_base_tag(), x,y)) {} - template < typename T1, typename T2 > Vector_2(T1&& x, T2&& y) - : RVector_2(typename R::Construct_vector_2()(Return_base_tag(), std::forward(x), - std::forward(y))) + : RVector_2(typename R::Construct_vector_2()(Return_base_tag(), + std::forward(x), + std::forward(y))) {} Vector_2(const RT &x, const RT &y, const RT &w) diff --git a/Kernel_23/include/CGAL/Vector_3.h b/Kernel_23/include/CGAL/Vector_3.h index e8cf72bdf87..cd419404ad0 100644 --- a/Kernel_23/include/CGAL/Vector_3.h +++ b/Kernel_23/include/CGAL/Vector_3.h @@ -87,10 +87,6 @@ public: Vector_3(const Null_vector& v) : Rep(typename R::Construct_vector_3()(Return_base_tag(), v)) {} - template < typename T1, typename T2, typename T3 > - Vector_3(const T1 &x, const T2 &y, const T3 &z) - : Rep(typename R::Construct_vector_3()(Return_base_tag(), x, y, z)) {} - template < typename T1, typename T2, typename T3 > Vector_3(T1&& x, T2&& y, T3&& z) : Rep(typename R::Construct_vector_3()(Return_base_tag(), std::forward(x), From 50c9740cffaa5ca012e98c93696b544916b27a3d Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 27 Mar 2024 23:18:33 +0100 Subject: [PATCH 13/32] fix the use of rvalue references --- Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h | 2 +- Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h index a45cee3fe71..939e80c0c2a 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h @@ -53,7 +53,7 @@ public: : base(CGAL::make_array(x, y)) {} VectorC2(FT&& x, FT&& y) - : base(CGAL::fwd_make_array(x, y)) {} + : base(CGAL::fwd_make_array(std::move(x), std::move(y))) {} VectorC2(const FT &hx, const FT &hy, const FT &hw) : base( hw != FT(1) ? CGAL::make_array(hx/hw, hy/hw) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h index ff9ef65bb7d..f6563db5b7a 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h @@ -68,7 +68,7 @@ public: : base(CGAL::make_array(x, y, z)) {} VectorC3(FT_&& x, FT_&& y, FT_&& z) - : base(CGAL::fwd_make_array(x, y, z)) {} + : base(CGAL::make_array(std::move(x), std::move(y), std::move(z))) {} VectorC3(const FT_ &x, const FT_ &y, const FT_ &z, const FT_ &w) : base( w != FT_(1) ? CGAL::make_array(x/w, y/w, z/w) From d5ae0c9b9487753b697fbe9d6a5b33be6ce91566 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 28 Mar 2024 15:44:47 +0100 Subject: [PATCH 14/32] add a test, and the new class template NT_wrapper --- ...ct_predicates_exact_constructions_kernel.h | 44 +++-- Number_types/include/CGAL/NT_wrapper.h | 177 ++++++++++++++++++ Number_types/test/Number_types/CMakeLists.txt | 1 + .../test/Number_types/wrapping_type.cpp | 44 +++++ 4 files changed, 249 insertions(+), 17 deletions(-) create mode 100644 Number_types/include/CGAL/NT_wrapper.h create mode 100644 Number_types/test/Number_types/wrapping_type.cpp diff --git a/Kernel_23/include/CGAL/Exact_predicates_exact_constructions_kernel.h b/Kernel_23/include/CGAL/Exact_predicates_exact_constructions_kernel.h index f963f2e9ec3..68eb4a252c8 100644 --- a/Kernel_23/include/CGAL/Exact_predicates_exact_constructions_kernel.h +++ b/Kernel_23/include/CGAL/Exact_predicates_exact_constructions_kernel.h @@ -29,8 +29,15 @@ namespace CGAL { +constexpr bool epeck_use_static_filter = +#ifdef CGAL_NO_STATIC_FILTERS + false; +#else + true; +#endif + // Epeck_ft is either Gmpq, or leda_rational, or Quotient -typedef internal::Exact_field_selector::Type Epeck_ft; +using Epeck_ft = internal::Exact_field_selector::Type; // The following are redefined kernels instead of simple typedefs in order to shorten // template name length (for error messages, mangling...). @@ -41,33 +48,36 @@ typedef internal::Exact_field_selector::Type Epeck_ft; class Epeck : public Filtered_kernel_adaptor< Type_equality_wrapper< Simple_cartesian >::Base::Type, Epeck >, -#ifdef CGAL_NO_STATIC_FILTERS - false > -#else - true > -#endif + epeck_use_static_filter > {}; // end class Epeck #else // no CGAL_DONT_USE_LAZY_KERNEL +namespace internal { + template + using Epeck_sc = Simple_cartesian; + using Epeck_interval = Simple_cartesian; + + template + using Epeck_converter = Cartesian_converter, Epeck_interval>; + + template + using Epeck_lazy_base = Lazy_kernel_base, Epeck_interval, Epeck_converter, Kernel>; + + template + using Epeck_lazy_base_with_type_equality = Type_equality_wrapper, Kernel>; +} // namespace internal + // Equivalent to Lazy_kernel > -class Epeck - : public Type_equality_wrapper< - Lazy_kernel_base< Simple_cartesian, - Simple_cartesian, - Cartesian_converter< Simple_cartesian, - Simple_cartesian >, - Epeck>, - Epeck > -{}; +class Epeck : public internal::Epeck_lazy_base_with_type_equality {}; #endif // no CGAL_DONT_USE_LAZY_KERNEL -typedef Epeck Exact_predicates_exact_constructions_kernel; +using Exact_predicates_exact_constructions_kernel = Epeck; template <> struct Triangulation_structural_filtering_traits { - typedef Tag_true Use_structural_filtering_tag; + using Use_structural_filtering_tag = Tag_true; }; } //namespace CGAL diff --git a/Number_types/include/CGAL/NT_wrapper.h b/Number_types/include/CGAL/NT_wrapper.h new file mode 100644 index 00000000000..ac9794f000b --- /dev/null +++ b/Number_types/include/CGAL/NT_wrapper.h @@ -0,0 +1,177 @@ +// Copyright (c) 2024, GeometryFactory Sarl (France). All rights reserved. +// +// This file is part of CGAL (www.cgal.org) +// +// $URL$ +// $Id$ +// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-Commercial +// +// Author(s) : Laurent Rineau + +#ifndef CGAL_NT_WRAPPER_H +#define CGAL_NT_WRAPPER_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace CGAL { + +template +class NT_wrapper { + NT value; + + static void call_f(const std::source_location& l = std::source_location::current()) { + if (f) + f(l); + } + +public: + inline static std::function f; + + NT_wrapper() : value(0) { call_f(); } + NT_wrapper(const NT& val) : value(val) { call_f();} + NT_wrapper(NT&& val) : value(std::move(val)) { call_f(); } + NT_wrapper(int val) : value(val) { call_f(); } + + template >> + NT_wrapper(const NT_wrapper& other) : value(other.get_value()) { call_f(); } + + NT_wrapper(const NT_wrapper& other) : value(other.value) { call_f(); } + NT_wrapper(NT_wrapper&& other) : value(std::move(other.value)) { call_f(); } + ~NT_wrapper() { call_f(); } + + NT_wrapper& operator=(const NT_wrapper& other) { + if (this != &other) { + value = other.value; + call_f(); + } + return *this; + } + + NT_wrapper& operator=(NT_wrapper&& other) { + if (this != &other) { + value = std::move(other.value); + call_f(); + } + return *this; + } + + NT get_value() const { + return value; + } + + operator NT() const { + return value; + } + + NT_wrapper operator+(const NT_wrapper& rhs) const { + return NT_wrapper(value + rhs.value); + } + + NT_wrapper operator-(const NT_wrapper& rhs) const { + return NT_wrapper(value - rhs.value); + } + + NT_wrapper operator*(const NT_wrapper& rhs) const { + return NT_wrapper(value * rhs.value); + } + + NT_wrapper operator/(const NT_wrapper& rhs) const { + return NT_wrapper(value / rhs.value); + } + + NT_wrapper operator/(int rhs) const { + return NT_wrapper(value / rhs); + } + + bool operator==(const NT_wrapper& rhs) const { + return value == rhs.value; + } + + bool operator!=(const NT_wrapper& rhs) const { + return value != rhs.value; + } + + bool operator<(const NT_wrapper& rhs) const { + return value < rhs.value; + } + + bool operator>(const NT_wrapper& rhs) const { + return value > rhs.value; + } + + bool operator<=(const NT_wrapper& rhs) const { + return value <= rhs.value; + } + + bool operator>=(const NT_wrapper& rhs) const { + return value >= rhs.value; + } +}; + +CGAL_DEFINE_COERCION_TRAITS_FROM_TO_TEM(NT_wrapper, double, typename NT) + +template +struct Real_embeddable_traits> + : public INTERN_RET::Real_embeddable_traits_base, + typename Real_embeddable_traits::Is_real_embeddable> +{ + using Type = NT_wrapper; + class Sgn + : public CGAL::cpp98::unary_function< NT, ::CGAL::Sign > { + public: + ::CGAL::Sign operator()( const Type& x ) const { + return CGAL_NTS sign( x.get_value() ); + } + }; + + class To_double + : public CGAL::cpp98::unary_function< NT, double > { + public: + double operator()( const Type& x) const { + return CGAL_NTS to_double( x.get_value() ); + } + }; + + class To_interval + : public CGAL::cpp98::unary_function< NT, std::pair > { + public: + std::pair operator()( const Type& x ) const { + return CGAL_NTS to_interval( x.get_value() ); + } + }; +}; + +namespace internal { + +template +struct Exact_field_selector> { + using Type = NT_wrapper::Type>; + using type = Type; +}; + +template +struct Exact_ring_selector> { + using Type = NT_wrapper::Type>; + using type = Type; +}; + +} // namespace internal + +struct Wrapped_epick + : public CGAL::internal::Epick_with_filtered_predicates, Wrapped_epick> +{}; +struct Wrapped_epeck + : public CGAL::internal::Epeck_lazy_base_with_type_equality, Wrapped_epeck> +{}; + +} // namespace CGAL + +#endif // CGAL_NT_WRAPPER_H \ No newline at end of file diff --git a/Number_types/test/Number_types/CMakeLists.txt b/Number_types/test/Number_types/CMakeLists.txt index 73488a8a819..185649fc75f 100644 --- a/Number_types/test/Number_types/CMakeLists.txt +++ b/Number_types/test/Number_types/CMakeLists.txt @@ -61,6 +61,7 @@ create_single_source_cgal_program("unsigned.cpp") create_single_source_cgal_program("utilities.cpp") create_single_source_cgal_program("Exact_rational.cpp") create_single_source_cgal_program("Mpzf_new.cpp") +create_single_source_cgal_program("wrapping_type.cpp" CXX_FEATURES cxx_std_20) if( CGAL_Core_FOUND ) create_single_source_cgal_program( "CORE_Expr_ticket_4296.cpp" ) diff --git a/Number_types/test/Number_types/wrapping_type.cpp b/Number_types/test/Number_types/wrapping_type.cpp new file mode 100644 index 00000000000..0fead133318 --- /dev/null +++ b/Number_types/test/Number_types/wrapping_type.cpp @@ -0,0 +1,44 @@ +#include +#include + +#include + +struct Map { + std::map m; + void increment(const std::string& key) { + m[key]++; + } + ~Map() { + for(const auto& [key, value] : m) + std::clog << value << " " << key << std::endl; + } +} map; + +void incr_counter(const std::source_location& l) { + map.increment(l.function_name()); +} + +using K = CGAL::Wrapped_epick; + +using EK = CGAL::Wrapped_epeck; + +int main() { + CGAL::NT_wrapper::f = incr_counter; + CGAL::NT_wrapper::f = incr_counter; + K ::Point_2 p1(0, 2), p2(2, 4), p3(4, 6); + EK::Point_2 p4(0, 2), p5(2, 4), p6(4, 6); + exact(p4); + exact(p5); + exact(p6); + [[maybe_unused]] bool result_2d_k = CGAL::orientation(p1, p2, p3) == CGAL::COLLINEAR; + [[maybe_unused]] bool result_2d_e = CGAL::orientation(p4, p5, p6) == CGAL::COLLINEAR; + assert (result_2d_k && result_2d_e); + + for(auto [key, _] : map.m) { + if(key.find("const") != std::string::npos) { + std::cerr << "ERROR: copy constructor called!\n"; + return 1; + } + } + return 0; +} From 8b16105a3d957871056c04c5de9c7e94325ba31e Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 29 Mar 2024 08:30:03 +0100 Subject: [PATCH 15/32] deal with missing --- Number_types/test/Number_types/wrapping_type.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Number_types/test/Number_types/wrapping_type.cpp b/Number_types/test/Number_types/wrapping_type.cpp index 0fead133318..6313e3769a1 100644 --- a/Number_types/test/Number_types/wrapping_type.cpp +++ b/Number_types/test/Number_types/wrapping_type.cpp @@ -1,6 +1,8 @@ #include #include +#include +#if __has_include() #include struct Map { @@ -42,3 +44,10 @@ int main() { } return 0; } + +#else +int main() { + std::cerr << "C++20 not available\n"; + return 0; +} +#endif From 77297df8d61808fc3f578755ca3fe70001128f8d Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 29 Mar 2024 08:36:06 +0100 Subject: [PATCH 16/32] deal with AppleClang 15 --- Number_types/include/CGAL/NT_wrapper.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Number_types/include/CGAL/NT_wrapper.h b/Number_types/include/CGAL/NT_wrapper.h index ac9794f000b..f0f6f108001 100644 --- a/Number_types/include/CGAL/NT_wrapper.h +++ b/Number_types/include/CGAL/NT_wrapper.h @@ -35,22 +35,22 @@ class NT_wrapper { public: inline static std::function f; - NT_wrapper() : value(0) { call_f(); } - NT_wrapper(const NT& val) : value(val) { call_f();} - NT_wrapper(NT&& val) : value(std::move(val)) { call_f(); } - NT_wrapper(int val) : value(val) { call_f(); } + NT_wrapper() : value(0) { call_f(std::source_location::current()); } + NT_wrapper(const NT& val) : value(val) { call_f(std::source_location::current());} + NT_wrapper(NT&& val) : value(std::move(val)) { call_f(std::source_location::current()); } + NT_wrapper(int val) : value(val) { call_f(std::source_location::current()); } template >> - NT_wrapper(const NT_wrapper& other) : value(other.get_value()) { call_f(); } + NT_wrapper(const NT_wrapper& other) : value(other.get_value()) { call_f(std::source_location::current()); } - NT_wrapper(const NT_wrapper& other) : value(other.value) { call_f(); } - NT_wrapper(NT_wrapper&& other) : value(std::move(other.value)) { call_f(); } - ~NT_wrapper() { call_f(); } + NT_wrapper(const NT_wrapper& other) : value(other.value) { call_f(std::source_location::current()); } + NT_wrapper(NT_wrapper&& other) : value(std::move(other.value)) { call_f(std::source_location::current()); } + ~NT_wrapper() { call_f(std::source_location::current()); } NT_wrapper& operator=(const NT_wrapper& other) { if (this != &other) { value = other.value; - call_f(); + call_f(std::source_location::current()); } return *this; } @@ -58,7 +58,7 @@ public: NT_wrapper& operator=(NT_wrapper&& other) { if (this != &other) { value = std::move(other.value); - call_f(); + call_f(std::source_location::current()); } return *this; } From d48ca93f644678123a65af80906775bad6d0ff95 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 29 Mar 2024 11:34:43 +0100 Subject: [PATCH 17/32] fix the logic --- .../include/CGAL/Cartesian/function_objects.h | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index 7fead4991ed..8b30413705b 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -3080,20 +3080,6 @@ namespace CartesianKernelFunctors { operator()(Return_base_tag, Args&& ...args) const { return Rep(std::forward(args)...); } - Rep // Point_2 - operator()(Return_base_tag, const RT& x, const RT& y) const - { return Rep(x, y); } - - template - std::enable_if_t && - !std::is_same_v, Rep> - operator()(T1&& x, T2&& y) const - { return Rep(std::forward(x), std::forward(y)); } - - Rep // Point_2 - operator()(Return_base_tag, const RT& x, const RT& y, const RT& w) const - { return Rep(x, y, w); } - Point_2 operator()(const Line_2& l) const { @@ -3104,7 +3090,7 @@ namespace CartesianKernelFunctors { } Point_2 - operator()(const Line_2& l, const FT i) const + operator()(const Line_2& l, const FT& i) const { typename K::Construct_point_2 construct_point_2; typename K::FT x, y; @@ -3128,6 +3114,10 @@ namespace CartesianKernelFunctors { operator()(const RT& x, const RT& y) const { return Point_2(x, y); } + Point_2 + operator()(RT&& x, RT&& y) const + { return Point_2(std::move(x), std::move(y)); } + Point_2 operator()(const RT& x, const RT& y, const RT& w) const { return Point_2(x, y, w); } @@ -3179,10 +3169,9 @@ namespace CartesianKernelFunctors { operator()(const RT& x, const RT& y, const RT& z) const { return Point_3(x, y, z); } - template Point_3 - operator()(T1&& x, T2&& y, T3&& z) const - { return Point_3(std::forward(x), std::forward(y), std::forward(z)); } + operator()(RT&& x, RT&& y, RT&& z) const + { return Point_3(std::move(x), std::move(y), std::move(z)); } Point_3 operator()(const RT& x, const RT& y, const RT& z, const RT& w) const From 0c8f0693fbf2aa3ee26ad09d8f48e03099d7b311 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 5 Apr 2024 13:57:09 +0200 Subject: [PATCH 18/32] add a missing #include for LEDA --- LEDA/include/CGAL/LEDA_basic.h | 1 + 1 file changed, 1 insertion(+) diff --git a/LEDA/include/CGAL/LEDA_basic.h b/LEDA/include/CGAL/LEDA_basic.h index 5dc01566024..6c05c14c58d 100644 --- a/LEDA/include/CGAL/LEDA_basic.h +++ b/LEDA/include/CGAL/LEDA_basic.h @@ -25,6 +25,7 @@ // The following is needed for LEDA 4.4 due to min/max problems... # define LEDA_NO_MIN_MAX_TEMPL +#include // as a workaround for a missing include in #include #ifdef LEDA_NAMESPACE From e07135e347c6beb1a45ebe56e6e03ed555f5b904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Loriot?= Date: Wed, 10 Apr 2024 10:12:04 +0200 Subject: [PATCH 19/32] workaround functions removed from c++20 used in leda --- LEDA/include/CGAL/LEDA_basic.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/LEDA/include/CGAL/LEDA_basic.h b/LEDA/include/CGAL/LEDA_basic.h index 6c05c14c58d..95ff771054e 100644 --- a/LEDA/include/CGAL/LEDA_basic.h +++ b/LEDA/include/CGAL/LEDA_basic.h @@ -25,9 +25,14 @@ // The following is needed for LEDA 4.4 due to min/max problems... # define LEDA_NO_MIN_MAX_TEMPL -#include // as a workaround for a missing include in +#ifdef CGAL_CXX20 +# define STREAM_DUMMY // disable stream_dummy() function that is not used and using features removed from c++20 +// We cannot undef STREAM_DUMMY as LEAD/internal/PREAMBULE.h is not protected +#endif #include + + #ifdef LEDA_NAMESPACE # define CGAL_LEDA_SCOPE leda #else From 78f98041c64e2d1f6830ee2154c98b5d37e9ed1b Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 19 Apr 2024 16:45:49 +0200 Subject: [PATCH 20/32] add a comment --- Number_types/include/CGAL/NT_wrapper.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Number_types/include/CGAL/NT_wrapper.h b/Number_types/include/CGAL/NT_wrapper.h index f0f6f108001..97f66f1e55b 100644 --- a/Number_types/include/CGAL/NT_wrapper.h +++ b/Number_types/include/CGAL/NT_wrapper.h @@ -23,6 +23,16 @@ namespace CGAL { +/* + * This class template `NT_wapper` is currently undocumented, on purpose. + * + * This class template provides a wrapper for number types. It calls a function + * `f` when a constructor, destructor, or assignment operator is called. This + * is useful to detect when a copy constructor is called, for example. An + * example of use case is in the test file + * `Number_types/test/Number_types/wrapping_type.cpp`. + */ + template class NT_wrapper { NT value; From 66c1b9b9e0237f8814d25cd0945ae1e2e5673a75 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 19 Apr 2024 16:46:12 +0200 Subject: [PATCH 21/32] fix a compilation error detected locally by CTest --- Number_types/test/Number_types/known_bit_size_integers.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Number_types/test/Number_types/known_bit_size_integers.cpp b/Number_types/test/Number_types/known_bit_size_integers.cpp index 351ffa412af..4027fcfff14 100644 --- a/Number_types/test/Number_types/known_bit_size_integers.cpp +++ b/Number_types/test/Number_types/known_bit_size_integers.cpp @@ -1,10 +1,10 @@ #include -#include +#include #include int main() { - std::cout << "Verifying the sizes of boost::[u]int{8,16,32,64}_t" + std::cout << "Verifying the sizes of std::[u]int{8,16,32,64}_t" << std::endl; static_assert(sizeof(std::int8_t) == 1); From 4206382ac78e1bc3ebe88b9297986cbfd2fb4e69 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 19 Apr 2024 16:46:26 +0200 Subject: [PATCH 22/32] fix the doc --- STL_Extension/doc/STL_Extension/CGAL/array.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/STL_Extension/doc/STL_Extension/CGAL/array.h b/STL_Extension/doc/STL_Extension/CGAL/array.h index 5c3d083c2a5..9a1c2921641 100644 --- a/STL_Extension/doc/STL_Extension/CGAL/array.h +++ b/STL_Extension/doc/STL_Extension/CGAL/array.h @@ -6,8 +6,6 @@ namespace CGAL { \returns `std::array` where `N` is the number of arguments given to the function. The position of each argument in the array is the same as its position in the argument list. - -The maximal number of arguments is `6`. */ template std::array make_array(const T&...); @@ -18,8 +16,6 @@ arguments given to the function. The position of each argument in the array is the same as its position in the argument list. This is the functor version of `make_array()`. - -The maximal number of arguments is `6`. */ struct Construct_array { From 736ab7a5556a5e6ddf93adea91baf4516abe830a Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 19 Apr 2024 16:47:38 +0200 Subject: [PATCH 23/32] make_array now use perfect forwarding, and remove fwd_make_array --- STL_Extension/include/CGAL/array.h | 42 ++++++++++--------- .../STL_Extension/test_fwd_make_array.cpp | 5 ++- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/STL_Extension/include/CGAL/array.h b/STL_Extension/include/CGAL/array.h index 7b15f064db8..98892c6257d 100644 --- a/STL_Extension/include/CGAL/array.h +++ b/STL_Extension/include/CGAL/array.h @@ -45,34 +45,36 @@ namespace CGAL { // It's also untrue that this is not documented... It is ! -template< typename T, typename... Args > -BOOST_CXX14_CONSTEXPR -std::array< T, 1 + sizeof...(Args) > -make_array(const T & t, const Args & ... args) -{ - std::array< T, 1 + sizeof...(Args) > a = { { t, static_cast(args)... } }; - return a; -} +template +struct Make_array_element_type { + using type = T; +}; -template< typename T, typename... Args > -BOOST_CXX14_CONSTEXPR -std::array< T, sizeof...(Args) > -fwd_make_array(Args && ... args) -{ - std::array< T, sizeof...(Args) > a = { static_cast(std::forward(args))... }; - return a; -} +template +struct Make_array_element_type { + using type = typename std::common_type_t; +}; +template +using Make_array_element_type_t = typename Make_array_element_type::type; + +template +constexpr +std::array, sizeof...(Args) > +make_array(Args&& ... args) +{ + return {{ std::forward(args)... }}; +} // Functor version struct Construct_array { - template + template constexpr - std::array - operator()(const T& t, const Args& ... args) const + decltype(auto) + operator()(Args&& ... args) const { - return make_array (t, args...); + return make_array( std::forward(args)... ); } }; diff --git a/STL_Extension/test/STL_Extension/test_fwd_make_array.cpp b/STL_Extension/test/STL_Extension/test_fwd_make_array.cpp index 305b09d3f1c..6d55735a14f 100644 --- a/STL_Extension/test/STL_Extension/test_fwd_make_array.cpp +++ b/STL_Extension/test/STL_Extension/test_fwd_make_array.cpp @@ -15,8 +15,9 @@ struct A // move-only class, move-constructible from B int main() { // this test requires C++17 mandatory return-value optimization (RVO) - std::array a = CGAL::fwd_make_array(B()); - std::array b = CGAL::fwd_make_array(1u); + std::array a = CGAL::make_array(B()); + auto b = CGAL::make_array(1u); + static_assert(std::is_same_v>); CGAL_USE(a); CGAL_USE(b); return 0; From 2bb3f9a0d33c4076e25bc104ee50e1654f697a8f Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 19 Apr 2024 17:24:24 +0200 Subject: [PATCH 24/32] make_array is not useful here --- Cartesian_kernel/include/CGAL/Cartesian/Direction_2.h | 2 +- Cartesian_kernel/include/CGAL/Cartesian/Direction_3.h | 4 ++-- Cartesian_kernel/include/CGAL/Cartesian/Iso_cuboid_3.h | 6 +++--- Cartesian_kernel/include/CGAL/Cartesian/Iso_rectangle_2.h | 2 +- Cartesian_kernel/include/CGAL/Cartesian/Line_2.h | 2 +- Cartesian_kernel/include/CGAL/Cartesian/Plane_3.h | 2 +- Cartesian_kernel/include/CGAL/Cartesian/Ray_2.h | 2 +- Cartesian_kernel/include/CGAL/Cartesian/Ray_3.h | 8 ++++---- Cartesian_kernel/include/CGAL/Cartesian/Segment_2.h | 2 +- Cartesian_kernel/include/CGAL/Cartesian/Segment_3.h | 2 +- Cartesian_kernel/include/CGAL/Cartesian/Tetrahedron_3.h | 2 +- Cartesian_kernel/include/CGAL/Cartesian/Triangle_2.h | 2 +- Cartesian_kernel/include/CGAL/Cartesian/Triangle_3.h | 2 +- Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h | 4 ++-- Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h | 4 ++-- Homogeneous_kernel/include/CGAL/Homogeneous/DirectionH2.h | 2 +- .../include/CGAL/Homogeneous/Iso_cuboidH3.h | 6 +++--- .../include/CGAL/Homogeneous/Iso_rectangleH2.h | 2 +- Homogeneous_kernel/include/CGAL/Homogeneous/LineH2.h | 2 +- Homogeneous_kernel/include/CGAL/Homogeneous/VectorH3.h | 2 +- STL_Extension/include/CGAL/Handle_for.h | 2 +- 21 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Direction_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Direction_2.h index 4d27652873c..302299d0898 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Direction_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Direction_2.h @@ -47,7 +47,7 @@ public: DirectionC2() {} DirectionC2(const FT &x, const FT &y) - : base(CGAL::make_array(x, y)) {} + : base{x, y} {} bool operator==(const DirectionC2 &d) const; bool operator!=(const DirectionC2 &d) const; diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Direction_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Direction_3.h index 6cf5c0c8e78..a9c9867a934 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Direction_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Direction_3.h @@ -45,7 +45,7 @@ public: DirectionC3() {} explicit DirectionC3(const Vector_3 &v) - : base(CGAL::make_array(v.x(), v.y(), v.z())) {} + : base{v.x(), v.y(), v.z()} {} // { *this = v.direction(); } explicit DirectionC3(const Line_3 &l) @@ -58,7 +58,7 @@ public: { *this = s.rep().direction(); } DirectionC3(const FT &x, const FT &y, const FT &z) - : base(CGAL::make_array(x, y, z)) {} + : base{x, y, z} {} typename R::Boolean operator==(const DirectionC3 &d) const; typename R::Boolean operator!=(const DirectionC3 &d) const; diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Iso_cuboid_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Iso_cuboid_3.h index 2e22a69b77d..82f319261a0 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Iso_cuboid_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Iso_cuboid_3.h @@ -43,7 +43,7 @@ public: Iso_cuboidC3() {} Iso_cuboidC3(const Point_3 &p, const Point_3 &q, int) - : base(CGAL::make_array(p, q)) + : base{p, q} { // I have to remove the assertions, because of Cartesian_converter. // CGAL_kernel_assertion(p.x()<=q.x()); @@ -68,8 +68,8 @@ public: Iso_cuboidC3(const Point_3 &left, const Point_3 &right, const Point_3 &bottom, const Point_3 &top, const Point_3 &far_, const Point_3 &close) - : base(CGAL::make_array(Construct_point_3()(left.x(), bottom.y(), far_.z()), - Construct_point_3()(right.x(), top.y(), close.z()))) + : base{Construct_point_3()(left.x(), bottom.y(), far_.z()), + Construct_point_3()(right.x(), top.y(), close.z())} { CGAL_kernel_precondition(!less_x(right, left)); CGAL_kernel_precondition(!less_y(top, bottom)); diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Iso_rectangle_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Iso_rectangle_2.h index 6f3b8c40f2a..e238cf57767 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Iso_rectangle_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Iso_rectangle_2.h @@ -43,7 +43,7 @@ public: // : base(p, q) {} Iso_rectangleC2(const Point_2 &p, const Point_2 &q, int) - : base(CGAL::make_array(p, q)) + : base{p, q} { // I have to remove the assertions, because of Cartesian_converter. // CGAL_kernel_assertion(p<=q); diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Line_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Line_2.h index 77ec08c459d..21ff3298338 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Line_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Line_2.h @@ -46,7 +46,7 @@ public: LineC2() {} LineC2(const FT &a, const FT &b, const FT &c) - : base(CGAL::make_array(a, b, c)) {} + : base{a, b, c} {} typename R_::Boolean operator==(const LineC2 &l) const; typename R_::Boolean operator!=(const LineC2 &l) const; diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Plane_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Plane_3.h index d9d873b0847..38a119e1320 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Plane_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Plane_3.h @@ -64,7 +64,7 @@ public: { *this = plane_from_point_direction(o, v.direction()); } PlaneC3(const FT &a, const FT &b, const FT &c, const FT &d) - : base(CGAL::make_array(a, b, c, d)) {} + : base{a, b, c, d} {} PlaneC3(const Line_3 &l, const Point_3 &p) { *this = plane_from_points(l.point(), diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Ray_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Ray_2.h index 8448eba97e7..c703dc79dcd 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Ray_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Ray_2.h @@ -40,7 +40,7 @@ public: {} RayC2(const Point_2 &sp, const Point_2 &secondp) - : base(CGAL::make_array(sp, secondp)) + : base{sp, secondp} {} diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Ray_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Ray_3.h index 15892d8dfc0..7dd67e372ba 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Ray_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Ray_3.h @@ -43,16 +43,16 @@ public: RayC3() {} RayC3(const Point_3 &sp, const Point_3 &secondp) - : base(CGAL::make_array(sp, secondp)) {} + : base{sp, secondp} {} RayC3(const Point_3 &sp, const Vector_3 &v) - : base(CGAL::make_array(sp, sp + v)) {} + : base{sp, sp + v} {} RayC3(const Point_3 &sp, const Direction_3 &d) - : base(CGAL::make_array(sp, sp + d.to_vector())) {} + : base{sp, sp + d.to_vector()} {} RayC3(const Point_3 &sp, const Line_3 &l) - : base(CGAL::make_array(sp, sp + l.to_vector())) {} + : base{sp, sp + l.to_vector()} {} typename R::Boolean operator==(const RayC3 &r) const; typename R::Boolean operator!=(const RayC3 &r) const; diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Segment_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Segment_2.h index 3672c797e7c..25bff4769fd 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Segment_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Segment_2.h @@ -39,7 +39,7 @@ public: {} SegmentC2(const Point_2 &sp, const Point_2 &ep) - : base(CGAL::make_array(sp, ep)) + : base{sp, ep} {} const Point_2 & diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Segment_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Segment_3.h index 122626550f4..8ab1d082d6f 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Segment_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Segment_3.h @@ -42,7 +42,7 @@ public: SegmentC3() {} SegmentC3(const Point_3 &sp, const Point_3 &ep) - : base(CGAL::make_array(sp, ep)) {} + : base{sp, ep} {} bool has_on(const Point_3 &p) const; bool collinear_has_on(const Point_3 &p) const; diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Tetrahedron_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Tetrahedron_3.h index 3a197adecf8..c20733313af 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Tetrahedron_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Tetrahedron_3.h @@ -45,7 +45,7 @@ public: TetrahedronC3(const Point_3 &p, const Point_3 &q, const Point_3 &r, const Point_3 &s) - : base(CGAL::make_array(p, q, r, s)) {} + : base{p, q, r, s} {} const Point_3 & vertex(int i) const; const Point_3 & operator[](int i) const; diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Triangle_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Triangle_2.h index 5639f2363c4..48661cb5964 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Triangle_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Triangle_2.h @@ -41,7 +41,7 @@ public: TriangleC2() {} TriangleC2(const Point_2 &p, const Point_2 &q, const Point_2 &r) - : base(CGAL::make_array(p, q, r)) {} + : base{p, q, r} {} const Point_2 & diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Triangle_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Triangle_3.h index 1fa2525ae10..7e61db2dee2 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Triangle_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Triangle_3.h @@ -42,7 +42,7 @@ public: TriangleC3() {} TriangleC3(const Point_3 &p, const Point_3 &q, const Point_3 &r) - : base(CGAL::make_array(p, q, r)) {} + : base{p, q, r} {} bool operator==(const TriangleC3 &t) const; bool operator!=(const TriangleC3 &t) const; diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h b/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h index 939e80c0c2a..1ff9d12ee7b 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Vector_2.h @@ -50,10 +50,10 @@ public: VectorC2() {} VectorC2(const FT &x, const FT &y) - : base(CGAL::make_array(x, y)) {} + : base{x, y} {} VectorC2(FT&& x, FT&& y) - : base(CGAL::fwd_make_array(std::move(x), std::move(y))) {} + : base{std::move(x), std::move(y)} {} VectorC2(const FT &hx, const FT &hy, const FT &hw) : base( hw != FT(1) ? CGAL::make_array(hx/hw, hy/hw) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h index f6563db5b7a..89540fd9b0d 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/Vector_3.h @@ -65,10 +65,10 @@ public: { *this = R().construct_vector_3_object()(l); } VectorC3(const FT_ &x, const FT_ &y, const FT_ &z) - : base(CGAL::make_array(x, y, z)) {} + : base{x, y, z} {} VectorC3(FT_&& x, FT_&& y, FT_&& z) - : base(CGAL::make_array(std::move(x), std::move(y), std::move(z))) {} + : base{std::move(x), std::move(y), std::move(z)} {} VectorC3(const FT_ &x, const FT_ &y, const FT_ &z, const FT_ &w) : base( w != FT_(1) ? CGAL::make_array(x/w, y/w, z/w) diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/DirectionH2.h b/Homogeneous_kernel/include/CGAL/Homogeneous/DirectionH2.h index a86847f9e87..b30267cf7d2 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/DirectionH2.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/DirectionH2.h @@ -56,7 +56,7 @@ public: DirectionH2() {} DirectionH2(const RT& x, const RT& y) - : base(CGAL::make_array(x, y, RT(1))) {} + : base{x, y, RT(1)} {} // TODO Not documented : should not exist, not used. // we should also change array -> array diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Iso_cuboidH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Iso_cuboidH3.h index 0119260a3c1..e4830033289 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Iso_cuboidH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Iso_cuboidH3.h @@ -43,7 +43,7 @@ public: Iso_cuboidH3() {} Iso_cuboidH3(const Point_3& p, const Point_3& q, int) - : base(CGAL::make_array(p, q)) + : base{p, q} { CGAL_kernel_assertion(p.x()<=q.x()); CGAL_kernel_assertion(p.y()<=q.y()); @@ -173,8 +173,8 @@ CGAL_KERNEL_LARGE_INLINE Iso_cuboidH3:: Iso_cuboidH3(const RT& min_hx, const RT& min_hy, const RT& min_hz, const RT& max_hx, const RT& max_hy, const RT& max_hz) - : base(CGAL::make_array(Point_3(min_hx, min_hy, min_hz, RT(1)), - Point_3(max_hx, max_hy, max_hz, RT(1)))) + : base{Point_3(min_hx, min_hy, min_hz, RT(1)), + Point_3(max_hx, max_hy, max_hz, RT(1))} {} template < class R > diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/Iso_rectangleH2.h b/Homogeneous_kernel/include/CGAL/Homogeneous/Iso_rectangleH2.h index 5c3f1ba9d32..6bdde3dec91 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/Iso_rectangleH2.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/Iso_rectangleH2.h @@ -42,7 +42,7 @@ public: Iso_rectangleH2() {} Iso_rectangleH2(const Point_2& p, const Point_2& q, int) - : base(CGAL::make_array(p, q)) + : base{p, q} { // I have to remove the assertions, because of Homogeneous_converter. // CGAL_kernel_assertion(p.x()<=q.x()); diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/LineH2.h b/Homogeneous_kernel/include/CGAL/Homogeneous/LineH2.h index 5f37cfee985..ab69b965f35 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/LineH2.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/LineH2.h @@ -45,7 +45,7 @@ public: LineH2() {} LineH2(const RT& a, const RT& b, const RT& c) - : base(CGAL::make_array(a, b, c)) {} + : base{a, b, c} {} bool operator==(const LineH2& l) const; bool operator!=(const LineH2& l) const; diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/VectorH3.h b/Homogeneous_kernel/include/CGAL/Homogeneous/VectorH3.h index aecd718d41a..56a0e2b9ad8 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/VectorH3.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/VectorH3.h @@ -63,7 +63,7 @@ public: { *this = R().construct_vector_3_object()(l); } VectorH3(const Null_vector&) - : base(CGAL::make_array(RT(0), RT(0), RT(0), RT(1))) {} + : base{RT(0), RT(0), RT(0), RT(1)} {} template < typename Tx, typename Ty, typename Tz > VectorH3(const Tx & x, const Ty & y, const Tz & z, diff --git a/STL_Extension/include/CGAL/Handle_for.h b/STL_Extension/include/CGAL/Handle_for.h index 2f05c6be1ce..9384277f7ae 100644 --- a/STL_Extension/include/CGAL/Handle_for.h +++ b/STL_Extension/include/CGAL/Handle_for.h @@ -42,7 +42,7 @@ class Handle_for T t; std::atomic_uint count; template - RefCounted(U&&...u ) : t(std::forward(u)...), count(1) {} + RefCounted(U&&...u ) : t{std::forward(u)...}, count(1) {} }; From 67d55f8afe70fd400e7c603cee0c9139abc84802 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Mon, 22 Apr 2024 14:24:54 +0200 Subject: [PATCH 25/32] fix missing include of --- Number_types/include/CGAL/Mpzf.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Number_types/include/CGAL/Mpzf.h b/Number_types/include/CGAL/Mpzf.h index 020ea8ce94b..44bb8fd9246 100644 --- a/Number_types/include/CGAL/Mpzf.h +++ b/Number_types/include/CGAL/Mpzf.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #ifdef CGAL_USE_GMPXX From 1d5851e0139391c413b21db5e02584dc2ca13738 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 23 Apr 2024 11:41:55 +0200 Subject: [PATCH 26/32] Update LEDA/include/CGAL/LEDA_basic.h Co-authored-by: Andreas Fabri --- LEDA/include/CGAL/LEDA_basic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LEDA/include/CGAL/LEDA_basic.h b/LEDA/include/CGAL/LEDA_basic.h index 95ff771054e..eb6baa5ad56 100644 --- a/LEDA/include/CGAL/LEDA_basic.h +++ b/LEDA/include/CGAL/LEDA_basic.h @@ -27,7 +27,7 @@ #ifdef CGAL_CXX20 # define STREAM_DUMMY // disable stream_dummy() function that is not used and using features removed from c++20 -// We cannot undef STREAM_DUMMY as LEAD/internal/PREAMBULE.h is not protected +// We cannot undef STREAM_DUMMY as LEDA/internal/PREAMBULE.h is not protected #endif #include From ca1f11d7150aab3d64171b8293b315d834195020 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 23 Apr 2024 13:33:07 +0200 Subject: [PATCH 27/32] Add CGAL::is_convertible_without_narrowing ... and `CGAL::cpp20::type_identity`. --- STL_Extension/include/CGAL/type_traits.h | 26 +++++++++++++++++++ .../test/STL_Extension/test_type_traits.cpp | 26 ++++++++++++------- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/STL_Extension/include/CGAL/type_traits.h b/STL_Extension/include/CGAL/type_traits.h index c68386c7f76..f64e7c0c57f 100644 --- a/STL_Extension/include/CGAL/type_traits.h +++ b/STL_Extension/include/CGAL/type_traits.h @@ -29,6 +29,12 @@ struct is_same_or_derived : namespace cpp20 { + template + struct type_identity { using type = T; }; + + template + using type_identity_t = typename type_identity::type; + template< class T > struct remove_cvref { typedef std::remove_cv_t> type; @@ -39,6 +45,26 @@ namespace cpp20 { } // end namespace cpp20 +namespace details { + template + struct is_convertible_without_narrowing : std::false_type + {}; + + template + struct is_convertible_without_narrowing{std::declval()})>> + : std::is_convertible + {}; +} + +template +struct is_convertible_without_narrowing : details::is_convertible_without_narrowing +{}; + +template +inline constexpr bool is_convertible_without_narrowing_v = is_convertible_without_narrowing::value; + } // end namespace CGAL #endif // CGAL_TYPE_TRAITS_H diff --git a/STL_Extension/test/STL_Extension/test_type_traits.cpp b/STL_Extension/test/STL_Extension/test_type_traits.cpp index 77586b50c89..caa0e3afa36 100644 --- a/STL_Extension/test/STL_Extension/test_type_traits.cpp +++ b/STL_Extension/test/STL_Extension/test_type_traits.cpp @@ -18,14 +18,22 @@ struct B : public A {}; typedef A C; int main() { - assert( ( ::CGAL::is_same_or_derived< A,A >::value == 1 ) ); - assert( ( ::CGAL::is_same_or_derived< A,B >::value == 1 ) ); - assert( ( ::CGAL::is_same_or_derived< B,A >::value == 0 ) ); - assert( ( ::CGAL::is_same_or_derived< B,B >::value == 1 ) ); - assert( ( ::CGAL::is_same_or_derived< A,C >::value == 1 ) ); - assert( ( ::CGAL::is_same_or_derived< B,C >::value == 0 ) ); - assert( ( ::CGAL::is_same_or_derived< C,C >::value == 1 ) ); - assert( ( ::CGAL::is_same_or_derived< C,A >::value == 1 ) ); - assert( ( ::CGAL::is_same_or_derived< C,B >::value == 1 ) ); + static_assert( ( ::CGAL::is_same_or_derived< A,A >::value == 1 ) ); + static_assert( ( ::CGAL::is_same_or_derived< A,B >::value == 1 ) ); + static_assert( ( ::CGAL::is_same_or_derived< B,A >::value == 0 ) ); + static_assert( ( ::CGAL::is_same_or_derived< B,B >::value == 1 ) ); + static_assert( ( ::CGAL::is_same_or_derived< A,C >::value == 1 ) ); + static_assert( ( ::CGAL::is_same_or_derived< B,C >::value == 0 ) ); + static_assert( ( ::CGAL::is_same_or_derived< C,C >::value == 1 ) ); + static_assert( ( ::CGAL::is_same_or_derived< C,A >::value == 1 ) ); + static_assert( ( ::CGAL::is_same_or_derived< C,B >::value == 1 ) ); + + static_assert( CGAL::is_convertible_without_narrowing_v ); + static_assert( ! CGAL::is_convertible_without_narrowing_v ); + static_assert( CGAL::is_convertible_without_narrowing_v ); + static_assert( ! CGAL::is_convertible_without_narrowing_v ); + static_assert( CGAL::is_convertible_without_narrowing_v ); + static_assert( ! CGAL::is_convertible_without_narrowing_v ); + static_assert( ! CGAL::is_convertible_without_narrowing_v ); return 0; } From 940a7ebe9fcaf00af7d63ccfd08193cae6eca530 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 23 Apr 2024 14:29:33 +0200 Subject: [PATCH 28/32] fix make_array with is_convertible_without_narrowing --- STL_Extension/include/CGAL/array.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/STL_Extension/include/CGAL/array.h b/STL_Extension/include/CGAL/array.h index 98892c6257d..45da267b0ea 100644 --- a/STL_Extension/include/CGAL/array.h +++ b/STL_Extension/include/CGAL/array.h @@ -13,6 +13,7 @@ #define CGAL_ARRAY_H #include +#include #include #include @@ -63,7 +64,13 @@ constexpr std::array, sizeof...(Args) > make_array(Args&& ... args) { - return {{ std::forward(args)... }}; + using Target_type = Make_array_element_type_t; + if constexpr ( (CGAL::is_convertible_without_narrowing_v, Target_type>&&...) ) + return {{ std::forward(args)... }}; + else { + std::array< Target_type, sizeof...(Args) > a = { { static_cast(args)... } }; + return a; + } } // Functor version From a3be6a04ae71fa410fb7744ba9280ba6eab3d9ac Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 24 Apr 2024 16:42:52 +0200 Subject: [PATCH 29/32] add a missing include --- Number_types/include/CGAL/known_bit_size_integers.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Number_types/include/CGAL/known_bit_size_integers.h b/Number_types/include/CGAL/known_bit_size_integers.h index c5bc43fed54..195d0fae2c2 100644 --- a/Number_types/include/CGAL/known_bit_size_integers.h +++ b/Number_types/include/CGAL/known_bit_size_integers.h @@ -24,11 +24,12 @@ #define CGAL_KNOWN_BIT_SIZE_INTEGERS_H #define CGAL_DEPRECATED_HEADER "" -#define CGAL_REPLACEMENT_HEADER "" +#define CGAL_REPLACEMENT_HEADER "" #include #include #include +#include #ifndef CGAL_NO_DEPRECATED_CODE From 15349f0bdafe60b85697f9d142c2652200d968e8 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Fri, 26 Apr 2024 10:39:41 +0200 Subject: [PATCH 30/32] simplify the code for MSVC 2017 (compiler bug_ --- STL_Extension/include/CGAL/array.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/STL_Extension/include/CGAL/array.h b/STL_Extension/include/CGAL/array.h index 45da267b0ea..60cf9253b81 100644 --- a/STL_Extension/include/CGAL/array.h +++ b/STL_Extension/include/CGAL/array.h @@ -65,9 +65,15 @@ std::array, sizeof...(Args) > make_array(Args&& ... args) { using Target_type = Make_array_element_type_t; + +// MSVC 2017 chokes on the following code, so we simplify it for this compiler +// See https://godbolt.org/z/7Y34Y1c53 +#if ! defined(_MSC_VER) || (_MSC_VER > 1916) if constexpr ( (CGAL::is_convertible_without_narrowing_v, Target_type>&&...) ) return {{ std::forward(args)... }}; - else { + else +#endif // not MSVC or MSVC 2019 or later + { std::array< Target_type, sizeof...(Args) > a = { { static_cast(args)... } }; return a; } From 0095302f2d8af7b0c43bdba8efd2ac87aefc5cd5 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 30 Apr 2024 10:18:45 +0200 Subject: [PATCH 31/32] fix the test for buggy MSVC 2017 --- .../test/STL_Extension/test_fwd_make_array.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/STL_Extension/test/STL_Extension/test_fwd_make_array.cpp b/STL_Extension/test/STL_Extension/test_fwd_make_array.cpp index 6d55735a14f..dc1663b53a3 100644 --- a/STL_Extension/test/STL_Extension/test_fwd_make_array.cpp +++ b/STL_Extension/test/STL_Extension/test_fwd_make_array.cpp @@ -14,8 +14,17 @@ struct A // move-only class, move-constructible from B int main() { - // this test requires C++17 mandatory return-value optimization (RVO) +#if ! defined(_MSC_VER) || (_MSC_VER > 1916) + // This test requires C++17 mandatory return-value optimization (RVO). + // + // MSVC-2017 does not implement C++17 correctly + // See https://godbolt.org/z/7Y34Y1c53 + // and commit 15349f0bdafe60b85697f9d142c2652200d968e8 + // where we introduced a workaround for MSVC-2017: disable the correct + // forwarding of arguments in the `make_array` function. + // For that reason we disable this test for MSVC-2017) std::array a = CGAL::make_array(B()); +#endif auto b = CGAL::make_array(1u); static_assert(std::is_same_v>); CGAL_USE(a); From 10e9de8e04abec45f027ee357d050768af8e6d7a Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Tue, 30 Apr 2024 09:29:30 +0100 Subject: [PATCH 32/32] Move CGAL_USE(1) --- STL_Extension/test/STL_Extension/test_fwd_make_array.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/STL_Extension/test/STL_Extension/test_fwd_make_array.cpp b/STL_Extension/test/STL_Extension/test_fwd_make_array.cpp index dc1663b53a3..f228358287c 100644 --- a/STL_Extension/test/STL_Extension/test_fwd_make_array.cpp +++ b/STL_Extension/test/STL_Extension/test_fwd_make_array.cpp @@ -24,10 +24,10 @@ int main() // forwarding of arguments in the `make_array` function. // For that reason we disable this test for MSVC-2017) std::array a = CGAL::make_array(B()); + CGAL_USE(a); #endif auto b = CGAL::make_array(1u); static_assert(std::is_same_v>); - CGAL_USE(a); CGAL_USE(b); return 0; }