From a850c344609a4c487d3972ba12e0a8a54849995a Mon Sep 17 00:00:00 2001 From: Efi Fogel Date: Thu, 9 Nov 2023 15:06:23 +0200 Subject: [PATCH] Fixed Are_mergable_2 functor; add code that tests whether the equal operator (operator==) is applicable to the data that extends the curve --- .../include/CGAL/Arr_curve_data_traits_2.h | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/Arrangement_on_surface_2/include/CGAL/Arr_curve_data_traits_2.h b/Arrangement_on_surface_2/include/CGAL/Arr_curve_data_traits_2.h index d0a68b2885ba..810da81aa6f6 100644 --- a/Arrangement_on_surface_2/include/CGAL/Arr_curve_data_traits_2.h +++ b/Arrangement_on_surface_2/include/CGAL/Arr_curve_data_traits_2.h @@ -247,27 +247,32 @@ class Arr_curve_data_traits_2 : public Traits_ { private: const Base_traits_2& m_base; - /*! Generate a helper class template to find out whether the base geometry - * traits has a nested type named Are_mergeable_2. - */ - BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_are_mergeable_2, - Are_mergeable_2, false) + template + bool are_mergeable_data(const T& cv1, const T& cv2, long) const { + CGAL_error_msg("Equality operator is not supported."); + return false; + } + + template + auto are_mergeable_data(const T& cv1, const T& cv2, int) const -> + decltype(cv1.data() == cv2.data()) + { return cv1.data() == cv2.data(); } /*! Implementation of the predicate in case the base geometry traits class * has a nested type named Are_mergeable_2. */ template - std::enable_if_t::value,bool> - are_mergeable(const X_monotone_curve_2& cv1, - const X_monotone_curve_2& cv2) const - { + auto are_mergeable(const X_monotone_curve_2& cv1, + const X_monotone_curve_2& cv2, + const GeomeTraits_2& traits, int) const -> + decltype(traits.are_mergeable_2_object(), bool()) { // In case the two base curves are not mergeable, the extended curves // are not mergeable as well. - if (! (m_base.are_mergeable_2_object()(cv1, cv2))) return false; + if (! (traits.are_mergeable_2_object()(cv1, cv2))) return false; // In case the two base curves are mergeable, check that they have the // same data fields. - return (cv1.data() == cv2.data()); + return are_mergeable_data(cv1, cv2, 0); } /*! Implementation of the predicate in case the base geometry traits class @@ -275,10 +280,9 @@ class Arr_curve_data_traits_2 : public Traits_ { * This function should never be called! */ template - std::enable_if_t::value,bool> - are_mergeable(const X_monotone_curve_2& /* cv1 */, - const X_monotone_curve_2& /* cv2 */) const - { + bool are_mergeable(const X_monotone_curve_2& /* cv1 */, + const X_monotone_curve_2& /* cv2 */, + const GeomeTraits_2& /* traits */, long) const { CGAL_error_msg("Are mergeable is not supported."); return false; } @@ -294,7 +298,7 @@ class Arr_curve_data_traits_2 : public Traits_ { */ bool operator()(const X_monotone_curve_2& cv1, const X_monotone_curve_2& cv2) const - { return are_mergeable(cv1, cv2); } + { return are_mergeable(cv1, cv2, m_base, 0); } }; /*! Obtain an Are_mergeable_2 functor object. */