From 7f1e16d8da70115c446eacb063385d17dc202eac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mael=20Rouxel-Labb=C3=A9?= Date: Tue, 17 Dec 2024 22:07:35 +0100 Subject: [PATCH] Factorize operator()s of Lazy_construction_variant --- Filtered_kernel/include/CGAL/Lazy.h | 69 ++++------------------------- 1 file changed, 8 insertions(+), 61 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index f1ba7fc9277..ab56f1f1c50 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -1484,26 +1484,27 @@ struct Lazy_construction_variant { typedef typename Type_mapper()(std::declval::type>()...)),AK,LK>::type type; }; - template + template decltype(auto) - operator()(const L1& l1, const L2& l2) const { + operator()(const L&... l) const + { + typedef typename result::type result_type; - typedef typename result::type result_type; // typedef decltype(std::declval()(std::declval::type>(), // std::declval::type>())) AT; // typedef decltype(std::declval()(std::declval::type>(), // std::declval::type>())) ET; - typedef decltype(std::declval()(CGAL::approx(l1), CGAL::approx(l2))) AT; - typedef decltype(std::declval()( CGAL::exact(l1), CGAL::exact(l2))) ET; + typedef decltype(std::declval()(CGAL::approx(l)...)) AT; + typedef decltype(std::declval()( CGAL::exact(l)...)) ET; CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); { Protect_FPU_rounding P; try { - Lazy lazy(new Lazy_rep_n(AC(), EC(), l1, l2)); + Lazy lazy(new Lazy_rep_n(AC(), EC(), l...)); // the approximate result requires the trait with types from the AK AT approx_v = lazy.approx(); @@ -1525,7 +1526,7 @@ struct Lazy_construction_variant { CGAL_BRANCH_PROFILER_BRANCH(tmp); Protect_FPU_rounding P2(CGAL_FE_TONEAREST); CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST); - ET exact_v = EC()(CGAL::exact(l1), CGAL::exact(l2)); + ET exact_v = EC()(CGAL::exact(l)...); result_type res; if(!exact_v) { @@ -1536,60 +1537,6 @@ struct Lazy_construction_variant { boost::apply_visitor(visitor, *exact_v); return res; } - - template - decltype(auto) - operator()(const L1& l1, const L2& l2, const L3& l3) const { - typedef typename result::type result_type; - - // typedef decltype(std::declval()(std::declval::type>(), - // std::declval::type>(), - // std::declval::type>())) AT; - // typedef decltype(std::declval()(std::declval::type>(), - // std::declval::type>(), - // std::declval::type>())) ET; - - typedef decltype(std::declval()(CGAL::approx(l1), CGAL::approx(l2), CGAL::approx(l3))) AT; - typedef decltype(std::declval()( CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3))) ET; - - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - { - Protect_FPU_rounding P; - - try { - Lazy lazy(new Lazy_rep_n(AC(), EC(), l1, l2, l3)); - - // the approximate result requires the trait with types from the AK - AT approx_v = lazy.approx(); - // the result we build - result_type res; - - if(!approx_v) { - // empty - return res; - } - - // the static visitor fills the result_type with the correct unwrapped type - internal::Fill_lazy_variant_visitor_2< result_type, AK, LK, EK, Lazy > visitor(res, lazy); - boost::apply_visitor(visitor, *approx_v); - - return res; - } catch (Uncertain_conversion_exception&) {} - } - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding P2(CGAL_FE_TONEAREST); - CGAL_expensive_assertion(FPU_get_cw() == CGAL_FE_TONEAREST); - ET exact_v = EC()(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3)); - result_type res; - - if(!exact_v) { - return res; - } - - internal::Fill_lazy_variant_visitor_0< result_type, AK, LK, EK> visitor(res); - boost::apply_visitor(visitor, *exact_v); - return res; - } }; template