From 07566226a3e6b1e7f17b12914b8924540ea6aca1 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 27 Jan 2019 12:17:45 +0100 Subject: [PATCH 01/56] Drop unused template parameter from Lazy. --- Filtered_kernel/include/CGAL/Lazy.h | 62 ++++++++++------------ Filtered_kernel/include/CGAL/Lazy_kernel.h | 2 +- Number_types/include/CGAL/Lazy_exact_nt.h | 4 +- 3 files changed, 31 insertions(+), 37 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index c54296e8767..09588df9988 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -61,42 +61,42 @@ template class Lazy_kernel_base; -template class Lazy; +template class Lazy; template class Lazy_exact_nt; -template +template inline const AT& -approx(const Lazy& l) +approx(const Lazy& l) { return l.approx(); } // Where is this one (non-const) needed ? Is it ? -template +template inline AT& -approx(Lazy& l) +approx(Lazy& l) { return l.approx(); } -template +template inline const ET& -exact(const Lazy& l) +exact(const Lazy& l) { return l.exact(); } -template +template inline unsigned -depth(const Lazy& l) +depth(const Lazy& l) { return l.depth(); } @@ -158,10 +158,10 @@ print_at(std::ostream& os, const std::pair & at) } -template +template inline void -print_dag(const Lazy& l, std::ostream& os, int level = 0) +print_dag(const Lazy& l, std::ostream& os, int level = 0) { l.print_dag(os, level); } @@ -723,7 +723,7 @@ public: //____________________________________________________________ // The handle class -template +template class Lazy : public Handle { template Self; + typedef Lazy Self; typedef Lazy_rep Self_rep; typedef AT_ AT; // undocumented @@ -1098,7 +1098,7 @@ public: // In a first version we assume that the references are of type Lazy, // and that the result type is void -template +template struct Lazy_functor_2_1 { static const bool Protection = true; @@ -1166,7 +1166,6 @@ struct Lazy_functor_2_2 typedef void result_type; typedef typename LK::Approximate_kernel AK; typedef typename LK::Exact_kernel EK; - typedef typename EK::FT EFT; typedef typename LK::E2A E2A; AC ac; @@ -1178,12 +1177,12 @@ public: void operator()(const L1& l1, const L2& l2, R1& r1, R2& r2) const { - typedef Lazy Handle_1; - typedef Lazy Handle_2; + typedef Lazy Handle_1; + typedef Lazy Handle_2; CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); Protect_FPU_rounding P; try { - typedef Lazy, std::pair, EFT, E2A> Lazy_pair; + typedef Lazy, std::pair, E2A> Lazy_pair; Lazy_pair lv(new Lazy_rep_2_2(ac, ec, l1, l2)); // lv->approx() is a std::pair; r1 = R1(Handle_1(new Lazy_rep_1 >, First >, E2A, Lazy_pair>(First >(), First >(), lv))); @@ -1208,11 +1207,10 @@ struct Lazy_intersect_with_iterators static const bool Protection = true; typedef typename LK::Approximate_kernel AK; typedef typename LK::Exact_kernel EK; - typedef typename EK::FT EFT; typedef typename LK::E2A E2A; typedef void result_type; - typedef Lazy Lazy_object; - typedef Lazy, std::vector, EFT, E2A> Lazy_vector; + typedef Lazy Lazy_object; + typedef Lazy, std::vector, E2A> Lazy_vector; AC ac; EC ec; @@ -1287,13 +1285,12 @@ struct Lazy_construction_object typedef typename LK::Approximate_kernel AK; typedef typename LK::Exact_kernel EK; - typedef typename EK::FT EFT; typedef typename LK::E2A E2A; typedef typename AC::result_type AT; typedef typename EC::result_type ET; typedef Object result_type; - typedef Lazy Lazy_object; + typedef Lazy Lazy_object; AC ac; EC ec; @@ -1535,7 +1532,6 @@ struct Lazy_construction_variant { typedef typename LK::Approximate_kernel AK; typedef typename LK::Exact_kernel EK; - typedef typename EK::FT EFT; typedef typename LK::E2A E2A; @@ -1569,7 +1565,7 @@ struct Lazy_construction_variant { Protect_FPU_rounding P; try { - Lazy lazy(new Lazy_rep_2(AC(), EC(), l1, l2)); + Lazy lazy(new Lazy_rep_2(AC(), EC(), l1, l2)); // the approximate result requires the trait with types from the AK AT approx_v = lazy.approx(); @@ -1582,7 +1578,7 @@ struct Lazy_construction_variant { } // 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); + internal::Fill_lazy_variant_visitor_2< result_type, AK, LK, EK, Lazy > visitor(res, lazy); boost::apply_visitor(visitor, *approx_v); return res; @@ -1618,7 +1614,7 @@ struct Lazy_construction_variant { CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); Protect_FPU_rounding P; try { - Lazy lazy(new Lazy_rep_3(AC(), EC(), l1, l2, l3)); + Lazy lazy(new Lazy_rep_3(AC(), EC(), l1, l2, l3)); // the approximate result requires the trait with types from the AK AT approx_v = lazy.approx(); @@ -1631,7 +1627,7 @@ struct Lazy_construction_variant { } // 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); + internal::Fill_lazy_variant_visitor_2< result_type, AK, LK, EK, Lazy > visitor(res, lazy); boost::apply_visitor(visitor, *approx_v); return res; @@ -1670,7 +1666,6 @@ struct Lazy_construction { typedef typename boost::remove_cv< typename boost::remove_reference < typename EC::result_type >::type >::type ET; - typedef typename EK::FT EFT; typedef typename Default::Get::type E2A; typedef typename Type_mapper::type result_type; @@ -1682,7 +1677,7 @@ struct Lazy_construction { template \ result_type \ operator()( BOOST_PP_ENUM(n, CGAL_LARGS, _) ) const { \ - typedef Lazy< AT, ET, EFT, E2A> Handle; \ + typedef Lazy< AT, ET, E2A> Handle; \ CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \ Protect_FPU_rounding P; \ try { \ @@ -1701,7 +1696,7 @@ struct Lazy_construction { result_type operator()() const { - typedef Lazy Handle; + typedef Lazy Handle; return result_type( Handle(new Lazy_rep_0()) ); } @@ -1717,7 +1712,6 @@ struct Lazy_construction typedef typename LK::Approximate_kernel AK; typedef typename LK::Exact_kernel EK; - typedef typename EK::FT EFT; typedef typename Default::Get::type E2A; template @@ -1749,7 +1743,7 @@ struct result { \ typename cpp11::result_of< EC(BOOST_PP_ENUM_PARAMS(n, E)) >::type >::type >::type ET; \ typedef typename boost::remove_cv< typename boost::remove_reference < \ typename cpp11::result_of< AC(BOOST_PP_ENUM_PARAMS(n, A)) >::type >::type >::type AT; \ - typedef Lazy< AT, ET, EFT, E2A> Handle; \ + typedef Lazy< AT, ET, E2A> Handle; \ typedef typename cpp11::result_of::type result_type; \ CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \ Protect_FPU_rounding P; \ @@ -1771,7 +1765,7 @@ struct result { \ { typedef typename cpp11::result_of::type AT; typedef typename cpp11::result_of::type ET; - typedef Lazy Handle; + typedef Lazy Handle; typedef typename Type_mapper< typename cpp11::result_of::type ,AK, LK>::type result_type; return result_type( Handle(new Lazy_rep_0()) ); diff --git a/Filtered_kernel/include/CGAL/Lazy_kernel.h b/Filtered_kernel/include/CGAL/Lazy_kernel.h index 2639a9f7027..90e18354df0 100644 --- a/Filtered_kernel/include/CGAL/Lazy_kernel.h +++ b/Filtered_kernel/include/CGAL/Lazy_kernel.h @@ -164,7 +164,7 @@ public: typedef CGAL::Object Object_3; #define CGAL_Kernel_obj(X) \ - typedef Lazy X; + typedef Lazy X; CGAL_Kernel_obj(Data_accessor_2) CGAL_Kernel_obj(Conic_2) diff --git a/Number_types/include/CGAL/Lazy_exact_nt.h b/Number_types/include/CGAL/Lazy_exact_nt.h index d1ffc105ccf..a71fb9328ab 100644 --- a/Number_types/include/CGAL/Lazy_exact_nt.h +++ b/Number_types/include/CGAL/Lazy_exact_nt.h @@ -344,14 +344,14 @@ struct Lazy_exact_Max : public Lazy_exact_binary // The real number type, handle class template class Lazy_exact_nt - : public Lazy, ET_, Lazy_exact_nt, To_interval > + : public Lazy, ET_, To_interval > , boost::ordered_euclidian_ring_operators2< Lazy_exact_nt, int > , boost::ordered_euclidian_ring_operators2< Lazy_exact_nt, double > { public: typedef Lazy_exact_nt Self; - typedef Lazy, ET_, Self, To_interval > Base; + typedef Lazy, ET_, To_interval > Base; typedef typename Base::Self_rep Self_rep; typedef typename Base::ET ET; // undocumented From cbddd4575a1abc44015623c25f7abdaa0aa53392 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 27 Jan 2019 15:16:38 +0100 Subject: [PATCH 02/56] One more occurence of Lazy this code is not used (unfinished), but it still gets included in the test, probably so it doesn't bitrot too fast. --- NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h | 1 - 1 file changed, 1 deletion(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h index bce1522a0fe..4ae80544fcf 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h @@ -79,7 +79,6 @@ struct Lazy_cartesian_types typedef Lazy< typename Get_type::type, typename Get_type::type, - typename Get_type::type, E2A_> type; }; template struct Type { From 34cbb9cd4b920dc4ba0486ae97f0b71f49a2d3ab Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 3 Feb 2019 23:16:28 +0100 Subject: [PATCH 03/56] Make Epeck_d work & C++14-only cleanups Still some rough edges: 1) double tab[]={.1,.2,.3}; Point_d p(tab+0,tab+3); lazily stores iterators to tab, so tab had better still be alive when we need update_exact. 2) One functor (point on a sphere) cannot be done exactly exactly with a representation center+squared radius. 3) Several hacks that make this not as generic as it should be. --- Filtered_kernel/include/CGAL/Lazy.h | 264 +++++++----------- Filtered_kernel/include/CGAL/Lazy_kernel.h | 12 +- Installation/include/CGAL/config.h | 6 + NewKernel_d/include/CGAL/Epeck_d.h | 17 +- .../CGAL/NewKernel_d/Cartesian_LA_base.h | 1 + .../include/CGAL/NewKernel_d/Coaffine.h | 6 + .../CGAL/NewKernel_d/Kernel_d_interface.h | 19 +- .../NewKernel_d/Kernel_object_converter.h | 12 + .../include/CGAL/NewKernel_d/Lazy_cartesian.h | 129 ++++++++- .../CGAL/NewKernel_d/Types/Hyperplane.h | 1 + .../include/CGAL/NewKernel_d/Types/Sphere.h | 1 + .../CGAL/NewKernel_d/Types/Weighted_point.h | 1 + .../include/CGAL/NewKernel_d/Vector/array.h | 2 + .../include/CGAL/NewKernel_d/Vector/mix.h | 1 + .../CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h | 3 +- .../CGAL/NewKernel_d/Wrapper/Point_d.h | 7 + .../NewKernel_d/function_objects_cartesian.h | 2 +- .../include/CGAL/iterator_from_indices.h | 3 +- NewKernel_d/test/NewKernel_d/Epick_d.cpp | 17 +- 19 files changed, 296 insertions(+), 208 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index 09588df9988..58a6c67f42e 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -37,6 +37,8 @@ #include #include #include +#include +#include #include #include @@ -107,27 +109,27 @@ depth(const Lazy& l) inline const T & exact (const T& d) { return d; } \ inline unsigned depth (const T& ) { return 0; } - -CGAL_LAZY_FORWARD(long double) -CGAL_LAZY_FORWARD(double) -CGAL_LAZY_FORWARD(float) -CGAL_LAZY_FORWARD(int) -CGAL_LAZY_FORWARD(unsigned int) -CGAL_LAZY_FORWARD(long) -CGAL_LAZY_FORWARD(unsigned long) -#ifdef CGAL_USE_LONG_LONG -CGAL_LAZY_FORWARD(long long) -CGAL_LAZY_FORWARD(unsigned long long) -#endif -CGAL_LAZY_FORWARD(Return_base_tag) -CGAL_LAZY_FORWARD(Null_vector) -CGAL_LAZY_FORWARD(Origin) -CGAL_LAZY_FORWARD(Orientation) CGAL_LAZY_FORWARD(Bbox_2) CGAL_LAZY_FORWARD(Bbox_3) - #undef CGAL_LAZY_FORWARD +templateinline std::enable_if_t::value||std::is_enum::value, T> approx(T d){return d;} +templateinline std::enable_if_t::value||std::is_enum::value, T> exact (T d){return d;} +templateinline std::enable_if_t::value||std::is_enum::value, unsigned> depth(T){return 0;} + +// For tag classes: Return_base_tag, Homogeneous_tag, Null_vector, Origin +templateinline std::enable_if_t::value, T> exact(T){return {};} +templateinline std::enable_if_t::value, T> approx(T){return {};} +templateinline std::enable_if_t::value, unsigned> depth(T){return 0;} + +// For an iterator, exact/approx applies to the objects it points to +template ::value>> +auto exact(T const& t) {return make_transforming_iterator(t,[](auto const&u){return CGAL::exact(u);});} +template ::value>> +auto approx(T const& t) {return make_transforming_iterator(t,[](auto const&u){return CGAL::approx(u);});} +template ::value>> +unsigned depth(T const& t) {return 1;} // FIXME: depth(*t) would be better when t is valid, but not for end iterators, and the true answer would iterate on the range, but we can't do that with only one iterator... We need to replace iterators with ranges to solve that. + #ifdef CGAL_LAZY_KERNEL_DEBUG template void @@ -311,6 +313,51 @@ public: }; +template +class Lazy_rep_n : + public Lazy_rep< AT, ET, E2A >, private EC +{ + // Lazy_rep_0 does not inherit from EC or take a parameter AC. It has different constructors. + static_assert(sizeof...(L)>0, "Use Lazy_rep_0 instead"); + template friend class Lazy_kernel_base; + mutable std::tuple l; // L...l; is not yet allowed. + const EC& ec() const { return *this; } + template + void update_exact_helper(std::index_sequence) const { + this->et = new ET(ec()( CGAL::exact( std::get(l) ) ... ) ); + this->at = E2A()(*(this->et)); + l = std::tuple{}; + } + public: + void update_exact() const { + update_exact_helper(std::make_index_sequence{}); + } + Lazy_rep_n(const AC& ac, const EC& ec, L const&...ll) : + Lazy_rep(ac(CGAL::approx(ll)...)), EC(ec), l(ll...) + { + this->set_depth(std::max({ -1, (int)CGAL::depth(ll)...}) + 1); + } +#ifdef CGAL_LAZY_KERNEL_DEBUG + private: + template + void print_dag_helper(std::ostream& os, int level, std::index_sequence) const { + this->print_at_et(os, level); + if(this->is_lazy()){ +# ifdef CGAL_LAZY_KERNEL_DEBUG_SHOW_TYPEID + CGAL::msg(os, level, typeid(AC).name()); +# endif + CGAL::msg(os, level, "DAG with " "3" " child nodes:"); + using expander = int[]; + expander{0,(CGAL::print_dag(std::get(l), os, level+1),0)...}; + } + } + public: + void print_dag(std::ostream& os, int level) const { + print_dag_helper(os, level, std::make_index_sequence{}); + } +#endif +}; + //____________________________________________________________ // The rep for the leaf node @@ -352,116 +399,6 @@ public: #define CGAL_LEXACT(z,n,t) CGAL::exact( l##n ) #define CGAL_LARGS(z, n, t) L##n const& l##n -#define CGAL_TMAP(z, n, d) typename Type_mapper< L##n, d##K, LK >::type -#define CGAL_PRUNE_TREE(z, n, d) l##n = L##n (); -#define CGAL_LINIT(z, n, d) l##n(l##n) -#define CGAL_LN(z, n, d) d(l##n) -#define CGAL_MLIST(z, n, d) mutable L##n l##n; - -//____________________________________________________________ - -template -class Lazy_rep_1 - : public Lazy_rep - , private EC -{ - typedef Lazy_rep Base; - - mutable L1 l1_; - - const EC& ec() const { return *this; } - -public: - - void - update_exact() const - { - this->et = new ET(ec()(CGAL::exact(l1_))); - this->at = E2A()(*(this->et)); - // Prune lazy tree - l1_ = L1(); - } - - Lazy_rep_1(const AC& ac, const EC& ec, const L1& l1) - : Lazy_rep(ac(CGAL::approx(l1))), EC(ec), l1_(l1) - { - this->set_depth(CGAL::depth(l1_) + 1); - } - -#ifdef CGAL_LAZY_KERNEL_DEBUG_SHOW_TYPEID -# define CGAL_LAZY_PRINT_TYPEID CGAL::msg(os, level, typeid(AC).name()); -#else // not CGAL_LAZY_KERNEL_DEBUG_SHOW_TYPEID -# define CGAL_LAZY_PRINT_TYPEID -#endif // not CGAL_LAZY_KERNEL_DEBUG_SHOW_TYPEID - -#ifdef CGAL_LAZY_KERNEL_DEBUG - void - print_dag(std::ostream& os, int level) const - { - this->print_at_et(os, level); - if(this->is_lazy()){ - CGAL_LAZY_PRINT_TYPEID - CGAL::msg(os, level, "DAG with one child node:"); - CGAL::print_dag(l1_, os, level+1); - } - } -#endif -}; - -#ifdef CGAL_LAZY_KERNEL_DEBUG -# define CGAL_PRINT_DAG_LN(z, n, d) \ - CGAL::print_dag(l##n, os, level+1); -# define CGAL_LAZY_REP_PRINT_DAG(n) \ - void print_dag(std::ostream& os, int level) const { \ - this->print_at_et(os, level); \ - if(this->is_lazy()){ \ - CGAL_LAZY_PRINT_TYPEID \ - CGAL::msg(os, level, "DAG with " #n " child nodes:"); \ - BOOST_PP_REPEAT(n, CGAL_PRINT_DAG_LN, _) \ - } \ - } -#else // not CGAL_LAZY_KERNEL_DEBUG -# define CGAL_LAZY_REP_PRINT_DAG(n) -#endif // not CGAL_LAZY_KERNEL_DEBUG - -#define CGAL_LAZY_REP(z, n, d) \ - template< typename AT, typename ET, typename AC, typename EC, typename E2A, BOOST_PP_ENUM_PARAMS(n, typename L)> \ -class Lazy_rep_##n :public Lazy_rep< AT, \ - ET, \ - E2A >, \ - private EC \ -{ \ - \ - template \ - friend class Lazy_kernel_base; \ - BOOST_PP_REPEAT(n, CGAL_MLIST, _) \ - const EC& ec() const { return *this; } \ -public: \ - void update_exact() const { \ - this->et = new ET(ec()( BOOST_PP_ENUM(n, CGAL_LEXACT, _) ) ); \ - this->at = E2A()(*(this->et)); \ - BOOST_PP_REPEAT(n, CGAL_PRUNE_TREE, _) \ - } \ - Lazy_rep_##n(const AC& ac, const EC&, BOOST_PP_ENUM(n, CGAL_LARGS, _)) \ - : Lazy_rep(ac( BOOST_PP_ENUM(n, CGAL_LN, CGAL::approx) )), BOOST_PP_ENUM(n, CGAL_LINIT, _) \ - { this->set_depth(max_n( BOOST_PP_ENUM(n, CGAL_LN, CGAL::depth) ) + 1); } \ - \ - CGAL_LAZY_REP_PRINT_DAG(n) \ -}; - -BOOST_PP_REPEAT_FROM_TO(2, 9, CGAL_LAZY_REP, _) - -#undef CGAL_TMAP -#undef CGAL_PRUNE_TREE -#undef CGAL_LINIT -#undef CGAL_LAZY_REP -#undef CGAL_LN -#undef CGAL_MLIST -#undef CGAL_PRINT_DAG_LN -#undef CGAL_LAZY_REP_PRINT_DAG #undef CGAL_LAZY_PRINT_TYPEID template < typename K1, typename K2 > @@ -854,6 +791,8 @@ struct Lazy_construction_bbox template struct Lazy_construction_nt { + Lazy_construction_nt(){} + Lazy_construction_nt(LK const&){} static const bool Protection = true; @@ -878,30 +817,23 @@ struct Lazy_construction_nt { BOOST_PP_REPEAT_FROM_TO(1, 6, CGAL_RESULT_NT, _) -#define CGAL_NT_OPERATOR(z, n, d) \ - template \ - typename cpp11::result_of::type \ - operator()( BOOST_PP_ENUM(n, CGAL_LARGS, _) ) const { \ - BOOST_PP_REPEAT(n, CGAL_TYPEMAP_EC, L) \ - BOOST_PP_REPEAT(n, CGAL_TYPEMAP_AC, L) \ - typedef typename boost::remove_cv< typename boost::remove_reference < \ - typename cpp11::result_of< EC(BOOST_PP_ENUM_PARAMS(n, E)) >::type >::type >::type ET; \ - typedef typename boost::remove_cv< typename boost::remove_reference < \ - typename cpp11::result_of< AC(BOOST_PP_ENUM_PARAMS(n, A)) >::type >::type >::type AT; \ - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \ - Protect_FPU_rounding P; \ - try { \ - return new Lazy_rep_##n, BOOST_PP_ENUM_PARAMS(n, L) >(ac, ec, BOOST_PP_ENUM_PARAMS(n, l)); \ - } catch (Uncertain_conversion_exception&) { \ - CGAL_BRANCH_PROFILER_BRANCH(tmp); \ - Protect_FPU_rounding P2(CGAL_FE_TONEAREST); \ - return new Lazy_rep_0 >(ec( BOOST_PP_ENUM(n, CGAL_LEXACT, _) )); \ - } \ - } \ + template + auto operator()(L const&...l) const -> + Lazy_exact_nt>> + { + typedef std::remove_cv_t> ET; + typedef std::remove_cv_t> AT; + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + return new Lazy_rep_n, L... >(ac, ec, l...); + } catch (Uncertain_conversion_exception&) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + return new Lazy_rep_0 >(ec( CGAL::exact(l)... )); + } + } - BOOST_PP_REPEAT_FROM_TO(1, 6, CGAL_NT_OPERATOR, _) - -#undef INTERVAL_OPERATOR #undef CGAL_RESULT_NT }; @@ -1185,8 +1117,8 @@ public: typedef Lazy, std::pair, E2A> Lazy_pair; Lazy_pair lv(new Lazy_rep_2_2(ac, ec, l1, l2)); // lv->approx() is a std::pair; - r1 = R1(Handle_1(new Lazy_rep_1 >, First >, E2A, Lazy_pair>(First >(), First >(), lv))); - r2 = R2(Handle_2(new Lazy_rep_1 >, Second >, E2A, Lazy_pair>(Second >(), Second >(), lv))); + r1 = R1(Handle_1(new Lazy_rep_n >, First >, E2A, Lazy_pair>(First >(), First >(), lv))); + r2 = R2(Handle_2(new Lazy_rep_n >, Second >, E2A, Lazy_pair>(Second >(), Second >(), lv))); } catch (Uncertain_conversion_exception&) { CGAL_BRANCH_PROFILER_BRANCH(tmp); Protect_FPU_rounding P2(CGAL_FE_TONEAREST); @@ -1232,7 +1164,7 @@ public: for (unsigned int i = 0; i < lv.approx().size(); i++) { // FIXME : I'm not sure how this work... #define CGAL_Kernel_obj(X) if (object_cast(& (lv.approx()[i]))) { \ - *it++ = make_object(typename LK::X(new Lazy_rep_1, \ + *it++ = make_object(typename LK::X(new Lazy_rep_n, \ Ith, E2A, Lazy_vector> \ (Ith(i), Ith(i), lv))); \ continue; \ @@ -1304,14 +1236,14 @@ public: CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); Protect_FPU_rounding P; try { - Lazy_object lo(new Lazy_rep_1(ac, ec, l1)); + Lazy_object lo(new Lazy_rep_n(ac, ec, l1)); if(lo.approx().is_empty()) return Object(); #define CGAL_Kernel_obj(X) \ if (object_cast(& (lo.approx()))) { \ - typedef Lazy_rep_1< typename AK::X, typename EK::X, Object_cast, Object_cast, E2A, Lazy_object> Lcr; \ + typedef Lazy_rep_n< typename AK::X, typename EK::X, Object_cast, Object_cast, E2A, Lazy_object> Lcr; \ Lcr * lcr = new Lcr(Object_cast(), Object_cast(), lo); \ return make_object(typename LK::X(lcr)); \ } @@ -1337,14 +1269,14 @@ public: CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); Protect_FPU_rounding P; try { - Lazy_object lo(new Lazy_rep_2(ac, ec, l1, l2)); + Lazy_object lo(new Lazy_rep_n(ac, ec, l1, l2)); if(lo.approx().is_empty()) return Object(); #define CGAL_Kernel_obj(X) \ if (object_cast(& (lo.approx()))) { \ - typedef Lazy_rep_1, Object_cast, E2A, Lazy_object> Lcr; \ + typedef Lazy_rep_n, Object_cast, E2A, Lazy_object> Lcr; \ Lcr * lcr = new Lcr(Object_cast(), Object_cast(), lo); \ return make_object(typename LK::X(lcr)); \ } @@ -1360,7 +1292,7 @@ public: std::vector V;\ V.resize(v_ptr->size()); \ for (unsigned int i = 0; i < v_ptr->size(); i++) { \ - V[i] = typename LK::X(new Lazy_rep_1, \ + V[i] = typename LK::X(new Lazy_rep_n, \ Ith_for_intersection, E2A, Lazy_object> \ (Ith_for_intersection(i), Ith_for_intersection(i), lo)); \ } \ @@ -1391,14 +1323,14 @@ CGAL_Kernel_obj(Point_3) CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); Protect_FPU_rounding P; try { - Lazy_object lo(new Lazy_rep_3(ac, ec, l1, l2, l3)); + Lazy_object lo(new Lazy_rep_n(ac, ec, l1, l2, l3)); if(lo.approx().is_empty()) return Object(); #define CGAL_Kernel_obj(X) \ if (object_cast(& (lo.approx()))) { \ - typedef Lazy_rep_1, Object_cast, E2A, Lazy_object> Lcr; \ + typedef Lazy_rep_n, Object_cast, E2A, Lazy_object> Lcr; \ Lcr * lcr = new Lcr(Object_cast(), Object_cast(), lo); \ return make_object(typename LK::X(lcr)); \ } @@ -1469,7 +1401,7 @@ struct Fill_lazy_variant_visitor_2 : boost::static_visitor<> { typedef typename Type_mapper::type EKT; typedef typename Type_mapper::type LKT; - typedef Lazy_rep_1, Variant_cast, typename LK::E2A, Origin> Lcr; + typedef Lazy_rep_n, Variant_cast, typename LK::E2A, Origin> Lcr; Lcr * lcr = new Lcr(Variant_cast(), Variant_cast(), *o); *r = LKT(lcr); @@ -1484,7 +1416,7 @@ struct Fill_lazy_variant_visitor_2 : boost::static_visitor<> { std::vector V; V.resize(t.size()); for (unsigned int i = 0; i < t.size(); i++) { - V[i] = LKT(new Lazy_rep_1, + V[i] = LKT(new Lazy_rep_n, Ith_for_intersection, typename LK::E2A, Origin> (Ith_for_intersection(i), Ith_for_intersection(i), *o)); } @@ -1565,7 +1497,7 @@ struct Lazy_construction_variant { Protect_FPU_rounding P; try { - Lazy lazy(new Lazy_rep_2(AC(), EC(), l1, l2)); + Lazy lazy(new Lazy_rep_n(AC(), EC(), l1, l2)); // the approximate result requires the trait with types from the AK AT approx_v = lazy.approx(); @@ -1614,7 +1546,7 @@ struct Lazy_construction_variant { CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); Protect_FPU_rounding P; try { - Lazy lazy(new Lazy_rep_3(AC(), EC(), l1, l2, l3)); + 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(); @@ -1681,7 +1613,7 @@ struct Lazy_construction { CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \ Protect_FPU_rounding P; \ try { \ - return result_type( Handle(new Lazy_rep_##n(ac, ec, BOOST_PP_ENUM_PARAMS(n, l)))); \ + return result_type( Handle(new Lazy_rep_n(ac, ec, BOOST_PP_ENUM_PARAMS(n, l)))); \ } catch (Uncertain_conversion_exception&) { \ CGAL_BRANCH_PROFILER_BRANCH(tmp); \ Protect_FPU_rounding P2(CGAL_FE_TONEAREST); \ @@ -1748,7 +1680,7 @@ struct result { \ CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \ Protect_FPU_rounding P; \ try { \ - return result_type( Handle(new Lazy_rep_##n(ac, ec, BOOST_PP_ENUM_PARAMS(n, l)))); \ + return result_type( Handle(new Lazy_rep_n(ac, ec, BOOST_PP_ENUM_PARAMS(n, l)))); \ } catch (Uncertain_conversion_exception&) { \ CGAL_BRANCH_PROFILER_BRANCH(tmp); \ Protect_FPU_rounding P2(CGAL_FE_TONEAREST); \ diff --git a/Filtered_kernel/include/CGAL/Lazy_kernel.h b/Filtered_kernel/include/CGAL/Lazy_kernel.h index 90e18354df0..1009198e04d 100644 --- a/Filtered_kernel/include/CGAL/Lazy_kernel.h +++ b/Filtered_kernel/include/CGAL/Lazy_kernel.h @@ -330,7 +330,7 @@ public: FT operator()(const Weighted_point_2& p) const { - typedef Lazy_rep_3 LR; - typedef Lazy_rep_3 LR; - typedef Lazy_rep_3 #include #include +#include #include - +// TODO: add static filters somewhere namespace CGAL { -#define CGAL_BASE \ - Cartesian_base_d::Type, Dim> -template -struct Epeck_d_help1 -: CGAL_BASE -{ - CGAL_CONSTEXPR Epeck_d_help1(){} - CGAL_CONSTEXPR Epeck_d_help1(int d):CGAL_BASE(d){} -}; +#define CGAL_KA Cartesian_base_d +#define CGAL_KE Cartesian_base_d::Type, Dim> +template using Epeck_d_help1 = Lazy_cartesian>; +#undef CGAL_KE +#undef CGAL_KA #undef CGAL_BASE #define CGAL_BASE \ Kernel_d_interface< \ diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_base.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_base.h index 632ee0ef9e7..533b953331c 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_base.h @@ -88,6 +88,7 @@ struct Cartesian_LA_base_d : public Dimension_base ::add::type ::add::type ::add::type + ::add::type Object_list; typedef typeset< Point_cartesian_const_iterator_tag>::type diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h b/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h index a9307329fc1..d60b5d896a8 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h @@ -321,6 +321,12 @@ template struct In_flat_power_side_of_power_sphere_raw : private Store } + +// For the lazy kernel +inline CartesianDKernelFunctors::Flat_orientation const& exact(CartesianDKernelFunctors::Flat_orientation const& o){return o;} +inline CartesianDKernelFunctors::Flat_orientation const& approx(CartesianDKernelFunctors::Flat_orientation const& o){return o;} +inline unsigned depth(CartesianDKernelFunctors::Flat_orientation const&){return 0;} + CGAL_KD_DEFAULT_TYPE(Flat_orientation_tag,(CGAL::CartesianDKernelFunctors::Flat_orientation),(),()); CGAL_KD_DEFAULT_FUNCTOR(In_flat_orientation_tag,(CartesianDKernelFunctors::In_flat_orientation),(Point_tag),(Compute_point_cartesian_coordinate_tag,Point_dimension_tag)); CGAL_KD_DEFAULT_FUNCTOR(In_flat_side_of_oriented_sphere_tag,(CartesianDKernelFunctors::In_flat_side_of_oriented_sphere),(Point_tag),(Compute_point_cartesian_coordinate_tag,Point_dimension_tag)); diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h index c1cb7ce07e1..f6463dda4dd 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h @@ -151,30 +151,33 @@ template struct Kernel_d_interface : public Base_ { CGAL_FUNCTOR_INIT_STORE(Construct_cartesian_const_iterator_d) typedef typename Get_functor >::type CPI; typedef typename Get_functor >::type CVI; - // FIXME: The following sometimes breaks compilation. The typedef below forces instantiation of this, which forces Point_d, which itself (in the wrapper) needs the derived kernel to tell it what the base kernel is, and that's a cycle. The exact circumstances are not clear, g++ and clang++ are ok in both C++03 and C++11, it is only clang in C++11 without CGAL_CXX11 that breaks. For now, rely on result_type. + // FIXME: The following sometimes breaks compilation. The typedef below forces instantiation of this, which forces Point_d, which itself (in the wrapper) needs the derived kernel to tell it what the base kernel is, and that's a cycle. The exact circumstances are not clear, g++ and clang++ are ok in both C++03 and C++11, it is only clang in C++11 without CGAL_CXX11 that breaks. Relying on CPI::result_type is great for Epick_d but not Epeck_d. //typedef typename CGAL::decay::type>::type result_type; - typedef typename CGAL::decay::type result_type; + //typedef typename CGAL::decay::type result_type; + //typedef decltype(std::declval()(std::declval(),Begin_tag{})) result_type; + // HACK + typedef typename Base::Point_cartesian_const_iterator result_type; // Kernel_d requires a common iterator type for points and vectors // TODO: provide this mixed functor in preKernel? //CGAL_static_assertion((boost::is_same::type>::type, result_type>::value)); - CGAL_static_assertion((boost::is_same::type, result_type>::value)); + //CGAL_static_assertion((boost::is_same::type, result_type>::value)); template - result_type operator()(Point_d const&p, Tag_ t)const{ + auto operator()(Point_d const&p, Tag_ t)const{ return CPI(this->kernel())(p,t); } template - result_type operator()(typename First_if_different::Type const&v, Tag_ t)const{ + auto operator()(typename First_if_different::Type const&v, Tag_ t)const{ return CVI(this->kernel())(v,t); } template - result_type operator()(Obj const&o)const{ + auto operator()(Obj const&o)const{ return operator()(o, Begin_tag()); } - result_type operator()(Point_d const&p, int)const{ + auto operator()(Point_d const&p, int)const{ return operator()(p, End_tag()); } - result_type operator()(typename First_if_different::Type const&v, int)const{ + auto operator()(typename First_if_different::Type const&v, int)const{ return operator()(v, End_tag()); } }; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h index 9d8c2280297..152b4f47eda 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h @@ -95,6 +95,18 @@ template struct KO_converter{ } }; +template struct KO_converter{ + typedef typename Get_type::type argument_type; + typedef typename Get_type::type result_type; + template + result_type operator()(K1 const& k1, K2 const& k2, C const& conv, argument_type const& s) const { + typename Get_functor::type f(k1); + typename Get_functor::type g(k1); + typename Get_functor >::type cib(k2); + return cib(conv(f(s)),conv(g(s))); + } +}; + template struct KO_converter{ typedef typename Get_type::type argument_type; typedef typename Get_type::type result_type; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h index 4ae80544fcf..1912ce7f214 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h @@ -28,6 +28,7 @@ #include #include #include +#include namespace CGAL { @@ -61,6 +62,47 @@ namespace internal { }; } +template +struct Lazy_construction2 { + static const bool Protection = true; + + typedef typename LK::Approximate_kernel AK; + typedef typename LK::Exact_kernel EK; + typedef typename LK::E2A E2A; + typedef typename Get_functor::type AC; + typedef typename Get_functor::type EC; + typedef typename map_result_tag::type result_tag; + typedef typename Get_type::type AT; + typedef typename Get_type::type ET; + typedef typename Get_type::type result_type; + // same as Handle = Lazy< AT, ET, E2A> + + Lazy_construction2(){} + Lazy_construction2(LK const&k):ac(k.approximate_kernel()),ec(k.exact_kernel()){} + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; + + template + std::enable_if_t<(sizeof...(L)>0), result_type> operator()(L const&...l) const { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + return new Lazy_rep_n(ac, ec, l...); + } catch (Uncertain_conversion_exception&) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + return new Lazy_rep_0(ec(CGAL::exact(l)...)); + } + } + // FIXME: this forces us to have default constructors for all types, try to make its instantiation lazier + result_type operator()() const + { + return new Lazy_rep_0(); + } + +#undef CGAL_CONSTRUCTION_OPERATOR +}; + template struct Lazy_cartesian_types { @@ -103,20 +145,30 @@ struct Lazy_cartesian_types }; template -struct Lazy_cartesian : Dimension_base, +struct Lazy_cartesian : Lazy_cartesian_types > { - //CGAL_CONSTEXPR Lazy_cartesian(){} - //CGAL_CONSTEXPR Lazy_cartesian(int d):Base_(d){} + CGAL_CONSTEXPR Lazy_cartesian(){} + CGAL_CONSTEXPR Lazy_cartesian(int d):ak(d),ek(d){} //TODO: Do we want to store an AK and an EK? Or just references? //FIXME: references would be better I guess. //TODO: In any case, make sure that we don't end up storing this kernel for //nothing (it is not empty but references empty kernels or something) - AK_ ak; EK_ ek; + CGAL_NO_UNIQUE_ADDRESS AK_ ak; + CGAL_NO_UNIQUE_ADDRESS EK_ ek; AK_ const& approximate_kernel()const{return ak;} EK_ const& exact_kernel()const{return ek;} + int dimension()const{return ak.dimension();} + void set_dimension(int dim){ak.set_dimension(dim);ek.set_dimension(dim);} + + // For compilers that do not handle [[no_unique_address]] + typedef boost::mpl::and_< + internal::Do_not_store_kernel, + internal::Do_not_store_kernel > Do_not_store_kernel; + + typedef typename EK_::Dimension Dimension; // ? typedef Lazy_cartesian Self; typedef Lazy_cartesian_types Base; //typedef typename Default::Get::type Kernel; @@ -124,8 +176,18 @@ struct Lazy_cartesian : Dimension_base, typedef AK_ Approximate_kernel; typedef EK_ Exact_kernel; typedef E2A_ E2A; - typedef Approx_converter C2A; - typedef Exact_converter C2E; + //typedef Approx_converter C2A; + //typedef Exact_converter C2E; + struct C2A { + C2A(){} + C2A(Kernel const&, Approximate_kernel const&){} + templatedecltype(auto)operator()(T const&t)const{return CGAL::approx(t);} + }; + struct C2E { + C2E(){} + C2E(Kernel const&, Exact_kernel const&){} + templatedecltype(auto)operator()(T const&t)const{return CGAL::exact(t);} + }; typedef typename Exact_kernel::Rep_tag Rep_tag; typedef typename Exact_kernel::Kernel_tag Kernel_tag; @@ -151,12 +213,58 @@ struct Lazy_cartesian : Dimension_base, template struct Functor { typedef typename Get_functor::type FA; typedef typename Get_functor::type FE; - typedef Lazy_construction type; + typedef Lazy_construction2 type; + }; + template struct Functor { + typedef typename Get_functor::type FA; + struct type { + FA fa; + type(){} + type(Kernel const&k):fa(k.approximate_kernel()){} + template + int operator()(P const&p)const{return fa(CGAL::approx(p));} + }; + }; + template struct Functor { + typedef typename Get_functor::type FA; + struct type { + FA fa; + type(){} + type(Kernel const&k):fa(k.approximate_kernel()){} + template + int operator()(V const&v)const{return fa(CGAL::approx(v));} + }; + }; + template struct Functor { + // Don't filter that one, as there is no guarantee that the interval + // basis would be in any way related to the exact basis, the most obvious + // difference being the order of the vectors. + // Don't try to be generic until we have more than just this one. + typedef typename Get_functor::type FE; + typedef typename Get_type::type AT; + typedef typename Get_type::type ET; + typedef typename Base::template Type::type V; // Lazy + struct type { + FE fe; + type(){} + type(Kernel const&k):fe(k.exact_kernel()){} + template + void operator()(Iter i, Iter e, Oter o)const{ + fe(CGAL::exact(i), CGAL::exact(e), + boost::make_function_output_iterator( + [&o](ET const&v){ + *o++ = V(new Lazy_rep_0(v)); + } + ) + ); + } + }; }; - //typedef typename Iterator::type Point_cartesian_const_iterator; - //typedef typename Iterator::type Vector_cartesian_const_iterator; + typedef typename Base::template Iterator::type Point_cartesian_const_iterator; + typedef typename Base::template Iterator::type Vector_cartesian_const_iterator; + // This is really specific to point/vector coordinate iterators template struct Construct_iter : private Store_kernel { Construct_iter(){} @@ -169,7 +277,8 @@ struct Lazy_cartesian : Dimension_base, } template result_type operator()(T const& t,End_tag)const{ - return result_type(t,Self().dimension(),this->kernel()); + typedef typename Get_functor::type PD; + return result_type(t,PD(this->kernel().approximate_kernel())(CGAL::approx(t)),this->kernel()); } }; template struct Functor { diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Hyperplane.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Hyperplane.h index 1a32b080bed..21333780d2c 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Hyperplane.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Hyperplane.h @@ -33,6 +33,7 @@ template class Hyperplane { FT_ s_; public: + Hyperplane(){} Hyperplane(Vector_ const&v, FT_ const&s): v_(v), s_(s) {} // TODO: Add a piecewise constructor? diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Sphere.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Sphere.h index ff82aec26a5..b6c12e11c83 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Sphere.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Sphere.h @@ -30,6 +30,7 @@ template class Sphere { FT_ r2_; public: + Sphere(){} Sphere(Point_ const&p, FT_ const&r2): c_(p), r2_(r2) {} // TODO: Add a piecewise constructor? diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h index ed0c7d71191..8bb92abdcfe 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h @@ -31,6 +31,7 @@ template class Weighted_point { FT_ w_; public: + Weighted_point(){} Weighted_point(Point_ const&p, FT_ const&w): c_(p), w_(w) {} // TODO: Add a piecewise constructor? diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h b/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h index 6f9aa5bb3f2..f600134e0e4 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h @@ -162,6 +162,8 @@ BOOST_PP_REPEAT_FROM_TO(1, 11, CGAL_CODE, _ ) } }; +// Do not try to instantiate the above +template struct Array_vector {}; } #endif diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Vector/mix.h b/NewKernel_d/include/CGAL/NewKernel_d/Vector/mix.h index de8aac8845a..2e7145f6003 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Vector/mix.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Vector/mix.h @@ -33,6 +33,7 @@ struct Mix_vector }; }; +// FIXME: shouldn't we dispatch based on Max_dim_ instead? template struct Mix_vector, Max_dim_> : Static_::template Rebind_dimension, Max_dim_>::Other diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h index 4d5147dbffc..a97529bf6e7 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h @@ -145,9 +145,8 @@ struct Cartesian_wrap : public Base_ B b; type(){} type(Self const&k):b(k){} - typedef typename B::result_type result_type; #ifdef CGAL_CXX11 - template result_type operator()(U&&...u)const{ + template decltype(auto) operator()(U&&...u)const{ return b(internal::Forward_rep()(u)...); } #else diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h index a4013b983d3..643828d9733 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h @@ -156,6 +156,13 @@ public: return PDBase()(rep()); } + friend auto operator==(Point_d const&p, Point_d const&q) { + typedef typename Get_functor::type EPBase; + return EPBase()(p.rep(), q.rep()); + } + + friend auto operator!=(Point_d const&p, Point_d const&q) { return !(p==q); } + /* Direction_d direction() const { diff --git a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h index 1e7a34b3e1e..94bd1e2ab76 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h @@ -462,7 +462,7 @@ template struct Linear_base : private Store_kernel { typedef typename R::LA::Dynamic_matrix Matrix; template - result_type operator()(Iter f, Iter e, Oter&o)const{ + result_type operator()(Iter f, Iter e, Oter o)const{ typename Get_functor::type c(this->kernel()); typename Get_functor::type vd(this->kernel()); typename Get_functor >::type cv(this->kernel()); diff --git a/NewKernel_d/include/CGAL/iterator_from_indices.h b/NewKernel_d/include/CGAL/iterator_from_indices.h index 22e772a5031..895a5f47916 100644 --- a/NewKernel_d/include/CGAL/iterator_from_indices.h +++ b/NewKernel_d/include/CGAL/iterator_from_indices.h @@ -50,7 +50,7 @@ class Iterator_from_indices typedef std::ptrdiff_t index_t; Container_* cont; index_t index; - Coord_access ca; + CGAL_NO_UNIQUE_ADDRESS Coord_access ca; void increment(){ ++index; } void decrement(){ --index; } void advance(std::ptrdiff_t n){ index+=n; } @@ -66,6 +66,7 @@ class Iterator_from_indices return ca(*cont,index); } public: + Iterator_from_indices(){} Iterator_from_indices(Container_& cont_,std::size_t n) : cont(&cont_), index(n) {} template diff --git a/NewKernel_d/test/NewKernel_d/Epick_d.cpp b/NewKernel_d/test/NewKernel_d/Epick_d.cpp index 30aa5f79882..503450d96d7 100644 --- a/NewKernel_d/test/NewKernel_d/Epick_d.cpp +++ b/NewKernel_d/test/NewKernel_d/Epick_d.cpp @@ -11,6 +11,7 @@ int main() //#define BOOST_RESULT_OF_USE_DECLTYPE 1 #include +#include #include #include @@ -121,7 +122,6 @@ void test2(){ typedef typename K1::Oriented_side_d OS; typedef typename K1::Orthogonal_vector_d OV; typedef typename K1::Point_dimension_d PD; - typedef typename K1::Point_of_sphere_d PS; typedef typename K1::Point_to_vector_d PV; typedef typename K1::Vector_to_point_d VP; typedef typename K1::Barycentric_coordinates_d BC; @@ -190,7 +190,6 @@ void test2(){ OS os Kinit(oriented_side_d_object); OV ov Kinit(orthogonal_vector_d_object); PD pd Kinit(point_dimension_d_object); - PS ps Kinit(point_of_sphere_d_object); PV pv Kinit(point_to_vector_d_object); VP vp Kinit(vector_to_point_d_object); BC bc Kinit(barycentric_coordinates_d_object); @@ -356,6 +355,8 @@ void test2(){ #endif P z0=cp( 0+2,5-3); P z1=cp(-5+2,0-3); + assert(abs(sd(z0,z1)-50)<.0001); + assert(ed(z0,z0) && !ed(z0,z1)); P z2=cp( 3+2,4-3); P tabz[]={z0,z1,z2}; Sp sp = csp(tabz+0,tabz+3); @@ -368,6 +369,8 @@ void test2(){ assert(abs(sp.squared_radius()-25)<.0001); #if 1 // Fails for an exact kernel + typedef typename K1::Point_of_sphere_d PS; + PS ps Kinit(point_of_sphere_d_object); P psp0=ps(sp,0); P psp1=ps(sp,1); P psp2=ps(sp,2); @@ -423,12 +426,15 @@ template struct Construct_point3_helper { Construct_point3_helper(CP const& x) : cp(x) {} template typename CP::result_type operator()(T1 const&t1, T2 const&t2, T3 const&t3)const{ - double tab[]={(double)t1,(double)t2,(double)t3}; + //double tab[]={(double)t1,(double)t2,(double)t3}; + // The lazy kernel stores iterators, not a vector, so the array must stay alive until update_exact()! For the tests I am keeping the memory leak for now, it is more convenient. + double*tab=new double[3]{(double)t1,(double)t2,(double)t3}; return cp(tab+0,tab+3); } template typename CP::result_type operator()(T1 const&t1, T2 const&t2, T3 const&t3, T4 const&t4)const{ - double tab[]={(double)t1,(double)t2,(double)t3}; + // Same discussion as above + double*tab=new double[3]{(double)t1,(double)t2,(double)t3}; return cp(tab+0,tab+3,t4); } }; @@ -690,6 +696,9 @@ int main(){ test2(); test3(); test3(); + //test2>>(); + //test3>>(); + //test3>(); } #endif From 05eaf8f4f6a9180f4b6496a69938cd07676c5479 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 4 Feb 2019 21:56:31 +0100 Subject: [PATCH 04/56] Document Epeck_d. --- Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h | 143 +++++++++++++++++++ Kernel_d/doc/Kernel_d/CGAL/Epick_d.h | 1 + Kernel_d/doc/Kernel_d/Kernel_d.txt | 16 +++ Kernel_d/doc/Kernel_d/PackageDescription.txt | 1 + 4 files changed, 161 insertions(+) create mode 100644 Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h new file mode 100644 index 00000000000..ac607f9f53c --- /dev/null +++ b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h @@ -0,0 +1,143 @@ + +namespace CGAL { + +/*! +\ingroup PkgKernelDKernels + +A model for `Kernel_d`, minus `Kernel_d::Point_of_sphere_d`, that uses %Cartesian coordinates to represent the +geometric objects. + +This kernel is default constructible and copyable. It does not carry any +state so it is possible to use objects created by one instance with +functors created by another one. + +This kernel supports construction of points from `double` %Cartesian +coordinates. It provides exact geometric predicates and constructions. The +geometric predicates are made exact without sacrificing speed thanks to the use +of filters. The geometric constructions are made exact without sacrificing +speed thanks to a lazy mechanism, similar to `Epeck`. A construction creates an +approximate object, and stores a directed acyclic graph (DAG) of the operation +and arguments used. When an operation needs more precision on an object than is +currently available, which should be rare, CGAL reconstructs exactly all the +ancestors of the object and replaces this part of the graph with exact objects. +This should be transparent for users, those details do not affect the +functionality, but they can cause surprising running time where the costly part +of an algorithm is not the construction itself, but a seemingly trivial use +afterwards that causes exact reconstruction of a large part of the structure. + +`Sphere_d` is represented internally with a center and a squared radius, and the exact type used by the kernel is a rational type. This means that `Kernel_d::Point_of_sphere_d` cannot be implemented exactly in dimensions up to 3 (higher dimensions would require a decomposition of an integer as a sum of `d` squares), so currently it is not provided at all. + +\tparam DimensionTag is a tag representing the dimension of the +ambient Euclidean space. It may be either `Dimension_tag` where `d` is +an integer +or `Dynamic_dimension_tag`. In the latter case, the dimension of the space is specified for each point when it is constructed, so it does not need to be known at compile-time. + + +\attention Only the interfaces specific to this class are listed below. Refer to the +concepts for the rest. + +\attention Known bugs: the functor `Intersect_d` is not yet implemented. `Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Orientation_d` only works for points, not vectors. Constructing a `Point_d` with iterators is done lazily, see below. + +\attention Ancient compilers like gcc-4.2 or icc 14 are not supported, but gcc-4.4 and +icc 15 work. + +\attention This kernel requires the \ref thirdpartyEigen "Eigen" library. + + + +\cgalModels `Kernel_d` +\cgalModels `DelaunayTriangulationTraits` +\cgalModels `RegularTriangulationTraits` +\cgalModels `SearchTraits` +\cgalModels `RangeSearchTraits` + +\sa `CGAL::Cartesian_d` +\sa `CGAL::Homogeneous_d` +\sa `CGAL::Epick_d` + +*/ +template< typename DimensionTag > +struct Epeck_d { +/*! +represents a point in the Euclidean space +\cgalModels `DefaultConstructible` +\cgalModels `Assignable` +*/ +class Point_d { +public: +/*! introduces a point with coordinates (x0, x1, ...) where the number of + coordinates matches the dimension. + \pre `DimensionTag` is a fixed dimension, not `Dynamic_dimension_tag`. */ +Point_d(double x0, double x1, ...); + +/*! introduces a point with coordinate set `[first,end)`. + \pre If `DimensionTag` is a fixed dimension, it matches `distance(first,end)`. + \tparam ForwardIterator has its value type that is convertible to `double`. + \bug{Lazy construction} This constructor stores the iterators and may use + them at any later time, when an exact construction is needed. This means + that if `[first,end)` points to some buffer, it has to remain alive at + least as long as the point. + */ +template +Point_d(ForwardIterator first, ForwardIterator end); + +/*! returns the i'th coordinate of a point. + \pre `i` is non-negative and less than the dimension. */ +double operator[](int i)const; + +/*! returns an iterator pointing to the zeroth Cartesian coordinate. */ +Cartesian_const_iterator_d cartesian_begin()const; +/*! returns an iterator pointing beyond the last Cartesian coordinate. */ +Cartesian_const_iterator_d cartesian_end()const; +}; + +/*! +represents a weighted point in the Euclidean space +\cgalModels `DefaultConstructible` +\cgalModels `Assignable` +*/ +class Weighted_point_d { +public: +/*! introduces a weighted point with point p and weight w. */ +Weighted_point_d(const Point_d& p, const double& w); +/*! extracts the point of a weighted point. */ +Point_d point() const; +/*! extracts the weight of a weighted point. */ +double weight() const; +}; + +/*! \cgalModels `Kernel_d::Center_of_sphere_d` + */ +class Construct_circumcenter_d { +public: +/*! returns the center of the sphere defined by `A=tuple[first,last)`. The sphere is centered in the affine hull of A and passes through all the points of A. The order of the points of A does not matter. + \pre A is affinely independant. + \tparam ForwardIterator has `Epeck_d::Point_d` as value type. + */ +template +Point_d operator()(ForwardIterator first, ForwardIterator last); +}; +class Compute_squared_radius_d { +public: +/*! returns the radius of the sphere defined by `A=tuple[first,last)`. The sphere is centered in the affine hull of A and passes through all the points of A. The order of the points of A does not matter. + \pre A is affinely independant. + \tparam ForwardIterator has `Epeck_d::Point_d` as value type. + */ +template +Point_d operator()(ForwardIterator first, ForwardIterator last); +}; +/*! \cgalModels `Kernel_d::Side_of_bounded_sphere_d` + */ +class Side_of_bounded_sphere_d { +public: +/*! returns the relative position of point p to the sphere defined by `A=tuple[first,last)`. The sphere is centered in the affine hull of A and passes through all the points of A. The order of the points of A does not matter. + \pre A is affinely independant. + \tparam ForwardIterator has `Epeck_d::Point_d` as value type. + */ +template +Bounded_side operator()(ForwardIterator first, ForwardIterator last, const Point_d&p); +}; +Construct_circumcenter_d construct_circumcenter_d_object(); +Compute_squared_radius_d compute_squared_radius_d_object(); +}; /* end Epeck_d */ +} /* end namespace CGAL */ diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h index ce9133544be..ab6ac6e5f5d 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h @@ -43,6 +43,7 @@ icc 15 work. \sa `CGAL::Cartesian_d` \sa `CGAL::Homogeneous_d` +\sa `CGAL::Epeck_d` */ template< typename DimensionTag > diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index bdfa7b73a6e..09469675ec6 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -224,6 +224,22 @@ Note that it provides few interfaces in addition to those documented in the `Kernel_d` concept. In particular, the type of a point is only available as `Epick_d::%Point_d`, not `Point_d>`. +\subsection Kernel_dEpickKernel Epeck_d Kernel + +The kernel `Epeck_d`, short for Exact Predicates Exact +Constructions Kernel is a kernel particularly useful when the dimension of +the space is known at compile-time; The template parameter `DimensionTag` is then +`Dimension_tag` where `d` is an integer representing the dimension. It +may also be used with parameter `Dynamic_dimension_tag`, in which case the +dimension does not need to be known at compile-time. +It uses a %Cartesian representation and +supports construction of points from `double` coordinates. It provides exact +geometric predicates and constructions. + +Note that it provides few interfaces in addition to those documented in the +`Kernel_d` concept. In particular, the type of a point is only available as +`Epeck_d::%Point_d`, not `Point_d>`. + \subsection Kernel_dNamingconventions Naming Conventions diff --git a/Kernel_d/doc/Kernel_d/PackageDescription.txt b/Kernel_d/doc/Kernel_d/PackageDescription.txt index a2a4f31cbf3..b2e0d977672 100644 --- a/Kernel_d/doc/Kernel_d/PackageDescription.txt +++ b/Kernel_d/doc/Kernel_d/PackageDescription.txt @@ -49,6 +49,7 @@ - `CGAL::Cartesian_d` - `CGAL::Homogeneous_d` - `CGAL::Epick_d` +- `CGAL::Epeck_d` ## %Kernel Objects ## - `CGAL::Point_d` From 540a7d312bff4e42c4a7d1d9e1d0de0c84507ca5 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 4 Feb 2019 22:14:37 +0100 Subject: [PATCH 05/56] Try adding some \cgalModifBegin/End. --- Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h | 2 +- Kernel_d/doc/Kernel_d/CGAL/Epick_d.h | 4 +++- Kernel_d/doc/Kernel_d/Kernel_d.txt | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h index ac607f9f53c..3d0a7adaad3 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h @@ -5,7 +5,7 @@ namespace CGAL { \ingroup PkgKernelDKernels A model for `Kernel_d`, minus `Kernel_d::Point_of_sphere_d`, that uses %Cartesian coordinates to represent the -geometric objects. +geometric objects. This kernel is default constructible and copyable. It does not carry any state so it is possible to use objects created by one instance with diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h index ab6ac6e5f5d..29c2f3738d9 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h @@ -4,8 +4,9 @@ namespace CGAL { /*! \ingroup PkgKernelDKernels +\cgalModifBegin A model for `Kernel_d` that uses %Cartesian coordinates to represent the -geometric objects. +geometric objects. This kernel is default constructible and copyable. It does not carry any state so it is possible to use objects created by one instance with @@ -127,3 +128,4 @@ Construct_circumcenter_d construct_circumcenter_d_object(); Compute_squared_radius_d compute_squared_radius_d_object(); }; /* end Epick_d */ } /* end namespace CGAL */ +/// \cgalModifEnd diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index 09469675ec6..17bdcf363c8 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -224,6 +224,7 @@ Note that it provides few interfaces in addition to those documented in the `Kernel_d` concept. In particular, the type of a point is only available as `Epick_d::%Point_d`, not `Point_d>`. +\cgalModifBegin \subsection Kernel_dEpickKernel Epeck_d Kernel The kernel `Epeck_d`, short for Exact Predicates Exact @@ -239,6 +240,7 @@ geometric predicates and constructions. Note that it provides few interfaces in addition to those documented in the `Kernel_d` concept. In particular, the type of a point is only available as `Epeck_d::%Point_d`, not `Point_d>`. +\cgalModifEnd \subsection Kernel_dNamingconventions Naming Conventions From e0efdb377214ba5e71fff66d8cbc76cdbf012295 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 4 Feb 2019 22:27:46 +0100 Subject: [PATCH 06/56] Pasto --- Kernel_d/doc/Kernel_d/Kernel_d.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index 17bdcf363c8..9ff972cbc63 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -225,7 +225,7 @@ Note that it provides few interfaces in addition to those documented in the `Epick_d::%Point_d`, not `Point_d>`. \cgalModifBegin -\subsection Kernel_dEpickKernel Epeck_d Kernel +\subsection Kernel_dEpeckKernel Epeck_d Kernel The kernel `Epeck_d`, short for Exact Predicates Exact Constructions Kernel is a kernel particularly useful when the dimension of From f24c875c1651e2b505ca1a070ba8825f5b0d8879 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 4 Feb 2019 22:38:01 +0100 Subject: [PATCH 07/56] \bug doesn't have a title --- Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h index 3d0a7adaad3..0301322ec12 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h @@ -73,7 +73,7 @@ Point_d(double x0, double x1, ...); /*! introduces a point with coordinate set `[first,end)`. \pre If `DimensionTag` is a fixed dimension, it matches `distance(first,end)`. \tparam ForwardIterator has its value type that is convertible to `double`. - \bug{Lazy construction} This constructor stores the iterators and may use + \bug This constructor stores the iterators and may use them at any later time, when an exact construction is needed. This means that if `[first,end)` points to some buffer, it has to remain alive at least as long as the point. From 050a9663b99381c0618918cc2b8a79258583e501 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 5 Feb 2019 20:43:01 +0100 Subject: [PATCH 08/56] Attribution --- Kernel_d/doc/Kernel_d/Kernel_d.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index 9ff972cbc63..10531d1bc56 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -556,7 +556,7 @@ evolution of the low-dimensional kernel. The kernel was revised based on suggestions by Hervé Brönnimann, Michael Hoffmann, and Stefan Schirra. -Epick_d was added by Marc Glisse in 2014. +Marc Glisse added Epick_d in 2014 and Epeck_d in 2019. \subsection Kernel_dAcknowledgments Acknowledgments From 140e407bf8160970a136266b2cbf00c72d6cbfa7 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 5 Feb 2019 20:43:40 +0100 Subject: [PATCH 09/56] No need to warn about gcc-4.2 if it is C++14-only. --- Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h | 3 --- Kernel_d/doc/Kernel_d/CGAL/Epick_d.h | 3 --- 2 files changed, 6 deletions(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h index 0301322ec12..6a58b594230 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h @@ -38,9 +38,6 @@ concepts for the rest. \attention Known bugs: the functor `Intersect_d` is not yet implemented. `Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Orientation_d` only works for points, not vectors. Constructing a `Point_d` with iterators is done lazily, see below. -\attention Ancient compilers like gcc-4.2 or icc 14 are not supported, but gcc-4.4 and -icc 15 work. - \attention This kernel requires the \ref thirdpartyEigen "Eigen" library. diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h index 29c2f3738d9..9916144bf8f 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h @@ -29,9 +29,6 @@ concepts for the rest. \attention Known bugs: the functor `Intersect_d` is not yet implemented. `Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Orientation_d` only works for points, not vectors. -\attention Ancient compilers like gcc-4.2 or icc 14 are not supported, but gcc-4.4 and -icc 15 work. - \attention This kernel requires the \ref thirdpartyEigen "Eigen" library. From 678f911a4759192e006f5cb5a377337536e321d3 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 6 Feb 2019 13:56:05 +0100 Subject: [PATCH 10/56] C++14 tweaks --- .travis.yml | 2 +- Filtered_kernel/include/CGAL/Lazy.h | 42 +++++++++++++------ .../include/CGAL/NewKernel_d/Lazy_cartesian.h | 2 - .../CGAL/NewKernel_d/Wrapper/Point_d.h | 3 +- 4 files changed, 33 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 981151439f8..08fff7246ba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -63,7 +63,7 @@ before_script: - sudo chmod +x /usr/bin/doxygen - mkdir -p build - cd build -- cmake -DCMAKE_CXX_FLAGS="-std=c++11" -DCGAL_HEADER_ONLY=ON -DQt5_DIR="/opt/qt55/lib/cmake/Qt5" -DQt5Svg_DIR="/opt/qt55/lib/cmake/Qt5Svg" -DQt5OpenGL_DIR="/opt/qt55/lib/cmake/Qt5OpenGL" -DCMAKE_CXX_FLAGS_RELEASE=-DCGAL_NDEBUG -DWITH_examples=ON -DWITH_demos=ON -DWITH_tests=ON .. +- cmake -DCMAKE_CXX_FLAGS="-std=c++1y" -DCGAL_HEADER_ONLY=ON -DQt5_DIR="/opt/qt55/lib/cmake/Qt5" -DQt5Svg_DIR="/opt/qt55/lib/cmake/Qt5Svg" -DQt5OpenGL_DIR="/opt/qt55/lib/cmake/Qt5OpenGL" -DCMAKE_CXX_FLAGS_RELEASE=-DCGAL_NDEBUG -DWITH_examples=ON -DWITH_demos=ON -DWITH_tests=ON .. - make - sudo make install &>/dev/null - cd .. diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index 58a6c67f42e..54e558ee7be 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -237,7 +238,7 @@ struct Depth_base { template class Lazy_rep : public Rep, public Depth_base { - Lazy_rep (const Lazy_rep&); // cannot be copied. + Lazy_rep (const Lazy_rep&) = delete; // cannot be copied. public: @@ -247,13 +248,15 @@ public: mutable ET *et; Lazy_rep () - : at(), et(NULL){} + : at(), et(nullptr){} - Lazy_rep (const AT& a) - : at(a), et(NULL){} + template + Lazy_rep (A&& a) + : at(std::forward(a)), et(nullptr){} - Lazy_rep (const AT& a, const ET& e) - : at(a), et(new ET(e)) {} + template + Lazy_rep (A&& a, E&& e) + : at(std::forward(a)), et(new ET(std::forward(e))) {} const AT& approx() const { @@ -332,8 +335,9 @@ class Lazy_rep_n : void update_exact() const { update_exact_helper(std::make_index_sequence{}); } - Lazy_rep_n(const AC& ac, const EC& ec, L const&...ll) : - Lazy_rep(ac(CGAL::approx(ll)...)), EC(ec), l(ll...) + template + Lazy_rep_n(const AC& ac, const EC& ec, LL&&...ll) : + Lazy_rep(ac(CGAL::approx(ll)...)), EC(ec), l(std::forward(ll)...) { this->set_depth(std::max({ -1, (int)CGAL::depth(ll)...}) + 1); } @@ -377,14 +381,23 @@ public: Lazy_rep_0() : Lazy_rep() {} - Lazy_rep_0(const AT& a, const ET& e) - : Lazy_rep(a, e) {} + template + Lazy_rep_0(A&& a, E&& e) + : Lazy_rep(std::forward(a), std::forward(e)) {} +#if 0 + // unused. Find a less ambiguous placeholder if necessary Lazy_rep_0(const AT& a, void*) : Lazy_rep(a) {} +#endif - Lazy_rep_0(const ET& e) - : Lazy_rep(E2A()(e), e) {} + // E2A()(e) and std::forward(e) could be evaluated in any order, but + // that's ok, "forward" itself does not modify e, it may only mark it as + // modifyable by the outer call, which is obviously sequenced after the inner + // call E2A()(e). + template + Lazy_rep_0(E&& e) + : Lazy_rep(E2A()(e), std::forward(e)) {} void print_dag(std::ostream& os, int level) const @@ -722,6 +735,11 @@ public : PTR = new Lazy_rep_0(e); } + Lazy(ET&& e) + { + PTR = new Lazy_rep_0(std::move(e)); + } + const AT& approx() const { return ptr()->approx(); } diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h index 1912ce7f214..c62f3bbfde4 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h @@ -211,8 +211,6 @@ struct Lazy_cartesian : typedef Lazy_construction_nt type; }; template struct Functor { - typedef typename Get_functor::type FA; - typedef typename Get_functor::type FE; typedef Lazy_construction2 type; }; template struct Functor { diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h index 643828d9733..831ec157762 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h @@ -311,7 +311,8 @@ operator>>(std::istream &is, Point_d & p) for(int i=0;i Date: Wed, 6 Feb 2019 14:49:17 +0100 Subject: [PATCH 11/56] CGAL requires C++14. --- Installation/cmake/modules/CGAL_SetupCGALDependencies.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Installation/cmake/modules/CGAL_SetupCGALDependencies.cmake b/Installation/cmake/modules/CGAL_SetupCGALDependencies.cmake index 9171c8a813d..4a7640ae3f2 100644 --- a/Installation/cmake/modules/CGAL_SetupCGALDependencies.cmake +++ b/Installation/cmake/modules/CGAL_SetupCGALDependencies.cmake @@ -101,6 +101,10 @@ function(CGAL_setup_CGAL_dependencies target) target_compile_definitions(${target} ${keyword} CGAL_TEST_SUITE=1) endif() + # CGAL now requires C++14. `decltype(auto)` is used as a marker of + # C++14. + target_compile_features(${target} ${keyword} cxx_decltype_auto) + use_CGAL_Boost_support(${target} ${keyword}) foreach(dir ${CGAL_INCLUDE_DIRS}) From cdf197e82db115f7393cc917459bf36e731707c5 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 6 Feb 2019 15:00:19 +0100 Subject: [PATCH 12/56] Misplaced \cgalModifBegin \cgalModifEnd --- Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h | 2 ++ Kernel_d/doc/Kernel_d/CGAL/Epick_d.h | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h index 6a58b594230..4cc88de7db7 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h @@ -4,6 +4,7 @@ namespace CGAL { /*! \ingroup PkgKernelDKernels +\cgalModifBegin A model for `Kernel_d`, minus `Kernel_d::Point_of_sphere_d`, that uses %Cartesian coordinates to represent the geometric objects. @@ -138,3 +139,4 @@ Construct_circumcenter_d construct_circumcenter_d_object(); Compute_squared_radius_d compute_squared_radius_d_object(); }; /* end Epeck_d */ } /* end namespace CGAL */ +/// \cgalModifEnd diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h index 9916144bf8f..92bc498016e 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h @@ -4,7 +4,6 @@ namespace CGAL { /*! \ingroup PkgKernelDKernels -\cgalModifBegin A model for `Kernel_d` that uses %Cartesian coordinates to represent the geometric objects. @@ -125,4 +124,3 @@ Construct_circumcenter_d construct_circumcenter_d_object(); Compute_squared_radius_d compute_squared_radius_d_object(); }; /* end Epick_d */ } /* end namespace CGAL */ -/// \cgalModifEnd From ba3bc8476f70b3cf4d3369319ec9d96380b8c4a9 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 6 Feb 2019 15:00:54 +0100 Subject: [PATCH 13/56] Fix automatic links --- Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h | 7 ++++--- Kernel_d/doc/Kernel_d/Kernel_d.txt | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h index 4cc88de7db7..3b34dab7a8b 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h @@ -16,10 +16,11 @@ This kernel supports construction of points from `double` %Cartesian coordinates. It provides exact geometric predicates and constructions. The geometric predicates are made exact without sacrificing speed thanks to the use of filters. The geometric constructions are made exact without sacrificing -speed thanks to a lazy mechanism, similar to `Epeck`. A construction creates an +speed thanks to a lazy mechanism, similar to +`Exact_predicates_exact_constructions_kernel`. A construction creates an approximate object, and stores a directed acyclic graph (DAG) of the operation and arguments used. When an operation needs more precision on an object than is -currently available, which should be rare, CGAL reconstructs exactly all the +currently available, which should be rare, %CGAL reconstructs exactly all the ancestors of the object and replaces this part of the graph with exact objects. This should be transparent for users, those details do not affect the functionality, but they can cause surprising running time where the costly part @@ -37,7 +38,7 @@ or `Dynamic_dimension_tag`. In the latter case, the dimension of the space is sp \attention Only the interfaces specific to this class are listed below. Refer to the concepts for the rest. -\attention Known bugs: the functor `Intersect_d` is not yet implemented. `Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Orientation_d` only works for points, not vectors. Constructing a `Point_d` with iterators is done lazily, see below. +\attention Known bugs: the functor `Kernel_d::Intersect_d` is not yet implemented. `Kernel_d::Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Kernel_d::Orientation_d` only works for points, not vectors. Constructing a `Point_d` with iterators is done lazily, see below. \attention This kernel requires the \ref thirdpartyEigen "Eigen" library. diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index 10531d1bc56..50c0d8f4a06 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -228,7 +228,7 @@ Note that it provides few interfaces in addition to those documented in the \subsection Kernel_dEpeckKernel Epeck_d Kernel The kernel `Epeck_d`, short for Exact Predicates Exact -Constructions Kernel is a kernel particularly useful when the dimension of +Constructions %Kernel is a kernel particularly useful when the dimension of the space is known at compile-time; The template parameter `DimensionTag` is then `Dimension_tag` where `d` is an integer representing the dimension. It may also be used with parameter `Dynamic_dimension_tag`, in which case the From 446edec0868d5a0e34db02c3fe80f28ed56f7351 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 6 Feb 2019 15:10:37 +0100 Subject: [PATCH 14/56] Replicate Laurent's patch from Epeck_d to Epick_d (same content) --- Kernel_d/doc/Kernel_d/CGAL/Epick_d.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h index 92bc498016e..947ea7b3c6d 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h @@ -26,7 +26,7 @@ or `Dynamic_dimension_tag`. In the latter case, the dimension of the space is sp \attention Only the interfaces specific to this class are listed below. Refer to the concepts for the rest. -\attention Known bugs: the functor `Intersect_d` is not yet implemented. `Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Orientation_d` only works for points, not vectors. +\attention Known bugs: the functor `Kernel_d::Intersect_d` is not yet implemented. `Kernel_d::Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Kernel_d::Orientation_d` only works for points, not vectors. \attention This kernel requires the \ref thirdpartyEigen "Eigen" library. From 7c5a55d8a8d06874296f4ebeedc2eb76008f2fe0 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 6 Feb 2019 15:13:14 +0100 Subject: [PATCH 15/56] Replicate Laurent's patch from Epeck_d to Epick_d (same content) --- Kernel_d/doc/Kernel_d/Kernel_d.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Kernel_d/doc/Kernel_d/Kernel_d.txt b/Kernel_d/doc/Kernel_d/Kernel_d.txt index 50c0d8f4a06..2808516bb04 100644 --- a/Kernel_d/doc/Kernel_d/Kernel_d.txt +++ b/Kernel_d/doc/Kernel_d/Kernel_d.txt @@ -210,7 +210,7 @@ type `LinearAlgebra`. \subsection Kernel_dEpickKernel Epick_d Kernel The kernel `Epick_d`, short for Exact Predicates Inexact -Constructions Kernel is a kernel particularly useful when the dimension of +Constructions %Kernel is a kernel particularly useful when the dimension of the space is known at compile-time; The template parameter `DimensionTag` is then `Dimension_tag` where `d` is an integer representing the dimension. It may also be used with parameter `Dynamic_dimension_tag`, in which case the From 0b60bb191c31f934f60e9223618d2289672725bb Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 6 Feb 2019 15:39:16 +0100 Subject: [PATCH 16/56] Compute_squared_radius_d gives a FT, not a Point_d. --- Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h | 2 +- Kernel_d/doc/Kernel_d/CGAL/Epick_d.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h index 3b34dab7a8b..d2f3b9ec2ca 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h @@ -123,7 +123,7 @@ public: \tparam ForwardIterator has `Epeck_d::Point_d` as value type. */ template -Point_d operator()(ForwardIterator first, ForwardIterator last); +FT operator()(ForwardIterator first, ForwardIterator last); }; /*! \cgalModels `Kernel_d::Side_of_bounded_sphere_d` */ diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h index 947ea7b3c6d..8325f349e0a 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epick_d.h @@ -107,7 +107,7 @@ public: \tparam ForwardIterator has `Epick_d::Point_d` as value type. */ template -Point_d operator()(ForwardIterator first, ForwardIterator last); +FT operator()(ForwardIterator first, ForwardIterator last); }; /*! \cgalModels `Kernel_d::Side_of_bounded_sphere_d` */ From 65fcf810f5fe259c0cf7e68ed246a9c54b45163c Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 6 Feb 2019 15:52:05 +0100 Subject: [PATCH 17/56] Symmetrize HasModel/IsModel for Epeck_d. --- .../doc/Spatial_searching/Concepts/RangeSearchTraits.h | 1 + Spatial_searching/doc/Spatial_searching/Concepts/SearchTraits.h | 1 + .../doc/Triangulation/Concepts/DelaunayTriangulationTraits.h | 1 + .../doc/Triangulation/Concepts/RegularTriangulationTraits.h | 1 + Triangulation/doc/Triangulation/Concepts/TriangulationTraits.h | 1 + 5 files changed, 5 insertions(+) diff --git a/Spatial_searching/doc/Spatial_searching/Concepts/RangeSearchTraits.h b/Spatial_searching/doc/Spatial_searching/Concepts/RangeSearchTraits.h index 56281b811fc..e0af4b8a2a7 100644 --- a/Spatial_searching/doc/Spatial_searching/Concepts/RangeSearchTraits.h +++ b/Spatial_searching/doc/Spatial_searching/Concepts/RangeSearchTraits.h @@ -11,6 +11,7 @@ range search queries in a model of `SpatialTree`. \cgalHasModel `CGAL::Cartesian_d` \cgalHasModel `CGAL::Homogeneous_d` \cgalHasModel `CGAL::Epick_d` +\cgalHasModel `CGAL::Epeck_d` \cgalHasModel `CGAL::Search_traits_2` \cgalHasModel `CGAL::Search_traits_3` diff --git a/Spatial_searching/doc/Spatial_searching/Concepts/SearchTraits.h b/Spatial_searching/doc/Spatial_searching/Concepts/SearchTraits.h index 2abebf75c0b..ae9f9d0363f 100644 --- a/Spatial_searching/doc/Spatial_searching/Concepts/SearchTraits.h +++ b/Spatial_searching/doc/Spatial_searching/Concepts/SearchTraits.h @@ -8,6 +8,7 @@ parameter of the search classes. \cgalHasModel `CGAL::Cartesian_d` \cgalHasModel `CGAL::Homogeneous_d` \cgalHasModel `CGAL::Epick_d` +\cgalHasModel `CGAL::Epeck_d` \cgalHasModel `CGAL::Search_traits_2` \cgalHasModel `CGAL::Search_traits_3` \cgalHasModel `CGAL::Search_traits_d` diff --git a/Triangulation/doc/Triangulation/Concepts/DelaunayTriangulationTraits.h b/Triangulation/doc/Triangulation/Concepts/DelaunayTriangulationTraits.h index f5d6345384c..65aa17e3478 100644 --- a/Triangulation/doc/Triangulation/Concepts/DelaunayTriangulationTraits.h +++ b/Triangulation/doc/Triangulation/Concepts/DelaunayTriangulationTraits.h @@ -10,6 +10,7 @@ a Delaunay triangulation. It corresponds to the first template parameter of the \cgalRefines `TriangulationTraits` \cgalHasModel `CGAL::Epick_d` +\cgalHasModel `CGAL::Epeck_d` \sa `TriangulationTraits` */ diff --git a/Triangulation/doc/Triangulation/Concepts/RegularTriangulationTraits.h b/Triangulation/doc/Triangulation/Concepts/RegularTriangulationTraits.h index ca0e3a0d9cd..265c25171ba 100644 --- a/Triangulation/doc/Triangulation/Concepts/RegularTriangulationTraits.h +++ b/Triangulation/doc/Triangulation/Concepts/RegularTriangulationTraits.h @@ -10,6 +10,7 @@ a regular triangulation. It corresponds to the first template parameter of the c \cgalRefines `TriangulationTraits` \cgalHasModel `CGAL::Epick_d` +\cgalHasModel `CGAL::Epeck_d` \sa `TriangulationTraits` */ diff --git a/Triangulation/doc/Triangulation/Concepts/TriangulationTraits.h b/Triangulation/doc/Triangulation/Concepts/TriangulationTraits.h index 9791e86d42f..bba42a5dcff 100644 --- a/Triangulation/doc/Triangulation/Concepts/TriangulationTraits.h +++ b/Triangulation/doc/Triangulation/Concepts/TriangulationTraits.h @@ -15,6 +15,7 @@ then optimized using spatial sorting. This is not required if the points are inserted one by one. \cgalHasModel `CGAL::Epick_d` +\cgalHasModel `CGAL::Epeck_d` \sa `DelaunayTriangulationTraits` */ From 4a2f14f6491984f1fcc177383df96fbfcf3e5e13 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 6 Feb 2019 15:54:08 +0100 Subject: [PATCH 18/56] Symmetrize HasModel/IsModel for Epeck_d. --- Kernel_d/doc/Kernel_d/Concepts/Kernel_d.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Kernel_d/doc/Kernel_d/Concepts/Kernel_d.h b/Kernel_d/doc/Kernel_d/Concepts/Kernel_d.h index 121402955d7..4de476b3f58 100644 --- a/Kernel_d/doc/Kernel_d/Concepts/Kernel_d.h +++ b/Kernel_d/doc/Kernel_d/Concepts/Kernel_d.h @@ -21,6 +21,7 @@ replacing operators, especially for equality testing. \cgalHasModel `CGAL::Cartesian_d` \cgalHasModel `CGAL::Homogeneous_d` \cgalHasModel `CGAL::Epick_d` +\cgalHasModel `CGAL::Epeck_d` */ class Kernel_d { public: From 49b3f3648fa80995034e7625a9b1054b0a8f8b57 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 7 Feb 2019 11:04:03 +0100 Subject: [PATCH 19/56] Try to upgrade Travis configuration to Xenial --- .travis.yml | 4 ++-- .travis/template.txt | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 08fff7246ba..3ef035a8021 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: cpp -dist: trusty +dist: xenial sudo: required git: depth: 3 @@ -63,7 +63,7 @@ before_script: - sudo chmod +x /usr/bin/doxygen - mkdir -p build - cd build -- cmake -DCMAKE_CXX_FLAGS="-std=c++1y" -DCGAL_HEADER_ONLY=ON -DQt5_DIR="/opt/qt55/lib/cmake/Qt5" -DQt5Svg_DIR="/opt/qt55/lib/cmake/Qt5Svg" -DQt5OpenGL_DIR="/opt/qt55/lib/cmake/Qt5OpenGL" -DCMAKE_CXX_FLAGS_RELEASE=-DCGAL_NDEBUG -DWITH_examples=ON -DWITH_demos=ON -DWITH_tests=ON .. +- cmake -DCMAKE_CXX_FLAGS="-std=c++1y" -DCGAL_HEADER_ONLY=ON -DQt5_DIR="/opt/qt55/lib/cmake/Qt5" -DQt5Svg_DIR="/opt/qt55/lib/cmake/Qt5Svg" -DQt5OpenGL_DIR="/opt/qt55/lib/cmake/Qt5OpenGL" -DCMAKE_CXX_FLAGS_RELEASE=-DCGAL_NDEBUG -DWITH_examples=ON -DWITH_demos=ON -DWITH_tests=ON .. - make - sudo make install &>/dev/null - cd .. diff --git a/.travis/template.txt b/.travis/template.txt index 1632aa16cbf..bed69a294d4 100644 --- a/.travis/template.txt +++ b/.travis/template.txt @@ -1,5 +1,5 @@ language: cpp -dist: trusty +dist: xenial sudo: required git: depth: 3 @@ -19,7 +19,7 @@ before_script: - sudo chmod +x /usr/bin/doxygen - mkdir -p build - cd build -- cmake -DCMAKE_CXX_FLAGS="-std=c++11" -DCGAL_HEADER_ONLY=ON -DQt5_DIR="/opt/qt55/lib/cmake/Qt5" -DQt5Svg_DIR="/opt/qt55/lib/cmake/Qt5Svg" -DQt5OpenGL_DIR="/opt/qt55/lib/cmake/Qt5OpenGL" -DCMAKE_CXX_FLAGS_RELEASE=-DCGAL_NDEBUG -DWITH_examples=ON -DWITH_demos=ON -DWITH_tests=ON .. +- cmake -DCMAKE_CXX_FLAGS="-std=c++1y" -DCGAL_HEADER_ONLY=ON -DQt5_DIR="/opt/qt55/lib/cmake/Qt5" -DQt5Svg_DIR="/opt/qt55/lib/cmake/Qt5Svg" -DQt5OpenGL_DIR="/opt/qt55/lib/cmake/Qt5OpenGL" -DCMAKE_CXX_FLAGS_RELEASE=-DCGAL_NDEBUG -DWITH_examples=ON -DWITH_demos=ON -DWITH_tests=ON .. - make - sudo make install &>/dev/null - cd .. From 5ef0977d67cc5d0549deeaf158ba0bb0a276cef9 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 12:34:17 +0100 Subject: [PATCH 20/56] Use Vector_dimension on vectors --- Filtered_kernel/include/CGAL/Lazy.h | 6 ++--- .../NewKernel_d/function_objects_cartesian.h | 25 ++++++++----------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index 54e558ee7be..08e51fec51c 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -124,11 +124,11 @@ templateinline std::enable_if_t::value, T> approx(T){r templateinline std::enable_if_t::value, unsigned> depth(T){return 0;} // For an iterator, exact/approx applies to the objects it points to -template ::value>> +template ::value>> auto exact(T const& t) {return make_transforming_iterator(t,[](auto const&u){return CGAL::exact(u);});} -template ::value>> +template ::value>> auto approx(T const& t) {return make_transforming_iterator(t,[](auto const&u){return CGAL::approx(u);});} -template ::value>> +template ::value>> unsigned depth(T const& t) {return 1;} // FIXME: depth(*t) would be better when t is valid, but not for end iterators, and the true answer would iterate on the range, but we can't do that with only one iterator... We need to replace iterators with ranges to solve that. #ifdef CGAL_LAZY_KERNEL_DEBUG diff --git a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h index 94bd1e2ab76..0d41eb59707 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h @@ -208,8 +208,7 @@ template struct Orientation_of_vectors : private Store_kernel { template result_type operator()(Iter f, Iter e)const{ typename Get_functor::type c(this->kernel()); - typename Get_functor::type vd(this->kernel()); - // FIXME: Uh? Using it on a vector ?! + typename Get_functor::type vd(this->kernel()); Vector const& v0=*f; int d=vd(v0); Matrix m(d,d); @@ -241,7 +240,7 @@ template struct Orientation_of_vectors : private Store_kernel { }; } -CGAL_KD_DEFAULT_FUNCTOR(Orientation_of_vectors_tag,(CartesianDKernelFunctors::Orientation_of_vectors),(Vector_tag),(Point_dimension_tag,Compute_vector_cartesian_coordinate_tag)); +CGAL_KD_DEFAULT_FUNCTOR(Orientation_of_vectors_tag,(CartesianDKernelFunctors::Orientation_of_vectors),(Vector_tag),(Vector_dimension_tag,Compute_vector_cartesian_coordinate_tag)); namespace CartesianDKernelFunctors { template struct Linear_rank : private Store_kernel { @@ -255,11 +254,10 @@ template struct Linear_rank : private Store_kernel { template result_type operator()(Iter f, Iter e)const{ typename Get_functor::type c(this->kernel()); - typename Get_functor::type vd(this->kernel()); + typename Get_functor::type vd(this->kernel()); std::ptrdiff_t n=std::distance(f,e); if (n==0) return 0; Vector const& v0 = *f; - // FIXME: Uh? Using it on a vector ?! int d=vd(v0); Matrix m(d,n); for(int j=0;j struct Linear_rank : private Store_kernel { }; } -CGAL_KD_DEFAULT_FUNCTOR(Linear_rank_tag,(CartesianDKernelFunctors::Linear_rank),(Vector_tag),(Point_dimension_tag,Compute_vector_cartesian_coordinate_tag)); +CGAL_KD_DEFAULT_FUNCTOR(Linear_rank_tag,(CartesianDKernelFunctors::Linear_rank),(Vector_tag),(Vector_dimension_tag,Compute_vector_cartesian_coordinate_tag)); namespace CartesianDKernelFunctors { template struct Linearly_independent : private Store_kernel { @@ -286,9 +284,8 @@ template struct Linearly_independent : private Store_kernel { template result_type operator()(Iter f, Iter e)const{ - typename Get_functor::type vd(this->kernel()); + typename Get_functor::type vd(this->kernel()); std::ptrdiff_t n=std::distance(f,e); - // FIXME: Uh? Using it on a vector ?! int d=vd(*f); if (n>d) return false; typename Get_functor::type lr(this->kernel()); @@ -297,7 +294,7 @@ template struct Linearly_independent : private Store_kernel { }; } -CGAL_KD_DEFAULT_FUNCTOR(Linearly_independent_tag,(CartesianDKernelFunctors::Linearly_independent),(Vector_tag),(Point_dimension_tag,Linear_rank_tag)); +CGAL_KD_DEFAULT_FUNCTOR(Linearly_independent_tag,(CartesianDKernelFunctors::Linearly_independent),(Vector_tag),(Vector_dimension_tag,Linear_rank_tag)); namespace CartesianDKernelFunctors { template struct Contained_in_linear_hull : private Store_kernel { @@ -311,10 +308,9 @@ template struct Contained_in_linear_hull : private Store_kernel { template result_type operator()(Iter f, Iter e,V const&w)const{ typename Get_functor::type c(this->kernel()); - typename Get_functor::type vd(this->kernel()); + typename Get_functor::type vd(this->kernel()); std::ptrdiff_t n=std::distance(f,e); if (n==0) return false; - // FIXME: Uh? Using it on a vector ?! int d=vd(w); Matrix m(d,n+1); for(int i=0; f!=e; ++f,++i){ @@ -336,7 +332,7 @@ template struct Contained_in_linear_hull : private Store_kernel { }; } -CGAL_KD_DEFAULT_FUNCTOR(Contained_in_linear_hull_tag,(CartesianDKernelFunctors::Contained_in_linear_hull),(Vector_tag),(Point_dimension_tag,Compute_vector_cartesian_coordinate_tag)); +CGAL_KD_DEFAULT_FUNCTOR(Contained_in_linear_hull_tag,(CartesianDKernelFunctors::Contained_in_linear_hull),(Vector_tag),(Vector_dimension_tag,Compute_vector_cartesian_coordinate_tag)); namespace CartesianDKernelFunctors { template struct Affine_rank : private Store_kernel { @@ -464,12 +460,11 @@ template struct Linear_base : private Store_kernel { template result_type operator()(Iter f, Iter e, Oter o)const{ typename Get_functor::type c(this->kernel()); - typename Get_functor::type vd(this->kernel()); + typename Get_functor::type vd(this->kernel()); typename Get_functor >::type cv(this->kernel()); std::ptrdiff_t n=std::distance(f,e); if (n==0) return; Vector const& v0 = *f; - // FIXME: Uh? Using it on a vector ?! int d=vd(v0); Matrix m(d,n); for(int j=0;j struct Linear_base : private Store_kernel { }; } -CGAL_KD_DEFAULT_FUNCTOR(Linear_base_tag,(CartesianDKernelFunctors::Linear_base),(Vector_tag),(Point_dimension_tag,Compute_vector_cartesian_coordinate_tag)); +CGAL_KD_DEFAULT_FUNCTOR(Linear_base_tag,(CartesianDKernelFunctors::Linear_base),(Vector_tag),(Vector_dimension_tag,Compute_vector_cartesian_coordinate_tag)); #if 0 namespace CartesianDKernelFunctors { From 530238db1a2f0bd076b454654326d821c5a5484d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 14:54:30 +0100 Subject: [PATCH 21/56] Remove some C++98 code to unclutter the files a bit. --- .../CGAL/NewKernel_d/Cartesian_LA_functors.h | 38 --------- .../CGAL/NewKernel_d/Cartesian_filter_NT.h | 26 ------ .../CGAL/NewKernel_d/Define_kernel_types.h | 5 -- .../CGAL/NewKernel_d/Filtered_predicate2.h | 29 ------- .../CGAL/NewKernel_d/Kernel_d_interface.h | 17 ---- .../include/CGAL/NewKernel_d/LA_eigen/LA.h | 6 +- .../CGAL/NewKernel_d/LA_eigen/constructors.h | 2 - .../NewKernel_d/Types/Aff_transformation.h | 13 --- .../include/CGAL/NewKernel_d/Types/Segment.h | 2 +- .../include/CGAL/NewKernel_d/functor_tags.h | 4 - NewKernel_d/include/CGAL/NewKernel_d/utils.h | 85 +------------------ NewKernel_d/include/CGAL/argument_swaps.h | 19 ----- .../include/CGAL/iterator_from_indices.h | 4 - .../include/CGAL/transforming_iterator.h | 5 -- .../include/CGAL/transforming_pair_iterator.h | 5 -- NewKernel_d/include/CGAL/typeset.h | 43 ---------- 16 files changed, 6 insertions(+), 297 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h index b15b44fe3ec..da49afa43c2 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h @@ -31,35 +31,9 @@ namespace CGAL { namespace CartesianDVectorBase { -#ifndef CGAL_CXX11 -namespace internal { -template struct Construct_LA_vector_ { - struct Never_use {}; - void operator()(Never_use)const; -}; -#define CGAL_CODE(Z,N,_) template struct Construct_LA_vector_ > { \ - typedef typename R::Constructor Constructor; \ - typedef typename Get_type::type RT; \ - typedef typename R::Vector_ result_type; \ - result_type operator() \ - (BOOST_PP_ENUM_PARAMS(N,RT const& t)) const { \ - return typename Constructor::Values()(BOOST_PP_ENUM_PARAMS(N,t)); \ - } \ - result_type operator() \ - (BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(N),RT const& t)) const { \ - return typename Constructor::Values_divide()(t##N,BOOST_PP_ENUM_PARAMS(N,t)); \ - } \ - }; -BOOST_PP_REPEAT_FROM_TO(2, 11, CGAL_CODE, _ ) -#undef CGAL_CODE -} -#endif template struct Construct_LA_vector : private Store_kernel -#ifndef CGAL_CXX11 -, public internal::Construct_LA_vector_ -#endif { //CGAL_FUNCTOR_INIT_IGNORE(Construct_LA_vector) CGAL_FUNCTOR_INIT_STORE(Construct_LA_vector) @@ -87,12 +61,9 @@ template struct Construct_LA_vector result_type operator()(result_type const& v)const{ return v; } -#ifdef CGAL_CXX11 result_type operator()(result_type&& v)const{ return std::move(v); } -#endif -#ifdef CGAL_CXX11 template typename std::enable_if::value && boost::is_same, Dimension>::value, @@ -108,9 +79,6 @@ template struct Construct_LA_vector operator()(U&&...u)const{ return Apply_to_last_then_rest()(typename Constructor::Values_divide(),std::forward(u)...); } -#else - using internal::Construct_LA_vector_::operator(); -#endif template inline typename boost::enable_if,result_type>::type operator() (Iter f,Iter g,Cartesian_tag t)const @@ -178,13 +146,7 @@ template struct Compute_cartesian_coordinate { typedef typename R::Vector_ first_argument_type; typedef int second_argument_type; typedef Tag_true Is_exact; -#ifdef CGAL_CXX11 typedef decltype(std::declval()[0]) result_type; -#else - typedef RT const& result_type; - // RT const& doesn't work with some LA (Eigen2 for instance) so we - // should use plain RT or find a way to detect this. -#endif result_type operator()(first_argument_type const& v,int i)const{ return v[i]; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_NT.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_NT.h index d4219348199..99144377986 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_NT.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_NT.h @@ -49,7 +49,6 @@ struct Cartesian_filter_NT : public Base_ type(Cartesian_filter_NT const&k):p1(reinterpret_cast(k)),p2(reinterpret_cast(k)){} //FIXME: if predicate's constructor takes a kernel as argument, how do we translate that? reinterpret_cast is really ugly and possibly unsafe. -#ifdef CGAL_CXX11 template result_type operator()(U&&...u)const{ { Protect_FPU_rounding p; @@ -60,31 +59,6 @@ struct Cartesian_filter_NT : public Base_ } return p2(std::forward(u)...); } -#else - result_type operator()()const{ // does it make sense to have 0 argument? - { - Protect_FPU_rounding p; - try { - typename P1::result_type res=p1(); - if(is_certain(res)) return get_certain(res); - } catch (Uncertain_conversion_exception&) {} - } - return p2(); - } -#define CGAL_CODE(Z,N,_) template result_type operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t))const{ \ - { \ - Protect_FPU_rounding p; \ - try { \ - typename P1::result_type res=p1(BOOST_PP_ENUM_PARAMS(N,t)); \ - if(is_certain(res)) return get_certain(res); \ - } catch (Uncertain_conversion_exception&) {} \ - } \ - return p2(BOOST_PP_ENUM_PARAMS(N,t)); \ - } - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE - -#endif }; }; }; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Define_kernel_types.h b/NewKernel_d/include/CGAL/NewKernel_d/Define_kernel_types.h index 92f39a7e842..74df9d5b232 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Define_kernel_types.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Define_kernel_types.h @@ -23,11 +23,6 @@ #include #include #include -#ifdef CGAL_CXX11 -#include -#else -#include -#endif namespace CGAL { namespace internal { diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h b/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h index 920a7d70735..1fff3e19a49 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h @@ -81,7 +81,6 @@ public: : ep(k.exact_kernel()), ap(k.approximate_kernel()), c2e(k,k.exact_kernel()), c2a(k,k.approximate_kernel()) {} -#ifdef CGAL_CXX11 template result_type operator()(Args&&... args) const @@ -103,34 +102,6 @@ public: Protect_FPU_rounding p(CGAL_FE_TONEAREST); return ep(c2e(std::forward(args))...); } -#else - -#define CGAL_VAR(Z,N,C) C(a##N) -#define CGAL_CODE(Z,N,_) \ - template \ - result_type \ - operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& a)) const \ - { \ - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \ - { \ - Protect_FPU_rounding p; \ - try \ - { \ - Ares res = ap(BOOST_PP_ENUM(N,CGAL_VAR,c2a)); \ - if (is_certain(res)) \ - return get_certain(res); \ - } \ - catch (Uncertain_conversion_exception&) {} \ - } \ - CGAL_BRANCH_PROFILER_BRANCH(tmp); \ - Protect_FPU_rounding p(CGAL_FE_TONEAREST); \ - return ep(BOOST_PP_ENUM(N,CGAL_VAR,c2e)); \ - } - BOOST_PP_REPEAT_FROM_TO(1, 10, CGAL_CODE, _ ) -#undef CGAL_CODE -#undef CGAL_VAR - -#endif }; } //namespace CGAL diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h index f6463dda4dd..9210cb07600 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h @@ -89,7 +89,6 @@ template struct Kernel_d_interface : public Base_ { Point_d operator()(Weighted_point_d const&wp)const{ return typename Get_functor::type(this->kernel())(wp); } -#ifdef CGAL_CXX11 Point_d operator()(Weighted_point_d &wp)const{ return typename Get_functor::type(this->kernel())(wp); } @@ -100,26 +99,10 @@ template struct Kernel_d_interface : public Base_ { return typename Get_functor::type(this->kernel())(std::move(wp)); } template -# if CGAL_CXX14 decltype(auto) -# else - Point_d -# endif operator()(T&&...t)const{ return CP(this->kernel())(std::forward(t)...); - //return CP(this->kernel())(t...); } -#else // not CGAL_CXX11 -# define CGAL_CODE(Z,N,_) template \ - Point_d operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t))const{ \ - return CP(this->kernel())(BOOST_PP_ENUM_PARAMS(N,t)); \ - } - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -# undef CGAL_CODE - Point_d operator()()const{ \ - return CP(this->kernel())(); \ - } -#endif // not CGAL_CXX11 }; typedef typename Get_functor >::type Construct_vector_d; typedef typename Get_functor >::type Construct_segment_d; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/LA.h b/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/LA.h index 57507b27815..b3d23ea32e3 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/LA.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/LA.h @@ -58,11 +58,7 @@ template struct LA_eigen { #if (EIGEN_WORLD_VERSION>=3) typedef NT const* Vector_const_iterator; #else - typedef Iterator_from_indices Vector_const_iterator; + typedef Iterator_from_indices Vector_const_iterator; #endif templatestatic Vector_const_iterator vector_begin(Vec_ const&a){ diff --git a/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h b/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h index 23c143891e5..f61f80a79f0 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h @@ -99,7 +99,6 @@ namespace CGAL { } }; -#ifdef CGAL_CXX11 struct Initializer_list { // Fix T==NT? template @@ -107,7 +106,6 @@ namespace CGAL { return Iterator()(l.size(),l.begin(),l.end()); } }; -#endif struct Values { #ifdef CGAL_CXX11 diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Aff_transformation.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Aff_transformation.h index f1da46fa1a2..cf0465bbcaa 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Aff_transformation.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Aff_transformation.h @@ -36,21 +36,8 @@ template struct Construct_aff_transformation { CGAL_FUNCTOR_INIT_IGNORE(Construct_aff_transformation) typedef R_ R; typedef typename Get_type::type result_type; -#ifdef CGAL_CXX11 template result_type operator()(T&&...)const{return result_type();} -#else - result_type operator()()const{ - return result_type(); - } -#define CGAL_CODE(Z,N,_) template \ - result_type operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const& BOOST_PP_INTERCEPT))const{ \ - return result_type(); \ - } - BOOST_PP_REPEAT_FROM_TO(1, 9, CGAL_CODE, _ ) -#undef CGAL_CODE - -#endif }; } CGAL_KD_DEFAULT_TYPE(Aff_transformation_tag,(CGAL::Aff_transformation),(),()); diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h index dc3047e05f2..cca4b3d6754 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h @@ -35,7 +35,7 @@ template class Segment { public: //typedef Segmentd Segment; #ifdef CGAL_CXX11 - //FIXME: don't forward directly, piecewise_constuct should call the point construction functor (I guess? or is it unnecessary?) + //FIXME: don't forward directly, piecewise_construct should call the point construction functor (I guess? or is it unnecessary?) template::type...>,std::tuple>::value>::type> Segment(U&&...u):data(std::forward(u)...){} #else diff --git a/NewKernel_d/include/CGAL/NewKernel_d/functor_tags.h b/NewKernel_d/include/CGAL/NewKernel_d/functor_tags.h index 3ed395c4403..58fbef78dd7 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/functor_tags.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/functor_tags.h @@ -22,10 +22,8 @@ #define CGAL_FUNCTOR_TAGS_H #include // for Null_tag #include -#ifdef CGAL_CXX11 #include #include -#endif #include #include #include @@ -42,10 +40,8 @@ namespace CGAL { : K::template Type {}; template struct Get_functor : K::template Functor {}; -#ifdef CGAL_CXX11 template using Type = typename Get_type::type; template using Functor = typename Get_functor::type; -#endif class Null_type {~Null_type();}; // no such object should be created diff --git a/NewKernel_d/include/CGAL/NewKernel_d/utils.h b/NewKernel_d/include/CGAL/NewKernel_d/utils.h index b4f44752983..fa4c043138a 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/utils.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/utils.h @@ -29,19 +29,12 @@ // http://lists.boost.org/boost-users/2014/11/83291.php #endif -#ifdef CGAL_CXX11 #include #include #define CGAL_FORWARDABLE(T) T&& #define CGAL_FORWARD(T,t) std::forward(t) #define CGAL_MOVE(t) std::move(t) #define CGAL_CONSTEXPR constexpr -#else -#define CGAL_FORWARDABLE(T) T const& -#define CGAL_FORWARD(T,t) t -#define CGAL_MOVE(t) t -#define CGAL_CONSTEXPR -#endif #include #include #include @@ -50,11 +43,7 @@ #include #include -#ifdef CGAL_CXX11 #define CGAL_BOOSTD std:: -#else -#define CGAL_BOOSTD boost:: -#endif namespace CGAL { namespace internal { @@ -81,17 +70,10 @@ struct Has_type_different_from // like std::forward, except for basic types where it does a cast, to // avoid issues with narrowing conversions -#ifdef CGAL_CXX11 template inline typename std::conditional::value&&std::is_arithmetic::type>::value,T,U&&>::type forward_safe(V&& u) { return std::forward(u); } -#else - template inline U const& forward_safe(U const& u) { - return u; - } -#endif -#ifdef CGAL_CXX11 template struct Constructible_from_each; template struct Constructible_from_each{ enum { value=std::is_convertible::value&&Constructible_from_each::value }; @@ -99,25 +81,12 @@ struct Has_type_different_from template struct Constructible_from_each{ enum { value=true }; }; -#else -// currently only used in C++0X code -#endif template struct Scale { -#ifndef CGAL_CXX11 - template struct result; - template struct result { - typedef FT type; - }; -#endif T const& scale; Scale(T const& t):scale(t){} template -#ifdef CGAL_CXX11 - auto operator()(FT&& x)const->decltype(scale*std::forward(x)) -#else - FT operator()(FT const& x)const -#endif + decltype(auto) operator()(FT&& x)const { return scale*CGAL_FORWARD(FT,x); } @@ -135,13 +104,9 @@ struct Has_type_different_from T const& scale; Divide(T const& t):scale(t){} template -#ifdef CGAL_CXX11 //FIXME: gcc complains for Gmpq - //auto operator()(FT&& x)const->decltype(Rational_traits().make_rational(std::forward(x),scale)) + //decltype(auto) operator()(FT&& x)const NT operator()(FT&& x)const -#else - NT operator()(FT const& x)const -#endif { return Rational_traits(). make_rational(CGAL_FORWARD(FT,x),scale); @@ -158,11 +123,7 @@ struct Has_type_different_from template < class Ret > struct multiplies { template -#ifdef CGAL_CXX11 - auto operator()(A&&a,B&&b)const->decltype(std::forward(a)*std::forward(b)) -#else - Ret operator()(A const& a, B const& b)const -#endif + decltype(auto) operator()(A&&a,B&&b)const { return CGAL_FORWARD(A,a)*CGAL_FORWARD(B,b); } @@ -170,27 +131,17 @@ struct Has_type_different_from template < class Ret > struct division { template -#ifdef CGAL_CXX11 - auto operator()(A&&a,B&&b)const->decltype(std::forward(a)/std::forward(b)) -#else - Ret operator()(A const& a, B const& b)const -#endif + decltype(auto) operator()(A&&a,B&&b)const { return CGAL_FORWARD(A,a)/CGAL_FORWARD(B,b); } }; -#ifdef CGAL_CXX11 using std::decay; -#else - template struct decay : boost::remove_cv::type> {}; -#endif template struct Type_copy_ref { typedef U type; }; template struct Type_copy_ref { typedef U& type; }; -#ifdef CGAL_CXX11 template struct Type_copy_ref { typedef U&& type; }; -#endif template struct Type_copy_cv { typedef U type; }; template struct Type_copy_cv { typedef U const type; }; template struct Type_copy_cv { typedef U volatile type; }; @@ -210,7 +161,6 @@ struct Has_type_different_from } }; -#ifdef CGAL_CXX11 template struct Indices{}; template struct Next_increasing_indices; template struct Next_increasing_indices > { @@ -232,39 +182,12 @@ struct Has_type_different_from return internal::do_call_on_tuple_elements(std::forward(f),std::move(t), typename N_increasing_indices::type()); } -#else -#define CGAL_VAR(Z,N,_) cpp0x::get(t) -#define CGAL_CODE(Z,N,_) template \ - inline Res call_on_tuple_elements(F const&f, \ - cpp0x::tuple const&t) { \ - return f(BOOST_PP_ENUM(N,CGAL_VAR,)); \ - } - template - inline Res call_on_tuple_elements(F const&f, cpp0x::tuple<>) { - return f(); - } -BOOST_PP_REPEAT_FROM_TO(1, 8, CGAL_CODE, _ ) -#undef CGAL_CODE -#undef CGAL_VAR -#endif template struct Factory { typedef A result_type; -#ifdef CGAL_CXX11 template result_type operator()(U&&...u)const{ return A(std::forward(u)...); } -#else - result_type operator()()const{ - return A(); - } -#define CGAL_CODE(Z,N,_) template \ - result_type operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ - return A(BOOST_PP_ENUM_PARAMS(N,u)); \ - } -BOOST_PP_REPEAT_FROM_TO(1, 8, CGAL_CODE, _ ) -#undef CGAL_CODE -#endif }; } diff --git a/NewKernel_d/include/CGAL/argument_swaps.h b/NewKernel_d/include/CGAL/argument_swaps.h index b23e3b6d1dc..1ebef4de555 100644 --- a/NewKernel_d/include/CGAL/argument_swaps.h +++ b/NewKernel_d/include/CGAL/argument_swaps.h @@ -30,9 +30,6 @@ #endif namespace CGAL { - -#ifdef CGAL_CXX11 - namespace internal { template struct Apply_to_last_then_rest_; @@ -55,10 +52,8 @@ struct Apply_to_last_then_rest_<0,F,T,U...> { return std::forward(f)(std::forward(t), std::forward(u)...); } }; - } // namespace internal - struct Apply_to_last_then_rest { template inline typename internal::Apply_to_last_then_rest_::result_type @@ -70,20 +65,6 @@ struct Apply_to_last_then_rest { } }; -#else // CGAL_CXX11 - -struct Apply_to_last_then_rest { -#define CGAL_CODE(Z,N,_) template \ - typename boost::result_of::type \ - operator()(F const&f, BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t), T const&t) const { \ - return f(t,BOOST_PP_ENUM_PARAMS(N,t)); \ - } - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE -}; - -#endif // CGAL_CXX11 - } // namespace CGAL #endif // CGAL_ARGUMENT_SWAPS_H diff --git a/NewKernel_d/include/CGAL/iterator_from_indices.h b/NewKernel_d/include/CGAL/iterator_from_indices.h index 895a5f47916..f79a3e89bf2 100644 --- a/NewKernel_d/include/CGAL/iterator_from_indices.h +++ b/NewKernel_d/include/CGAL/iterator_from_indices.h @@ -33,11 +33,7 @@ struct Default_coordinate_access { //TODO: default type for Value_: typename same_cv::type::value_type>::type template ()[0]) -#else - Value_& -#endif , class Coord_access = Default_coordinate_access > class Iterator_from_indices diff --git a/NewKernel_d/include/CGAL/transforming_iterator.h b/NewKernel_d/include/CGAL/transforming_iterator.h index 5140df7a3e6..107a42e8e87 100644 --- a/NewKernel_d/include/CGAL/transforming_iterator.h +++ b/NewKernel_d/include/CGAL/transforming_iterator.h @@ -62,12 +62,7 @@ class transforming_iterator_helper typedef std::iterator_traits Iter_traits; typedef typename Iter_traits::reference Iter_ref; typedef typename Default::Get()(std::declval())) -#else - typename boost::result_of::type - // should be reference instead of value_type -#endif >::type reference_; typedef typename Default::Get::type>::type>::type value_type; diff --git a/NewKernel_d/include/CGAL/transforming_pair_iterator.h b/NewKernel_d/include/CGAL/transforming_pair_iterator.h index 1f2b3033642..8bc7d824d1f 100644 --- a/NewKernel_d/include/CGAL/transforming_pair_iterator.h +++ b/NewKernel_d/include/CGAL/transforming_pair_iterator.h @@ -53,12 +53,7 @@ class transforming_pair_iterator_helper ::type iterator_category; typedef typename Default::Get()(std::declval::reference>(),std::declval::reference>())) -#else - typename boost::result_of::value_type,typename std::iterator_traits::value_type)>::type - // should be reference instead of value_type -#endif >::type reference; typedef typename Default::Get::type>::type>::type value_type; diff --git a/NewKernel_d/include/CGAL/typeset.h b/NewKernel_d/include/CGAL/typeset.h index 1bba56618e9..ba6a04ec37f 100644 --- a/NewKernel_d/include/CGAL/typeset.h +++ b/NewKernel_d/include/CGAL/typeset.h @@ -21,17 +21,12 @@ #ifndef CGAL_TYPESET_H #define CGAL_TYPESET_H #include -#ifdef CGAL_CXX11 #include -#else -#include -#endif // Sometimes using tuple just to list types is overkill (takes forever to // instantiate). namespace CGAL { -#ifdef CGAL_CXX11 template struct typeset; template struct typeset { typedef H head; @@ -55,33 +50,6 @@ namespace CGAL { template using contains = std::false_type; template using add = typeset; }; -#else - template struct typeset; - template, void, typeset >::type > - struct typeset { - typedef typeset type; - typedef H head; - typedef T tail; - template struct contains : - boost::mpl::if_,boost::true_type,typename tail::template contains >::type - {}; - template struct add; - //boost::mpl::if_,typeset,typeset >::type - }; - template<> struct typeset<> { - typedef typeset type; - template struct contains : boost::false_type {}; - template struct add : CGAL::typeset {}; - }; - - template - template - struct typeset::add : typeset::type> {}; - template - template - struct typeset::add : typeset {}; -#endif template struct typeset_union_ : typeset_union_::type, typename T2::tail> @@ -93,26 +61,15 @@ namespace CGAL { typedef typename T1::head H; typedef typename typeset_intersection_::type U; typedef typename -#ifdef CGAL_CXX11 std::conditional::value, -#else - boost::mpl::if_, -#endif typename U::template add::type, U>::type type; }; template struct typeset_intersection_,T> : typeset<> {}; -#ifdef CGAL_CXX11 template using typeset_union = typename typeset_union_::type; template using typeset_intersection = typename typeset_intersection_::type; -#else - template - struct typeset_union : typeset_union_::type {}; - template - struct typeset_intersection : typeset_intersection_::type {}; -#endif } #endif From cde81908d4f61d748775cd26f5a224309bc48951 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 15:18:09 +0100 Subject: [PATCH 22/56] Remove some C++98 code to unclutter the files a bit. --- .../NewKernel_d/Kernel_object_converter.h | 3 +- .../include/CGAL/NewKernel_d/Vector/array.h | 27 ------ .../include/CGAL/NewKernel_d/Vector/vector.h | 31 ------- .../CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h | 59 ------------- .../CGAL/NewKernel_d/Wrapper/Hyperplane_d.h | 29 ------- .../CGAL/NewKernel_d/Wrapper/Point_d.h | 32 ------- .../CGAL/NewKernel_d/Wrapper/Ref_count_obj.h | 31 ------- .../CGAL/NewKernel_d/Wrapper/Segment_d.h | 29 ------- .../CGAL/NewKernel_d/Wrapper/Sphere_d.h | 29 ------- .../CGAL/NewKernel_d/Wrapper/Vector_d.h | 32 ------- .../NewKernel_d/Wrapper/Weighted_point_d.h | 29 ------- .../NewKernel_d/function_objects_cartesian.h | 85 ------------------- 12 files changed, 1 insertion(+), 415 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h index 152b4f47eda..3022ec4997a 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h @@ -42,7 +42,7 @@ struct Point_converter_help { return cp(conv(i(p,Begin_tag())),conv(i(p,End_tag()))); } }; -#ifdef CGAL_CXX11 + // This doesn't seem so useful, the compiler should be able to handle // the iterators just as efficiently. template @@ -60,7 +60,6 @@ struct Point_converter_help,K1,K2> { return help(typename N_increasing_indices::type(),k1,k2,conv,p); } }; -#endif } template struct KO_converter : internal::Point_converter_help diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h b/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h index f600134e0e4..71e17313ced 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h @@ -105,48 +105,21 @@ template struct Array_vector { }; struct Values { -#ifdef CGAL_CXX11 template Vector operator()(U&&...u) const { static_assert(sizeof...(U)<=d_,"too many arguments"); Vector a={{forward_safe(u)...}}; return a; } -#else - -#define CGAL_CODE(Z,N,_) Vector operator()(BOOST_PP_ENUM_PARAMS(N,NT const& t)) const { \ - CGAL_assertion(N<=d_); \ - Vector a={{BOOST_PP_ENUM_PARAMS(N,t)}}; \ - return a; \ -} -BOOST_PP_REPEAT_FROM_TO(1, 11, CGAL_CODE, _ ) -#undef CGAL_CODE - -#endif }; struct Values_divide { -#ifdef CGAL_CXX11 template Vector operator()(H const& h,U&&...u) const { static_assert(sizeof...(U)<=d_,"too many arguments"); Vector a={{Rational_traits().make_rational(std::forward(u),h)...}}; return a; } -#else - -#define CGAL_VAR(Z,N,_) Rational_traits().make_rational( t##N , h) -#define CGAL_CODE(Z,N,_) template Vector \ - operator()(H const&h, BOOST_PP_ENUM_PARAMS(N,NT const& t)) const { \ - CGAL_assertion(N<=d_); \ - Vector a={{BOOST_PP_ENUM(N,CGAL_VAR,_)}}; \ - return a; \ - } - BOOST_PP_REPEAT_FROM_TO(1, 11, CGAL_CODE, _ ) -#undef CGAL_CODE -#undef CGAL_VAR - -#endif }; }; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h b/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h index 1c173a13901..1f2023c0785 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h @@ -100,31 +100,15 @@ template struct Vector_vector { #endif struct Values { -#ifdef CGAL_CXX11 template Vector operator()(U&&...u) const { //TODO: check the right number of {}, g++ accepts one and two Vector a={forward_safe(u)...}; return a; } -#else - -#define CGAL_VAR(Z,N,_) a.push_back(t##N); -#define CGAL_CODE(Z,N,_) Vector operator()(BOOST_PP_ENUM_PARAMS(N,NT const& t)) const { \ - Vector a; \ - a.reserve(N); \ - BOOST_PP_REPEAT(N,CGAL_VAR,) \ - return a; \ -} -BOOST_PP_REPEAT_FROM_TO(1, 11, CGAL_CODE, _ ) -#undef CGAL_CODE -#undef CGAL_VAR - -#endif }; struct Values_divide { -#ifdef CGAL_CXX11 template Vector operator()(H const&h,U&&...u) const { //TODO: do we want to cast at some point? @@ -133,21 +117,6 @@ BOOST_PP_REPEAT_FROM_TO(1, 11, CGAL_CODE, _ ) Vector a={Rational_traits().make_rational(std::forward(u),h)...}; return a; } -#else - -#define CGAL_VAR(Z,N,_) a.push_back(Rational_traits().make_rational( t##N ,h)); -#define CGAL_CODE(Z,N,_) template Vector \ - operator()(H const&h, BOOST_PP_ENUM_PARAMS(N,NT const& t)) const { \ - Vector a; \ - a.reserve(N); \ - BOOST_PP_REPEAT(N,CGAL_VAR,) \ - return a; \ - } - BOOST_PP_REPEAT_FROM_TO(1, 11, CGAL_CODE, _ ) -#undef CGAL_CODE -#undef CGAL_VAR - -#endif }; }; typedef typename Vector::const_iterator Vector_const_iterator; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h index a97529bf6e7..fb769112a4e 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h @@ -145,29 +145,9 @@ struct Cartesian_wrap : public Base_ B b; type(){} type(Self const&k):b(k){} -#ifdef CGAL_CXX11 template decltype(auto) operator()(U&&...u)const{ return b(internal::Forward_rep()(u)...); } -#else -#define CGAL_VAR(Z,N,_) internal::Forward_rep()(u##N) -#define CGAL_CODE(Z,N,_) template result_type \ - operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ - return b(BOOST_PP_ENUM(N,CGAL_VAR,)); \ - } - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE -#undef CGAL_VAR -// In case the last argument needs to be non-const. Fragile... -#define CGAL_VAR(Z,N,_) internal::Forward_rep()(u##N) -#define CGAL_CODE(Z,N,_) template result_type \ - operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u),V&v)const{ \ - return b(BOOST_PP_ENUM(N,CGAL_VAR,),internal::Forward_rep()(v)); \ - } - BOOST_PP_REPEAT_FROM_TO(1,8,CGAL_CODE,_) -#undef CGAL_CODE -#undef CGAL_VAR -#endif }; }; @@ -187,20 +167,9 @@ struct Cartesian_wrap : public Base_ typedef typename map_result_tag::type result_tag; // FIXME: Self or Derived? typedef typename Get_type::type result_type; -#ifdef CGAL_CXX11 template result_type operator()(U&&...u)const{ return result_type(Eval_functor(),b,internal::Forward_rep()(u)...); } -#else -#define CGAL_VAR(Z,N,_) internal::Forward_rep()(u##N) -#define CGAL_CODE(Z,N,_) template result_type \ - operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ - return result_type(Eval_functor(),b,BOOST_PP_ENUM(N,CGAL_VAR,)); \ - } - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE -#undef CGAL_VAR -#endif }; }; @@ -241,23 +210,9 @@ struct Cartesian_refcount : public Base_ type(){} type(Self const&k):b(k){} typedef typename B::result_type result_type; -#ifdef CGAL_CXX11 template result_type operator()(U&&...u)const{ return b(internal::Forward_rep()(u)...); } -#else - result_type operator()()const{ - return b(); - } -#define CGAL_VAR(Z,N,_) internal::Forward_rep()(u##N) -#define CGAL_CODE(Z,N,_) template result_type \ - operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ - return b(BOOST_PP_ENUM(N,CGAL_VAR,)); \ - } - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE -#undef CGAL_VAR -#endif }; }; @@ -274,23 +229,9 @@ struct Cartesian_refcount : public Base_ type(Self const&k):b(k){} typedef typename map_result_tag::type result_tag; typedef typename Get_type::type result_type; -#ifdef CGAL_CXX11 template result_type operator()(U&&...u)const{ return result_type(Eval_functor(),b,internal::Forward_rep()(u)...); } -#else - result_type operator()()const{ - return result_type(Eval_functor(),b); - } -#define CGAL_VAR(Z,N,_) internal::Forward_rep()(u##N) -#define CGAL_CODE(Z,N,_) template result_type \ - operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,U,const&u))const{ \ - return result_type(Eval_functor(),b,BOOST_PP_ENUM(N,CGAL_VAR,)); \ - } - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE -#undef CGAL_VAR -#endif }; }; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Hyperplane_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Hyperplane_d.h index 1dff1b59f20..0b9547646fb 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Hyperplane_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Hyperplane_d.h @@ -26,10 +26,6 @@ #include #include #include -#ifndef CGAL_CXX11 -#include -#endif -#include namespace CGAL { namespace Wrap { @@ -67,7 +63,6 @@ public: typedef R_ R; -#ifdef CGAL_CXX11 template::type...>,std::tuple >::value>::type> explicit Hyperplane_d(U&&...u) : Rep(CHBase()(std::forward(u)...)){} @@ -89,30 +84,6 @@ public: Hyperplane_d(Rep& v) : Rep(static_cast(v)) {} Hyperplane_d(Rep&& v) : Rep(std::move(v)) {} -#else - - Hyperplane_d() : Rep(CHBase()()) {} - - Hyperplane_d(Rep const& v) : Rep(v) {} // try not to use it - -#define CGAL_CODE(Z,N,_) template \ - explicit Hyperplane_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(CHBase()( \ - BOOST_PP_ENUM_PARAMS(N,t))) {} \ - \ - template \ - Hyperplane_d(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(f(BOOST_PP_ENUM_PARAMS(N,t))) {} - /* - template \ - Point_d(Eval_functor,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(Eval_functor(), BOOST_PP_ENUM_PARAMS(N,t)) {} - */ - - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE - -#endif //TODO: if OVBase returns a reference to a base vector, cast it to a //reference to a wrapper vector. Ugly but should be safe. diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h index 831ec157762..d4fe244e6c3 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h @@ -31,9 +31,6 @@ #include #include #include -#ifndef CGAL_CXX11 -#include -#endif #include namespace CGAL { @@ -77,7 +74,6 @@ public: typedef R_ R; -#ifdef CGAL_CXX11 template::type...>,std::tuple >::value>::type> explicit Point_d(U&&...u) : Rep(CPBase()(std::forward(u)...)){} @@ -107,34 +103,6 @@ public: Point_d(Origin&& v) : Rep(CPBase()(std::move(v))) {} -#else - - Point_d() : Rep(CPBase()()) {} - - Point_d(Rep const& v) : Rep(v) {} // try not to use it - -#define CGAL_CODE(Z,N,_) template \ - explicit Point_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(CPBase()( \ - BOOST_PP_ENUM_PARAMS(N,t))) {} \ - \ - template \ - Point_d(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(f(BOOST_PP_ENUM_PARAMS(N,t))) {} - /* - template \ - Point_d(Eval_functor,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(Eval_functor(), BOOST_PP_ENUM_PARAMS(N,t)) {} - */ - - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE - - // this one should be implicit - Point_d(Origin const& o) - : Rep(CPBase()(o)) {} - -#endif typename boost::result_of::type cartesian(int i)const{ return CCBase()(rep(),i); diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Ref_count_obj.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Ref_count_obj.h index be1de7fd5ed..403eeb6ba9f 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Ref_count_obj.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Ref_count_obj.h @@ -29,10 +29,6 @@ #include #include #include -#ifndef CGAL_CXX11 -#include -#endif -#include // no need for a fancy interface here, people can use the Point_d wrapper on // top. @@ -67,7 +63,6 @@ public: return CGAL::get_pointee_or_identity(data); } -#ifdef CGAL_CXX11 template::type...>,std::tuple >::value>::type> explicit Ref_count_obj(U&&...u) : data(Eval_functor(),CBase(),std::forward(u)...){} @@ -88,32 +83,6 @@ public: // Ref_count_obj(Origin&& v) // : data(Eval_functor(),CBase(),std::move(v)) {} -#else - - Ref_count_obj() : data(Eval_functor(),CBase()) {} - - Ref_count_obj(Rep const& v) : data(v) {} // try not to use it - -#define CGAL_CODE(Z,N,_) template \ - explicit Ref_count_obj(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : data(Eval_functor(),CBase(),BOOST_PP_ENUM_PARAMS(N,t)) {} \ - \ - template \ - Ref_count_obj(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : data(Eval_functor(),f,BOOST_PP_ENUM_PARAMS(N,t)) {} - - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE - template - Ref_count_obj(Eval_functor,F const& f) - : data(Eval_functor(),f) {} - -// // this one should be implicit -// Ref_count_obj(Origin const& o) -// : data(Eval_functor(),CBase(),o) {} - -#endif - }; } //namespace CGAL diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Segment_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Segment_d.h index 5194c8bc2bc..080960f795a 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Segment_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Segment_d.h @@ -28,10 +28,6 @@ #include #include #include -#ifndef CGAL_CXX11 -#include -#endif -#include namespace CGAL { namespace Wrap { @@ -70,7 +66,6 @@ public: typedef R_ R; -#ifdef CGAL_CXX11 template::type...>,std::tuple >::value>::type> explicit Segment_d(U&&...u) : Rep(CSBase()(std::forward(u)...)){} @@ -92,30 +87,6 @@ public: Segment_d(Rep& v) : Rep(static_cast(v)) {} Segment_d(Rep&& v) : Rep(std::move(v)) {} -#else - - Segment_d() : Rep(CSBase()()) {} - - Segment_d(Rep const& v) : Rep(v) {} // try not to use it - -#define CGAL_CODE(Z,N,_) template \ - explicit Segment_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(CSBase()( \ - BOOST_PP_ENUM_PARAMS(N,t))) {} \ - \ - template \ - Segment_d(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(f(BOOST_PP_ENUM_PARAMS(N,t))) {} - /* - template \ - Point_d(Eval_functor,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(Eval_functor(), BOOST_PP_ENUM_PARAMS(N,t)) {} - */ - - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE - -#endif //TODO: if CSEBase returns a reference to a base point, cast it to a //reference to a wrapper point. Ugly but should be safe. diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Sphere_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Sphere_d.h index c56d7f43beb..118a01ab154 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Sphere_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Sphere_d.h @@ -26,10 +26,6 @@ #include #include #include -#ifndef CGAL_CXX11 -#include -#endif -#include namespace CGAL { namespace Wrap { @@ -67,7 +63,6 @@ public: typedef R_ R; -#ifdef CGAL_CXX11 template::type...>,std::tuple >::value>::type> explicit Sphere_d(U&&...u) : Rep(CSBase()(std::forward(u)...)){} @@ -89,30 +84,6 @@ public: Sphere_d(Rep& v) : Rep(static_cast(v)) {} Sphere_d(Rep&& v) : Rep(std::move(v)) {} -#else - - Sphere_d() : Rep(CSBase()()) {} - - Sphere_d(Rep const& v) : Rep(v) {} // try not to use it - -#define CGAL_CODE(Z,N,_) template \ - explicit Sphere_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(CSBase()( \ - BOOST_PP_ENUM_PARAMS(N,t))) {} \ - \ - template \ - Sphere_d(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(f(BOOST_PP_ENUM_PARAMS(N,t))) {} - /* - template \ - Point_d(Eval_functor,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(Eval_functor(), BOOST_PP_ENUM_PARAMS(N,t)) {} - */ - - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE - -#endif //TODO: if COSBase returns a reference to a base point, cast it to a //reference to a wrapper point. Ugly but should be safe. diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h index c85a252891e..4df349df909 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h @@ -31,9 +31,6 @@ #include #include #include -#ifndef CGAL_CXX11 -#include -#endif #include namespace CGAL { @@ -75,7 +72,6 @@ public: typedef R_ R; -#ifdef CGAL_CXX11 template::type...>,std::tuple >::value>::type> explicit Vector_d(U&&...u) : Rep(CVBase()(std::forward(u)...)){} @@ -105,34 +101,6 @@ public: Vector_d(Null_vector&& v) : Rep(CVBase()(std::move(v))) {} -#else - - Vector_d() : Rep(CVBase()()) {} - - Vector_d(Rep const& v) : Rep(v) {} // try not to use it - -#define CGAL_CODE(Z,N,_) template \ - explicit Vector_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(CVBase()( \ - BOOST_PP_ENUM_PARAMS(N,t))) {} \ - \ - template \ - Vector_d(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(f(BOOST_PP_ENUM_PARAMS(N,t))) {} - /* - template \ - Vector_d(Eval_functor,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(Eval_functor(), BOOST_PP_ENUM_PARAMS(N,t)) {} - */ - - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE - - // this one should be implicit - Vector_d(Null_vector const& v) - : Rep(CVBase()(v)) {} - -#endif typename boost::result_of::type cartesian(int i)const{ return CCBase()(rep(),i); diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Weighted_point_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Weighted_point_d.h index 3b5ceb6bb31..f86cda64c04 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Weighted_point_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Weighted_point_d.h @@ -29,10 +29,6 @@ #include #include #include -#ifndef CGAL_CXX11 -#include -#endif -#include namespace CGAL { namespace Wrap { @@ -70,7 +66,6 @@ public: typedef R_ R; -#ifdef CGAL_CXX11 template::type...>,std::tuple >::value>::type> explicit Weighted_point_d(U&&...u) : Rep(CWPBase()(std::forward(u)...)){} @@ -92,30 +87,6 @@ public: Weighted_point_d(Rep& v) : Rep(static_cast(v)) {} Weighted_point_d(Rep&& v) : Rep(std::move(v)) {} -#else - - Weighted_point_d() : Rep(CWPBase()()) {} - - Weighted_point_d(Rep const& v) : Rep(v) {} // try not to use it - -#define CGAL_CODE(Z,N,_) template \ - explicit Weighted_point_d(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(CWPBase()( \ - BOOST_PP_ENUM_PARAMS(N,t))) {} \ - \ - template \ - Weighted_point_d(Eval_functor,F const& f,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(f(BOOST_PP_ENUM_PARAMS(N,t))) {} - /* - template \ - Point_d(Eval_functor,BOOST_PP_ENUM_BINARY_PARAMS(N,T,const&t)) \ - : Rep(Eval_functor(), BOOST_PP_ENUM_PARAMS(N,t)) {} - */ - - BOOST_PP_REPEAT_FROM_TO(1,11,CGAL_CODE,_) -#undef CGAL_CODE - -#endif //TODO: use references? Point_ point()const{ diff --git a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h index 0d41eb59707..808bcafc2bb 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h @@ -35,9 +35,7 @@ #include #include #include -#ifdef CGAL_CXX11 #include -#endif namespace CGAL { namespace CartesianDKernelFunctors { @@ -73,7 +71,6 @@ template,typename R::Default_ambient_dimension>::value>::type> template =3)>::type> @@ -85,28 +82,8 @@ template l) const { return operator()(l.begin(),l.end()); } -#else - //should we make it template to avoid instantiation for wrong dim? - //or iterate outside the class? -#define CGAL_VAR(Z,J,I) m(I,J)=c(p##I,J)-c(x,J); -#define CGAL_VAR2(Z,I,N) BOOST_PP_REPEAT(N,CGAL_VAR,I) -#define CGAL_CODE(Z,N,_) \ - result_type operator()(Point const&x, BOOST_PP_ENUM_PARAMS(N,Point const&p)) const { \ - typename Get_functor::type c(this->kernel()); \ - Matrix m(N,N); \ - BOOST_PP_REPEAT(N,CGAL_VAR2,N) \ - return R::LA::sign_of_determinant(CGAL_MOVE(m)); \ - } - -BOOST_PP_REPEAT_FROM_TO(7, 10, CGAL_CODE, _ ) - // No need to do it for <=6, since that uses a different code path -#undef CGAL_CODE -#undef CGAL_VAR2 -#undef CGAL_VAR -#endif }; -#ifdef CGAL_CXX11 template struct Orientation_of_points,true> : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation_of_points) typedef R_ R; @@ -139,40 +116,6 @@ template struct Orientation_of_points,true> return help2(Dimension_tag(),f,e); } }; -#else -#define CGAL_VAR(Z,J,I) c(p##I,J)-x##J -#define CGAL_VAR2(Z,I,N) BOOST_PP_ENUM(N,CGAL_VAR,I) -#define CGAL_VAR3(Z,N,_) Point const&p##N=*++f; -#define CGAL_VAR4(Z,N,_) RT const&x##N=c(x,N); -#define CGAL_CODE(Z,N,_) \ -template struct Orientation_of_points,true> : private Store_kernel { \ - CGAL_FUNCTOR_INIT_STORE(Orientation_of_points) \ - typedef R_ R; \ - typedef typename Get_type::type RT; \ - typedef typename Get_type::type Point; \ - typedef typename Get_type::type result_type; \ - result_type operator()(Point const&x, BOOST_PP_ENUM_PARAMS(N,Point const&p)) const { \ - typename Get_functor::type c(this->kernel()); \ - BOOST_PP_REPEAT(N,CGAL_VAR4,) \ - return sign_of_determinant(BOOST_PP_ENUM(N,CGAL_VAR2,N)); \ - } \ - template \ - result_type operator()(Iter f, Iter CGAL_assertion_code(e))const{ \ - Point const&x=*f; \ - BOOST_PP_REPEAT(N,CGAL_VAR3,) \ - CGAL_assertion(++f==e); \ - return operator()(x,BOOST_PP_ENUM_PARAMS(N,p)); \ - } \ -}; - - BOOST_PP_REPEAT_FROM_TO(2, 7, CGAL_CODE, _ ) -#undef CGAL_CODE -#undef CGAL_VAR4 -#undef CGAL_VAR3 -#undef CGAL_VAR2 -#undef CGAL_VAR - -#endif template struct Orientation_of_points,true> : private Store_kernel { CGAL_FUNCTOR_INIT_STORE(Orientation_of_points) @@ -224,7 +167,6 @@ template struct Orientation_of_vectors : private Store_kernel { return R::LA::sign_of_determinant(CGAL_MOVE(m)); } -#ifdef CGAL_CXX11 template =3)>::type> result_type operator()(U&&...u) const { return operator()({std::forward(u)...}); @@ -234,9 +176,6 @@ template struct Orientation_of_vectors : private Store_kernel { result_type operator()(std::initializer_list l) const { return operator()(l.begin(),l.end()); } -#else - //TODO -#endif }; } @@ -480,11 +419,7 @@ template struct Linear_base : private Store_kernel { for(int i=0; i < R::LA::columns(b); ++i){ //*o++ = Vector(b.col(i)); typedef -#ifdef CGAL_CXX11 decltype(std::declval()(0,0)) -#else - FT -#endif Ref; typedef Iterator_from_indices > IFI; @@ -657,7 +592,6 @@ template struct Side_of_oriented_sphere : private Store_kernel { return LA::sign_of_determinant(CGAL_MOVE(m)); } -#ifdef CGAL_CXX11 template =4)>::type> result_type operator()(U&&...u) const { return operator()({std::forward(u)...}); @@ -667,9 +601,6 @@ template struct Side_of_oriented_sphere : private Store_kernel { result_type operator()(std::initializer_list

l) const { return operator()(l.begin(),l.end()); } -#else - //TODO -#endif }; } @@ -816,7 +747,6 @@ template struct Side_of_bounded_sphere : private Store_kernel { return enum_cast (sos (f, e, p0) * op (f, e)); } -#ifdef CGAL_CXX11 template =4)>::type> result_type operator()(U&&...u) const { return operator()({std::forward(u)...}); @@ -826,9 +756,6 @@ template struct Side_of_bounded_sphere : private Store_kernel { result_type operator()(std::initializer_list

(p)...)); + return Help>()(c,x,std::forward_as_tuple(std::forward

(p)...)); } diff --git a/NewKernel_d/include/CGAL/NewKernel_d/utils.h b/NewKernel_d/include/CGAL/NewKernel_d/utils.h index 7b7981bc2ae..245ac8a4f38 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/utils.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/utils.h @@ -149,32 +149,23 @@ struct Has_type_different_from template struct result { typedef typename std::iterator_traits::reference type; }; - template typename result::type + template decltype(auto) operator()(It const&i)const{ return *i; } }; - template struct Indices{}; - template struct Next_increasing_indices; - template struct Next_increasing_indices > { - typedef Indices type; - }; - template struct N_increasing_indices { - typedef typename Next_increasing_indices::type>::type type; - }; - template<> struct N_increasing_indices<0> { typedef Indices<> type; }; namespace internal { - template inline typename std::result_of::type - do_call_on_tuple_elements(F&&f, std::tuple&&t, Indices&&) { + template inline decltype(auto) + do_call_on_tuple_elements(F&&f, std::tuple&&t, std::index_sequence&&) { return f(std::get(std::move(t))...); } } // internal - template - inline typename std::result_of::type + template + inline decltype(auto) call_on_tuple_elements(F&&f, std::tuple&&t) { return internal::do_call_on_tuple_elements(std::forward(f),std::move(t), - typename N_increasing_indices::type()); + std::make_index_sequence()); } template struct Factory { From a17f5655e18b3d5e37e1a575fdf9f1fa276f5379 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 17:21:28 +0100 Subject: [PATCH 32/56] More [[no_unique_address]] --- Filtered_kernel/include/CGAL/Lazy.h | 40 +++++++++---------- .../CGAL/NewKernel_d/Filtered_predicate2.h | 8 ++-- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index 08e51fec51c..60d01a032a8 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -787,8 +787,8 @@ struct Lazy_construction_bbox typedef typename LK::Exact_kernel EK; typedef typename AC::result_type result_type; - AC ac; - EC ec; + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; template result_type operator()(const L1& l1) const @@ -818,8 +818,8 @@ struct Lazy_construction_nt { typedef typename LK::Exact_kernel EK; typedef typename LK::E2A E2A; - AC ac; - EC ec; + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; template struct result { }; @@ -993,8 +993,8 @@ struct Lazy_cartesian_const_iterator_2 typedef typename LK::Exact_kernel EK; typedef typename LK::Cartesian_const_iterator_2 result_type; - AC ac; - EC ec; + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; public: @@ -1022,8 +1022,8 @@ struct Lazy_cartesian_const_iterator_3 typedef typename LK::Exact_kernel EK; typedef typename LK::Cartesian_const_iterator_3 result_type; - AC ac; - EC ec; + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; public: @@ -1054,8 +1054,8 @@ struct Lazy_functor_2_1 static const bool Protection = true; typedef void result_type; - AC ac; - EC ec; + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; public: @@ -1118,8 +1118,8 @@ struct Lazy_functor_2_2 typedef typename LK::Exact_kernel EK; typedef typename LK::E2A E2A; - AC ac; - EC ec; + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; public: @@ -1162,8 +1162,8 @@ struct Lazy_intersect_with_iterators typedef Lazy Lazy_object; typedef Lazy, std::vector, E2A> Lazy_vector; - AC ac; - EC ec; + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; public: @@ -1242,8 +1242,8 @@ struct Lazy_construction_object typedef Lazy Lazy_object; - AC ac; - EC ec; + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; public: @@ -1620,8 +1620,8 @@ struct Lazy_construction { typedef typename Type_mapper::type result_type; - AC ac; - EC ec; + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; #define CGAL_CONSTRUCTION_OPERATOR(z, n, d ) \ template \ @@ -1670,8 +1670,8 @@ struct Lazy_construction // you are on your own }; - AC ac; - EC ec; + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; // acquire the result_type of the approximate kernel, map it back to the lazy kernel object #define CGAL_RESULT(z, n, d) \ diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h b/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h index 323537d6776..a35d1c5bcd3 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h @@ -55,10 +55,10 @@ class Filtered_predicate2 //TODO: pack (at least use a tuple) //FIXME: is it better to store those, or just store enough to recreate them //(i.e. possibly references to the kernels)? - EP ep; - AP ap; - C2E c2e; - C2A c2a; + CGAL_NO_UNIQUE_ADDRESS EP ep; + CGAL_NO_UNIQUE_ADDRESS AP ap; + CGAL_NO_UNIQUE_ADDRESS C2E c2e; + CGAL_NO_UNIQUE_ADDRESS C2A c2a; public: From e2ce6d9daaa3a2c5055d38f12293135032f4be16 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 21:36:13 +0100 Subject: [PATCH 33/56] Remove unnecessary overload of Side_of_oriented_sphere --- .../CGAL/NewKernel_d/function_objects_cartesian.h | 2 ++ NewKernel_d/test/NewKernel_d/Epick_d.cpp | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h index bc8427d3355..979d1322762 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h @@ -551,11 +551,13 @@ template struct Side_of_oriented_sphere : private Store_kernel { typedef typename R::LA::template Rebind_dimension::Other LA; typedef typename LA::Square_matrix Matrix; + /* Undocumented, removed template result_type operator()(Iter f, Iter const& e)const{ Point const& p0=*f++; // *--e ? return this->operator()(f,e,p0); } + */ template result_type operator()(Iter f, Iter const& e, Point const& p0) const { diff --git a/NewKernel_d/test/NewKernel_d/Epick_d.cpp b/NewKernel_d/test/NewKernel_d/Epick_d.cpp index 503450d96d7..3bd63caf614 100644 --- a/NewKernel_d/test/NewKernel_d/Epick_d.cpp +++ b/NewKernel_d/test/NewKernel_d/Epick_d.cpp @@ -537,7 +537,7 @@ void test3(){ assert(abs(sd(e,a)-32)<.0001); P tab[]={a,b,c,d,e}; std::cout << po (&tab[0],tab+4) << ' '; - std::cout << sos(&tab[0],tab+5) << ' '; + std::cout << sos(&tab[1],tab+5,tab[0]) << ' '; std::cout << sbs(tab+1,tab+5,tab[0]) << std::endl; FO fo=cfo(&tab[0],tab+3); std::cout << fo; @@ -570,13 +570,13 @@ void test3(){ std::cout << ifsos(fo3,yy+0,yy+3,yy[3]) << ' '; std::cout << ifsos(fo3,yy+1,yy+4,yy[0]) << '\n'; P buf[]={cp(100,900,0),y[0],y[1],y[2],y[3]}; - std::cout << sos(buf+0,buf+5) << ' '; + std::cout << sos(buf+1,buf+5,buf[0]) << ' '; buf[1]=y[1];buf[2]=y[2];buf[3]=y[3];buf[4]=y[0]; - std::cout << sos(buf+0,buf+5) << ' '; + std::cout << sos(buf+1,buf+5,buf[0]) << ' '; buf[1]=yy[0];buf[2]=yy[1];buf[3]=yy[2];buf[4]=yy[3]; - std::cout << sos(buf+0,buf+5) << ' '; + std::cout << sos(buf+1,buf+5,buf[0]) << ' '; buf[1]=yy[1];buf[2]=yy[2];buf[3]=yy[3];buf[4]=yy[0]; - std::cout << sos(buf+0,buf+5) << '\n'; + std::cout << sos(buf+1,buf+5,buf[0]) << '\n'; assert(cah(y+0,y+3,y[3])); assert(!cah(y+0,y+3,buf[0])); assert(cl(a,a)==CGAL::EQUAL); From 28c2763f1a17c4e9a01cc0b5b2a1f8fcb7464019 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 21:39:47 +0100 Subject: [PATCH 34/56] Remove leftover macro CGAL_CONSTRUCTION_OPERATOR --- NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h index 3ada5ce2efe..a563746b053 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h @@ -99,8 +99,6 @@ struct Lazy_construction2 { { return new Lazy_rep_0(); } - -#undef CGAL_CONSTRUCTION_OPERATOR }; template From 224e1275229e38b12e3bbae2bb2903be5b751583 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 23:26:27 +0100 Subject: [PATCH 35/56] Experiment how we can store ranges in lazy objects. --- .../include/CGAL/NewKernel_d/Lazy_cartesian.h | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h index a563746b053..02ff98ac303 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h @@ -100,6 +100,103 @@ struct Lazy_construction2 { return new Lazy_rep_0(); } }; +#if 0 +// Experiment how we can store ranges +template +class Lazy_rep_XXX : + public Lazy_rep< AT, ET, E2A >, private EC +{ + int ld; + mutable std::vector lr; + const EC& ec() const { return *this; } + public: + void update_exact() const { + this->et = new ET(ec()(ld, CGAL::exact(std::begin(lr)), CGAL::exact(std::end(lr)))); + this->at = E2A()(*(this->et)); + lr = std::vector(); // lr.clear(); lr.shrink_to_fit(); generates worse code + } + template + Lazy_rep_XXX(const AC& ac, const EC& ec, int d, Iter const& f, Iter const& e) : + Lazy_rep(ac(d, CGAL::approx(f), CGAL::approx(e))), EC(ec), ld(d), lr(f, e) + { + this->set_depth(1); // ??? Who cares + } +}; +template +class Lazy_rep_YYY : + public Lazy_rep< AT, ET, E2A >, private EC +{ + mutable std::vector lr; + mutable L l; + const EC& ec() const { return *this; } + public: + void update_exact() const { + this->et = new ET(ec()(CGAL::exact(std::begin(lr)), CGAL::exact(std::end(lr)), CGAL::exact(l))); + this->at = E2A()(*(this->et)); + lr = std::vector(); // lr.clear(); lr.shrink_to_fit(); generates worse code + l = L(); + } + template + Lazy_rep_YYY(const AC& ac, const EC& ec, Iter const& f, Iter const& e, L const& ll) : + Lazy_rep(ac(CGAL::approx(f), CGAL::approx(e), CGAL::approx(ll))), EC(ec), lr(f, e), l(ll) + { + this->set_depth(1); // ??? Who cares + } +}; +template +struct Lazy_construction2, LK> { + static const bool Protection = true; + typedef Construct_ttag T; + typedef typename LK::Approximate_kernel AK; + typedef typename LK::Exact_kernel EK; + typedef typename LK::E2A E2A; + typedef typename Get_functor::type AC; + typedef typename Get_functor::type EC; + typedef typename map_result_tag::type result_tag; + typedef typename Get_type::type AT; + typedef typename Get_type::type ET; + typedef typename Get_type::type result_type; + // same as Handle = Lazy< AT, ET, E2A> + typedef typename Get_type::type FT; + + Lazy_construction2(){} + Lazy_construction2(LK const&k):ac(k.approximate_kernel()),ec(k.exact_kernel()){} + CGAL_NO_UNIQUE_ADDRESS AC ac; + CGAL_NO_UNIQUE_ADDRESS EC ec; + + template + std::enable_if_t<(sizeof...(L)>0&&Constructible_from_each::value), result_type> operator()(L const&...l) const { + CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); + Protect_FPU_rounding P; + try { + return new Lazy_rep_n(ac, ec, l...); + } catch (Uncertain_conversion_exception&) { + CGAL_BRANCH_PROFILER_BRANCH(tmp); + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); + return new Lazy_rep_0(ec(CGAL::exact(l)...)); + } + } + template + std::enable_if_t::value,result_type> operator()(int d, Iter const& f, Iter const& e) const { + typedef typename std::iterator_traits::value_type TT; + return new Lazy_rep_XXX(ac, ec, d, f, e); + } + template + std::enable_if_t::value,result_type> operator()(Iter const& f, Iter const& e, L const&l) const { + typedef typename std::iterator_traits::value_type TT; + return new Lazy_rep_YYY(ac, ec, f, e, l); + } + template + std::enable_if_t::value,result_type> operator()(Iter const& f, Iter const& e) const { + return operator()(std::distance(f, e), f, e); + } + // FIXME: this forces us to have default constructors for all types, try to make its instantiation lazier + result_type operator()() const + { + return new Lazy_rep_0(); + } +}; +#endif template struct Lazy_cartesian_types From 6e579bb11a732c4d290bf72340985cde692f39b3 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 9 Feb 2019 12:51:37 +0100 Subject: [PATCH 36/56] Avoid functors that take unpaired input iterators --- NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h | 2 ++ .../include/CGAL/NewKernel_d/function_objects_cartesian.h | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h b/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h index 6c81198b37d..21649ca2bf8 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h @@ -282,7 +282,7 @@ template struct In_flat_power_side_of_power_sphere_raw : private Store typedef typename LA::Square_matrix Matrix; template - result_type operator()(Flat_orientation const&o, Iter f, Iter e, IterW fw, Point const&x, Wt const&w) const { + result_type operator()(Flat_orientation const&o, Iter f, Iter const&e, IterW fw, IterW const&/*ew*/, Point const&x, Wt const&w) const { // TODO: can't work in the projection, but we should at least remove the row of 1s. typename Get_functor::type c(this->kernel()); typename Get_functor::type pd(this->kernel()); diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h index a23a838ce78..4c8fc694a34 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h @@ -118,6 +118,7 @@ template struct Power_side_of_power_sphere : private Store_kernel make_transforming_iterator (f, pdw), make_transforming_iterator (e, pdw), make_transforming_iterator (f, pw), + make_transforming_iterator (e, pw), pdw (p0), pw (p0)); } @@ -138,6 +139,7 @@ template struct In_flat_power_side_of_power_sphere : private Store_ker make_transforming_iterator (f, pdw), make_transforming_iterator (e, pdw), make_transforming_iterator (f, pw), + make_transforming_iterator (e, pw), pdw (p0), pw (p0)); } diff --git a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h index 979d1322762..cf82d299a45 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h @@ -499,7 +499,7 @@ template struct Power_side_of_power_sphere_raw : private Store_kernel< typedef typename LA::Square_matrix Matrix; template - result_type operator()(IterP f, IterP const& e, IterW fw, Pt const& p0, Wt const& w0) const { + result_type operator()(IterP f, IterP const& e, IterW fw, IterW const&/*ew*/, Pt const& p0, Wt const& w0) const { typedef typename Get_functor::type Sqdo; typename Get_functor::type c(this->kernel()); typename Get_functor::type pd(this->kernel()); From 15d2b82ff875666ebd8234d8097ca90ba24f33f9 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sat, 9 Feb 2019 22:31:31 +0100 Subject: [PATCH 37/56] Copy ranges defined by iterator pairs inside Lazy objects. --- .../include/CGAL/NewKernel_d/Lazy_cartesian.h | 193 +++++++++--------- NewKernel_d/test/NewKernel_d/Epick_d.cpp | 69 ++++--- 2 files changed, 141 insertions(+), 121 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h index 02ff98ac303..0fa5fa99d43 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h @@ -62,6 +62,99 @@ namespace internal { }; } +// Whenever a construction takes iterator pairs as input, whether they point to double of Lazy objects, copy the ranges inside the lazy result so they are available for update_exact(). We analyze the input to try and guess where iterator pairs are. I would prefer if each functor had a specific signature (no overload in this layer) so we wouldn't have to guess. +// FIXME: Lazy_construct_nt is also a construction and needs the same treatment. +namespace Lazy_internal { +templatestruct typelist{}; +templatestruct arg_i{}; +templatestruct arg_i_begin{}; +templatestruct arg_i_end{}; +templatestruct arg_i_ip1_range{}; +templatestruct analyze_args; +templatestruct analyze_args> { + typedef T creator; + typedef U reader; +}; +template +struct analyze_args,typelist,typelist,std::enable_if_t::value>> : +analyze_args>,typelist>,typelist> {}; +template +struct analyze_args,typelist,typelist,std::enable_if_t::value>> : +analyze_args>,typelist,arg_i_end>,typelist> {}; +template using analyze_args_for_lazy = analyze_args,typelist<>,typelist>; +templatestruct extract1; +templatestruct extract1,T>:std::tuple_element{}; +templatestruct extract1,T>{ + typedef std::tuple_element_t E; + typedef std::remove_cv_t> It; + typedef typename std::iterator_traits::value_type element_type; + // TODO: find a way to use an array of the right size, at least for the most frequent constructions + typedef std::vector type; +}; +templatedecltype(auto) +do_extract(arg_i,std::tupleconst&t) +{return std::get(t);} +templatedecltype(auto) +do_extract(arg_i_begin,std::tupleconst&t) +{return std::begin(std::get(t));} +templatedecltype(auto) +do_extract(arg_i_end,std::tupleconst&t) +{return std::end(std::get(t));} +templatedecltype(auto) +do_extract(arg_i_ip1_range,std::tupleconst&t) +{ + typedef std::tuple L; + typedef std::tuple_element_t E; + typedef std::remove_cv_t> It; + typedef typename std::iterator_traits::value_type element_type; + typedef std::vector type; + return type(std::get(t),std::get(t)); +} +templatestruct data_from_input; +templatestruct data_from_input,U> { + typedef std::tuple::type...> type; +}; +} +template +class Lazy_rep_XXX : + public Lazy_rep< AT, ET, E2A >, private EC +{ + // Lazy_rep_0 does not inherit from EC or take a parameter AC. It has different constructors. + static_assert(sizeof...(L)>0, "Use Lazy_rep_0 instead"); + template friend class Lazy_kernel_base; + typedef Lazy_internal::analyze_args_for_lazy Args; + // How to go from l to Lazy_rep's data + typedef typename Args::creator Creator; + // How to go back + typedef typename Args::reader Reader; + // what Lazy_rep should store + typedef typename Lazy_internal::data_from_input>::type LL; + mutable LL l; // L...l; is not yet allowed. + const EC& ec() const { return *this; } + template + void update_exact_helper(Lazy_internal::typelist) const { + this->et = new ET(ec()( CGAL::exact( Lazy_internal::do_extract(T{},l) ) ... ) ); + this->at = E2A()(*(this->et)); + l = LL(); // There should be a nicer way to clear. Destruction for instance. With this->et as a witness of whether l has already been destructed. + } + public: + void update_exact() const { + update_exact_helper(Reader{}); + } + template + Lazy_rep_XXX(const AC& ac, const EC& ec, LL const&...ll) : + Lazy_rep_XXX(Creator{},ac,ec,std::forward_as_tuple(ll...),ll...){}; + private: + // Currently we construct the vectors, then move them into the tuple. It would be nicer to construct them in their final destination, because eventually we will also have arrays instead of vectors. + template + Lazy_rep_XXX(Lazy_internal::typelist, const AC& ac, const EC& ec, LLL const&lll, LL const&...ll) : + Lazy_rep(ac(CGAL::approx(ll)...)), EC(ec), l(Lazy_internal::do_extract(T{},lll)...) + { + //this->set_depth(std::max({ -1, (int)CGAL::depth(ll)...}) + 1); + this->set_depth(1); // FIXME: now that we have ranges, we could actually compute the depth if we cared... + } + // TODO: print_dag needs a specific implementation for Lazy_rep_XXX +}; template struct Lazy_construction2 { static const bool Protection = true; @@ -87,7 +180,7 @@ struct Lazy_construction2 { CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); Protect_FPU_rounding P; try { - return new Lazy_rep_n(ac, ec, l...); + return new Lazy_rep_XXX(ac, ec, l...); } catch (Uncertain_conversion_exception&) { CGAL_BRANCH_PROFILER_BRANCH(tmp); Protect_FPU_rounding P2(CGAL_FE_TONEAREST); @@ -95,108 +188,12 @@ struct Lazy_construction2 { } } // FIXME: this forces us to have default constructors for all types, try to make its instantiation lazier + // Actually, that may be the clearing in update_exact(). result_type operator()() const { return new Lazy_rep_0(); } }; -#if 0 -// Experiment how we can store ranges -template -class Lazy_rep_XXX : - public Lazy_rep< AT, ET, E2A >, private EC -{ - int ld; - mutable std::vector lr; - const EC& ec() const { return *this; } - public: - void update_exact() const { - this->et = new ET(ec()(ld, CGAL::exact(std::begin(lr)), CGAL::exact(std::end(lr)))); - this->at = E2A()(*(this->et)); - lr = std::vector(); // lr.clear(); lr.shrink_to_fit(); generates worse code - } - template - Lazy_rep_XXX(const AC& ac, const EC& ec, int d, Iter const& f, Iter const& e) : - Lazy_rep(ac(d, CGAL::approx(f), CGAL::approx(e))), EC(ec), ld(d), lr(f, e) - { - this->set_depth(1); // ??? Who cares - } -}; -template -class Lazy_rep_YYY : - public Lazy_rep< AT, ET, E2A >, private EC -{ - mutable std::vector lr; - mutable L l; - const EC& ec() const { return *this; } - public: - void update_exact() const { - this->et = new ET(ec()(CGAL::exact(std::begin(lr)), CGAL::exact(std::end(lr)), CGAL::exact(l))); - this->at = E2A()(*(this->et)); - lr = std::vector(); // lr.clear(); lr.shrink_to_fit(); generates worse code - l = L(); - } - template - Lazy_rep_YYY(const AC& ac, const EC& ec, Iter const& f, Iter const& e, L const& ll) : - Lazy_rep(ac(CGAL::approx(f), CGAL::approx(e), CGAL::approx(ll))), EC(ec), lr(f, e), l(ll) - { - this->set_depth(1); // ??? Who cares - } -}; -template -struct Lazy_construction2, LK> { - static const bool Protection = true; - typedef Construct_ttag T; - typedef typename LK::Approximate_kernel AK; - typedef typename LK::Exact_kernel EK; - typedef typename LK::E2A E2A; - typedef typename Get_functor::type AC; - typedef typename Get_functor::type EC; - typedef typename map_result_tag::type result_tag; - typedef typename Get_type::type AT; - typedef typename Get_type::type ET; - typedef typename Get_type::type result_type; - // same as Handle = Lazy< AT, ET, E2A> - typedef typename Get_type::type FT; - - Lazy_construction2(){} - Lazy_construction2(LK const&k):ac(k.approximate_kernel()),ec(k.exact_kernel()){} - CGAL_NO_UNIQUE_ADDRESS AC ac; - CGAL_NO_UNIQUE_ADDRESS EC ec; - - template - std::enable_if_t<(sizeof...(L)>0&&Constructible_from_each::value), result_type> operator()(L const&...l) const { - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - Protect_FPU_rounding P; - try { - return new Lazy_rep_n(ac, ec, l...); - } catch (Uncertain_conversion_exception&) { - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding P2(CGAL_FE_TONEAREST); - return new Lazy_rep_0(ec(CGAL::exact(l)...)); - } - } - template - std::enable_if_t::value,result_type> operator()(int d, Iter const& f, Iter const& e) const { - typedef typename std::iterator_traits::value_type TT; - return new Lazy_rep_XXX(ac, ec, d, f, e); - } - template - std::enable_if_t::value,result_type> operator()(Iter const& f, Iter const& e, L const&l) const { - typedef typename std::iterator_traits::value_type TT; - return new Lazy_rep_YYY(ac, ec, f, e, l); - } - template - std::enable_if_t::value,result_type> operator()(Iter const& f, Iter const& e) const { - return operator()(std::distance(f, e), f, e); - } - // FIXME: this forces us to have default constructors for all types, try to make its instantiation lazier - result_type operator()() const - { - return new Lazy_rep_0(); - } -}; -#endif template struct Lazy_cartesian_types diff --git a/NewKernel_d/test/NewKernel_d/Epick_d.cpp b/NewKernel_d/test/NewKernel_d/Epick_d.cpp index 3bd63caf614..a088a6d263f 100644 --- a/NewKernel_d/test/NewKernel_d/Epick_d.cpp +++ b/NewKernel_d/test/NewKernel_d/Epick_d.cpp @@ -367,20 +367,6 @@ void test2(){ assert(abs(cent1[0]-2)<.0001); assert(abs(cent1[1]+3)<.0001); assert(abs(sp.squared_radius()-25)<.0001); -#if 1 - // Fails for an exact kernel - typedef typename K1::Point_of_sphere_d PS; - PS ps Kinit(point_of_sphere_d_object); - P psp0=ps(sp,0); - P psp1=ps(sp,1); - P psp2=ps(sp,2); - assert(!ed(psp0,psp1)); - assert(!ed(psp0,psp2)); - assert(!ed(psp2,psp1)); - assert(abs(sd(cent0,psp0)-25)<.0001); - assert(abs(sd(cent0,psp1)-25)<.0001); - assert(abs(sd(cent0,psp2)-25)<.0001); -#endif P x2py1 = tp(x2,y1); assert(x2py1[1]==-2); WP tw[]={cwp(cp(5,0),1.5),cwp(cp(2,std::sqrt(3)),1),cwp(cp(2,-std::sqrt(3)),1)}; @@ -416,6 +402,46 @@ void test2(){ D un10; CGAL_USE(un10); } +// Fails for an exact kernel, so I split it here +template +void test2i(){ + typedef Ker K1; + typedef typename K1::Point_d P; + typedef typename K1::Sphere_d Sp; + typedef typename K1::Point_of_sphere_d PS; + typedef typename K1::Construct_point_d CP; + typedef typename K1::Construct_sphere_d CSp; + typedef typename K1::Equal_d E; + typedef typename K1::Squared_distance_d SD; + typedef typename K1::Center_of_sphere_d COS; + Ker k +#if 0 + (2) +#endif + ; + CP cp Kinit(construct_point_d_object); + PS ps Kinit(point_of_sphere_d_object); + CSp csp Kinit(construct_sphere_d_object); + E ed Kinit(equal_d_object); + SD sd Kinit(squared_distance_d_object); + COS cos Kinit(center_of_sphere_d_object); + P z0=cp( 0+2,5-3); + P z1=cp(-5+2,0-3); + P z2=cp( 3+2,4-3); + P tabz[]={z0,z1,z2}; + Sp sp = csp(tabz+0,tabz+3); + P cent0=cos(sp); + P psp0=ps(sp,0); + P psp1=ps(sp,1); + P psp2=ps(sp,2); + assert(!ed(psp0,psp1)); + assert(!ed(psp0,psp2)); + assert(!ed(psp2,psp1)); + assert(abs(sd(cent0,psp0)-25)<.0001); + assert(abs(sd(cent0,psp1)-25)<.0001); + assert(abs(sd(cent0,psp2)-25)<.0001); +} + #if defined(BOOST_MSVC) # pragma warning(push) # pragma warning(disable: 4512) @@ -426,15 +452,12 @@ template struct Construct_point3_helper { Construct_point3_helper(CP const& x) : cp(x) {} template typename CP::result_type operator()(T1 const&t1, T2 const&t2, T3 const&t3)const{ - //double tab[]={(double)t1,(double)t2,(double)t3}; - // The lazy kernel stores iterators, not a vector, so the array must stay alive until update_exact()! For the tests I am keeping the memory leak for now, it is more convenient. - double*tab=new double[3]{(double)t1,(double)t2,(double)t3}; + double tab[]={(double)t1,(double)t2,(double)t3}; return cp(tab+0,tab+3); } template typename CP::result_type operator()(T1 const&t1, T2 const&t2, T3 const&t3, T4 const&t4)const{ - // Same discussion as above - double*tab=new double[3]{(double)t1,(double)t2,(double)t3}; + double tab[]={(double)t1,(double)t2,(double)t3}; return cp(tab+0,tab+3,t4); } }; @@ -693,12 +716,12 @@ CGAL_static_assertion((boost::is_same,CGAL::Ambient_dimen int main(){ //Broken with Linear_base_d (output iterator) //test2 >(); - test2(); + test2(); test2i(); test3(); test3(); - //test2>>(); - //test3>>(); - //test3>(); + test2>>(); + test3>>(); + test3>(); } #endif From 402279bcab9992635fa983637d30708ed948bf33 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 10 Feb 2019 12:57:40 +0100 Subject: [PATCH 38/56] Use range-for in a couple places. --- .../include/CGAL/NewKernel_d/Coaffine.h | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h b/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h index 21649ca2bf8..0596db79019 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h @@ -37,13 +37,11 @@ struct Flat_orientation { // For debugging purposes inline std::ostream& operator<< (std::ostream& o, Flat_orientation const& f) { o << "Proj: "; - for(std::vector::const_iterator i=f.proj.begin(); - i!=f.proj.end(); ++i) - o << *i << ' '; + for(int i : f.proj) + o << i << ' '; o << "\nRest: "; - for(std::vector::const_iterator i=f.rest.begin(); - i!=f.rest.end(); ++i) - o << *i << ' '; + for(int i : f.rest) + o << i << ' '; o << "\nInv: " << f.reverse; return o << '\n'; } @@ -155,8 +153,8 @@ template struct Contained_in_affine_hull : private Store_kernel { int d = (int)proj.size()+1; Matrix m (d, d); for(int i=0; i::iterator it=rest.begin();it!=rest.end();++it) { for(int i=0; i struct Contained_in_affine_hull : private Store_kernel { int d = (int)proj.size()+1; Matrix m (d, d); for(int i=0; i::iterator it=rest.begin();it!=rest.end();++it) { - for(int i=0; i Date: Sun, 10 Feb 2019 15:29:25 +0100 Subject: [PATCH 39/56] Handle computations the same as constructions. --- NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h | 10 +++++----- NewKernel_d/include/CGAL/NewKernel_d/functor_tags.h | 7 ++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h index 0fa5fa99d43..8385d6c42f4 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h @@ -63,7 +63,6 @@ namespace internal { } // Whenever a construction takes iterator pairs as input, whether they point to double of Lazy objects, copy the ranges inside the lazy result so they are available for update_exact(). We analyze the input to try and guess where iterator pairs are. I would prefer if each functor had a specific signature (no overload in this layer) so we wouldn't have to guess. -// FIXME: Lazy_construct_nt is also a construction and needs the same treatment. namespace Lazy_internal { templatestruct typelist{}; templatestruct arg_i{}; @@ -155,13 +154,14 @@ class Lazy_rep_XXX : } // TODO: print_dag needs a specific implementation for Lazy_rep_XXX }; +templatestruct Select_converter { typedef typename LK::E2A type; }; +templatestruct Select_converter { typedef To_interval type; }; template struct Lazy_construction2 { static const bool Protection = true; typedef typename LK::Approximate_kernel AK; typedef typename LK::Exact_kernel EK; - typedef typename LK::E2A E2A; typedef typename Get_functor::type AC; typedef typename Get_functor::type EC; typedef typename map_result_tag::type result_tag; @@ -169,6 +169,7 @@ struct Lazy_construction2 { typedef typename Get_type::type ET; typedef typename Get_type::type result_type; // same as Handle = Lazy< AT, ET, E2A> + typedef typename Select_converter::type, LK, ET>::type E2A; Lazy_construction2(){} Lazy_construction2(LK const&k):ac(k.approximate_kernel()),ec(k.exact_kernel()){} @@ -225,6 +226,7 @@ struct Lazy_cartesian_types typedef typename Select_nth_element_functor::type AF; typedef typename Select_nth_element_functor::type EF; + // TODO: we should use Lazy_construction2, but this seems ok for now, we never construct iterators from iterators. typedef typename internal::Lazy_construction_maybe_nt< Kernel_, AF, EF, is_NT_tag::value >::type nth_elem; @@ -298,9 +300,7 @@ struct Lazy_cartesian : typedef Filtered_predicate2 type; }; template struct Functor { - typedef typename Get_functor::type FA; - typedef typename Get_functor::type FE; - typedef Lazy_construction_nt type; + typedef Lazy_construction2 type; }; template struct Functor { typedef Lazy_construction2 type; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/functor_tags.h b/NewKernel_d/include/CGAL/NewKernel_d/functor_tags.h index 58fbef78dd7..ebe4eae4382 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/functor_tags.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/functor_tags.h @@ -199,7 +199,11 @@ namespace CGAL { typedef Null_tag value_tag; }; + templatestruct map_result_tag{typedef Null_type type;}; + templatestruct map_result_tag >{typedef T type;}; + #define CGAL_DECL_COMPUTE(X) struct X##_tag {}; \ + template<>struct map_result_tag{typedef FT_tag type;}; \ templatestruct Get_functor_category{typedef Compute_tag type;} CGAL_DECL_COMPUTE(Compute_point_cartesian_coordinate); CGAL_DECL_COMPUTE(Compute_vector_cartesian_coordinate); @@ -237,9 +241,6 @@ namespace CGAL { CGAL_DECL_ITER_OBJ(Point_cartesian_const_iterator, FT, Compute_point_cartesian_coordinate, Point); #undef CGAL_DECL_ITER_OBJ - templatestruct map_result_tag{typedef Null_type type;}; - templatestruct map_result_tag >{typedef T type;}; - templatestruct Get_functor_category,B,C> : boost::mpl::if_c::is_iterator, Construct_iterator_tag, From 66d4d3c791bcb840ba4c05baa6e32095d7c96e3b Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 10 Feb 2019 15:31:34 +0100 Subject: [PATCH 40/56] The bug is fixed, remove its doc. --- Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h index d2f3b9ec2ca..e631ee2c4d0 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h @@ -38,7 +38,7 @@ or `Dynamic_dimension_tag`. In the latter case, the dimension of the space is sp \attention Only the interfaces specific to this class are listed below. Refer to the concepts for the rest. -\attention Known bugs: the functor `Kernel_d::Intersect_d` is not yet implemented. `Kernel_d::Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Kernel_d::Orientation_d` only works for points, not vectors. Constructing a `Point_d` with iterators is done lazily, see below. +\attention Known bugs: the functor `Kernel_d::Intersect_d` is not yet implemented. `Kernel_d::Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Kernel_d::Orientation_d` only works for points, not vectors. \attention This kernel requires the \ref thirdpartyEigen "Eigen" library. @@ -72,10 +72,6 @@ Point_d(double x0, double x1, ...); /*! introduces a point with coordinate set `[first,end)`. \pre If `DimensionTag` is a fixed dimension, it matches `distance(first,end)`. \tparam ForwardIterator has its value type that is convertible to `double`. - \bug This constructor stores the iterators and may use - them at any later time, when an exact construction is needed. This means - that if `[first,end)` points to some buffer, it has to remain alive at - least as long as the point. */ template Point_d(ForwardIterator first, ForwardIterator end); From b72341251fe4c0d18e8d06678df4c28bf356b45f Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 10 Feb 2019 16:01:52 +0100 Subject: [PATCH 41/56] Allow move in conversion from an exact type ET to Lazy_exact_nt. --- Number_types/include/CGAL/Lazy_exact_nt.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Number_types/include/CGAL/Lazy_exact_nt.h b/Number_types/include/CGAL/Lazy_exact_nt.h index a71fb9328ab..f1bab3eeba1 100644 --- a/Number_types/include/CGAL/Lazy_exact_nt.h +++ b/Number_types/include/CGAL/Lazy_exact_nt.h @@ -165,6 +165,11 @@ struct Lazy_exact_Ex_Cst : public Lazy_exact_nt_rep { this->et = new ET(e); } + Lazy_exact_Ex_Cst (ET&& e) + : Lazy_exact_nt_rep(CGAL_NTS to_interval(e)) + { + this->et = new ET(std::move(e)); + } void update_exact() const { CGAL_error(); } }; @@ -376,6 +381,8 @@ public : Lazy_exact_nt (const ET & e) : Base(new Lazy_exact_Ex_Cst(e)){} + Lazy_exact_nt (ET&& e) + : Base(new Lazy_exact_Ex_Cst(std::move(e))){} template Lazy_exact_nt (const Lazy_exact_nt &x, From 80f8788fa49350ca3e024665af2f936244295c4d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 10 Feb 2019 17:49:13 +0100 Subject: [PATCH 42/56] Move Handle. Probably useless, but it can't hurt. --- STL_Extension/include/CGAL/Handle.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/STL_Extension/include/CGAL/Handle.h b/STL_Extension/include/CGAL/Handle.h index 14304c4a7b8..5b727e9883d 100644 --- a/STL_Extension/include/CGAL/Handle.h +++ b/STL_Extension/include/CGAL/Handle.h @@ -58,6 +58,14 @@ class Handle PTR->count++; } + // When the counter becomes atomic, this may avoid a few atomic operations. + Handle(Handle&& x) + { + CGAL_precondition( x.PTR != static_cast(0) ); + PTR = x.PTR; + x.PTR = nullptr; + } + ~Handle() { if ( PTR && (--PTR->count == 0)) @@ -75,6 +83,14 @@ class Handle return *this; } + Handle& + operator=(Handle&& x) + { + CGAL_precondition( x.PTR != static_cast(0) ); + std::swap(PTR, x.PTR); + return *this; + } + int refs() const { return PTR->count; } From ad14f96ac7d097c7f5f61f28636d5c57e1832a5c Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 12 Feb 2019 10:16:44 +0100 Subject: [PATCH 43/56] Update a few more places to the new member name in Lazy_rep_n. --- Filtered_kernel/include/CGAL/Lazy_kernel.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Filtered_kernel/include/CGAL/Lazy_kernel.h b/Filtered_kernel/include/CGAL/Lazy_kernel.h index 1009198e04d..491bff363bb 100644 --- a/Filtered_kernel/include/CGAL/Lazy_kernel.h +++ b/Filtered_kernel/include/CGAL/Lazy_kernel.h @@ -343,7 +343,7 @@ public: LR * lr = dynamic_cast(p.ptr()); if(lr && (! lr->et)){ - return lr->l2; + return std::get<2>(lr->l); } return BaseClass().compute_weight_2_object()(p); } @@ -373,7 +373,7 @@ public: LR * lr = dynamic_cast(p.ptr()); if(lr && (! lr->et)){ - return lr->l2; + return std::get<2>(lr->l); } return BaseClass().compute_weight_3_object()(p); } @@ -430,11 +430,11 @@ public: LR * lr = dynamic_cast(p.ptr()); if(lr && (! lr->et)){ - return lr->l1; + return std::get<1>(lr->l); } else { LRint* lrint = dynamic_cast(p.ptr()); if(lrint && (! lrint->et)){ - return lrint->l1; + return std::get<1>(lrint->l); } } @@ -493,11 +493,11 @@ public: LR * lr = dynamic_cast(p.ptr()); if(lr && (! lr->et)){ - return lr->l1; + return std::get<1>(lr->l); }else{ LRint* lrint = dynamic_cast(p.ptr()); if(lrint && (! lrint->et)){ - return lrint->l1; + return std::get<1>(lrint->l); } } return BaseClass().construct_point_3_object()(p); From 328f2bdbc6f9d2056e967b8d5fbc5ce025dbe361 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 12 Feb 2019 11:23:25 +0100 Subject: [PATCH 44/56] Replace -std=c++11 with c++1y. --- Scripts/developer_scripts/cgal_check_dependencies.sh | 2 +- Surface_mesh/benchmark/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Scripts/developer_scripts/cgal_check_dependencies.sh b/Scripts/developer_scripts/cgal_check_dependencies.sh index 65b989a8ca2..f270b719745 100644 --- a/Scripts/developer_scripts/cgal_check_dependencies.sh +++ b/Scripts/developer_scripts/cgal_check_dependencies.sh @@ -30,7 +30,7 @@ do fi done -cmake -DCGAL_HEADER_ONLY=FALSE -DCGAL_ENABLE_CHECK_HEADERS=TRUE -DDOXYGEN_EXECUTABLE="$DOX_PATH" -DCGAL_COPY_DEPENDENCIES=TRUE -DCMAKE_CXX_FLAGS="-std=c++11" .. +cmake -DCGAL_HEADER_ONLY=FALSE -DCGAL_ENABLE_CHECK_HEADERS=TRUE -DDOXYGEN_EXECUTABLE="$DOX_PATH" -DCGAL_COPY_DEPENDENCIES=TRUE -DCMAKE_CXX_FLAGS="-std=c++1y" .. if [ -n "$DO_CHECK_HEADERS" ]; then make -j$(nproc --all) -k check_headers fi diff --git a/Surface_mesh/benchmark/CMakeLists.txt b/Surface_mesh/benchmark/CMakeLists.txt index 8d376836e91..2c5482dcbd2 100644 --- a/Surface_mesh/benchmark/CMakeLists.txt +++ b/Surface_mesh/benchmark/CMakeLists.txt @@ -10,7 +10,7 @@ include_directories(BEFORE "../include") #add_definitions("-pg") #SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg") # add_definitions("-g") -add_definitions("-std=c++11") +add_definitions("-std=c++1y") # Polyhedron add_executable(polyhedron_performance performance_2.h polyhedron_performance.h polyhedron_performance.cpp) From 730cfdc2b67699d8a916f49b143dc6a11ddbe10d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 12 Feb 2019 13:23:34 +0100 Subject: [PATCH 45/56] Missing #includes. --- NewKernel_d/include/CGAL/Epeck_d.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NewKernel_d/include/CGAL/Epeck_d.h b/NewKernel_d/include/CGAL/Epeck_d.h index ced041e0887..0ae68f32aec 100644 --- a/NewKernel_d/include/CGAL/Epeck_d.h +++ b/NewKernel_d/include/CGAL/Epeck_d.h @@ -27,7 +27,9 @@ #include #include #include +#include #include +#include // TODO: add static filters somewhere namespace CGAL { From 321268e1d1f093120e1af51c3990550f2a5cc91f Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 13 Feb 2019 14:27:30 +0100 Subject: [PATCH 46/56] CGAL_CXX11 leftover --- NewKernel_d/include/CGAL/argument_swaps.h | 5 ----- 1 file changed, 5 deletions(-) diff --git a/NewKernel_d/include/CGAL/argument_swaps.h b/NewKernel_d/include/CGAL/argument_swaps.h index 1ebef4de555..8bedaff6f39 100644 --- a/NewKernel_d/include/CGAL/argument_swaps.h +++ b/NewKernel_d/include/CGAL/argument_swaps.h @@ -24,11 +24,6 @@ #include #include -#ifndef CGAL_CXX11 -#include -#include -#endif - namespace CGAL { namespace internal { From 5826d192ccf127fc984436cb9bbb18c6f125c061 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Wed, 13 Feb 2019 14:29:25 +0100 Subject: [PATCH 47/56] Move helper to STL_Extension --- .../include/CGAL/transforming_iterator.h | 0 .../include/CGAL/transforming_pair_iterator.h | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename {NewKernel_d => STL_Extension}/include/CGAL/transforming_iterator.h (100%) rename {NewKernel_d => STL_Extension}/include/CGAL/transforming_pair_iterator.h (100%) diff --git a/NewKernel_d/include/CGAL/transforming_iterator.h b/STL_Extension/include/CGAL/transforming_iterator.h similarity index 100% rename from NewKernel_d/include/CGAL/transforming_iterator.h rename to STL_Extension/include/CGAL/transforming_iterator.h diff --git a/NewKernel_d/include/CGAL/transforming_pair_iterator.h b/STL_Extension/include/CGAL/transforming_pair_iterator.h similarity index 100% rename from NewKernel_d/include/CGAL/transforming_pair_iterator.h rename to STL_Extension/include/CGAL/transforming_pair_iterator.h From 4d5521e644c804050e8968d4178e42fe35054705 Mon Sep 17 00:00:00 2001 From: Maxime Gimeno Date: Tue, 9 Apr 2019 14:55:53 +0200 Subject: [PATCH 48/56] fix list of packages --- .travis.yml | 8 ++++---- .travis/packages.txt | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index ce08a952ad6..11004ecf38d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,10 +48,10 @@ env: - PACKAGE='Surface_mesh_deformation Surface_mesher Surface_mesh_parameterization ' - PACKAGE='Surface_mesh_segmentation Surface_mesh_shortest_path Surface_mesh_simplification ' - PACKAGE='Surface_mesh_skeletonization Surface_sweep_2 TDS_2 ' - - PACKAGE='TDS_3 TestPackage Testsuite ' - - PACKAGE='Three Triangulation Triangulation_2 ' - - PACKAGE='Triangulation_3 Union_find Visibility_2 ' - - PACKAGE='Voronoi_diagram_2 wininst ' + - PACKAGE='TDS_3 Testsuite Three ' + - PACKAGE='Triangulation Triangulation_2 Triangulation_3 ' + - PACKAGE='Union_find Visibility_2 Voronoi_diagram_2 ' + - PACKAGE='wininst ' compiler: clang install: - echo "$PWD" diff --git a/.travis/packages.txt b/.travis/packages.txt index 77c9b4f26a5..fa151634628 100644 --- a/.travis/packages.txt +++ b/.travis/packages.txt @@ -125,7 +125,6 @@ Surface_mesh_skeletonization Surface_sweep_2 TDS_2 TDS_3 -TestPackage Testsuite Three Triangulation From 057c37828b3628bc93fcdd41f37dd311c5060cfd Mon Sep 17 00:00:00 2001 From: Andreas Fabri Date: Mon, 15 Apr 2019 12:26:03 +0200 Subject: [PATCH 49/56] Fix pragma push/pop --- NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h | 6 +++++- NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h index da4746af2c0..6153c237fb3 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h @@ -72,7 +72,11 @@ public: typedef R_ R; - +#if defined(BOOST_MSVC) && (BOOST_MSVC == 1900) +# pragma warning(push) +# pragma warning(disable: 4309) +#endif + template::type...>,std::tuple >::value>::type> explicit Point_d(U&&...u) : Rep(CPBase()(std::forward(u)...)){} diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h index f055a3f1e04..f62b349b846 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h @@ -72,6 +72,10 @@ public: typedef R_ R; +#if defined(BOOST_MSVC) && (BOOST_MSVC == 1900) +# pragma warning(push) +# pragma warning(disable: 4309) +#endif template::type...>,std::tuple >::value>::type> explicit Vector_d(U&&...u) : Rep(CVBase()(std::forward(u)...)){} From 2dde8a1ddbd68409d4ae24e3efe646d9fff7a547 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Mon, 15 Apr 2019 14:51:10 +0200 Subject: [PATCH 50/56] Revert "Move Handle." This reverts commit 80f8788fa49350ca3e024665af2f936244295c4d. --- STL_Extension/include/CGAL/Handle.h | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/STL_Extension/include/CGAL/Handle.h b/STL_Extension/include/CGAL/Handle.h index 5b727e9883d..14304c4a7b8 100644 --- a/STL_Extension/include/CGAL/Handle.h +++ b/STL_Extension/include/CGAL/Handle.h @@ -58,14 +58,6 @@ class Handle PTR->count++; } - // When the counter becomes atomic, this may avoid a few atomic operations. - Handle(Handle&& x) - { - CGAL_precondition( x.PTR != static_cast(0) ); - PTR = x.PTR; - x.PTR = nullptr; - } - ~Handle() { if ( PTR && (--PTR->count == 0)) @@ -83,14 +75,6 @@ class Handle return *this; } - Handle& - operator=(Handle&& x) - { - CGAL_precondition( x.PTR != static_cast(0) ); - std::swap(PTR, x.PTR); - return *this; - } - int refs() const { return PTR->count; } From 8dd18734b139b47247f511215deade7deb701a7f Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 16 Apr 2019 10:48:20 +0200 Subject: [PATCH 51/56] Remove name of unused argument. --- Filtered_kernel/include/CGAL/Lazy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index 60d01a032a8..4369e9b28c1 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -129,7 +129,7 @@ auto exact(T const& t) {return make_transforming_iterator(t,[](auto const&u){ret template ::value>> auto approx(T const& t) {return make_transforming_iterator(t,[](auto const&u){return CGAL::approx(u);});} template ::value>> -unsigned depth(T const& t) {return 1;} // FIXME: depth(*t) would be better when t is valid, but not for end iterators, and the true answer would iterate on the range, but we can't do that with only one iterator... We need to replace iterators with ranges to solve that. +unsigned depth(T const&) {return 1;} // FIXME: depth(*t) would be better when t is valid, but not for end iterators, and the true answer would iterate on the range, but we can't do that with only one iterator... We need to replace iterators with ranges to solve that. #ifdef CGAL_LAZY_KERNEL_DEBUG template From 92f4a7d3ad60c8e4f1b5e2d74f056873d9409d2a Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Tue, 16 Apr 2019 11:43:10 +0200 Subject: [PATCH 52/56] std::abs --- NewKernel_d/test/NewKernel_d/Epick_d.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/NewKernel_d/test/NewKernel_d/Epick_d.cpp b/NewKernel_d/test/NewKernel_d/Epick_d.cpp index a088a6d263f..a86ac47685d 100644 --- a/NewKernel_d/test/NewKernel_d/Epick_d.cpp +++ b/NewKernel_d/test/NewKernel_d/Epick_d.cpp @@ -437,6 +437,7 @@ void test2i(){ assert(!ed(psp0,psp1)); assert(!ed(psp0,psp2)); assert(!ed(psp2,psp1)); + using std::abs; assert(abs(sd(cent0,psp0)-25)<.0001); assert(abs(sd(cent0,psp1)-25)<.0001); assert(abs(sd(cent0,psp2)-25)<.0001); From 2f709a40e51515da76dc3bbb0b9e0298354acffc Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Sun, 19 May 2019 23:42:49 +0200 Subject: [PATCH 53/56] Visual Studio 2015 is broken. --- Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h | 2 +- NewKernel_d/test/NewKernel_d/Epick_d.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h index e631ee2c4d0..5e2faa6a59f 100644 --- a/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h +++ b/Kernel_d/doc/Kernel_d/CGAL/Epeck_d.h @@ -38,7 +38,7 @@ or `Dynamic_dimension_tag`. In the latter case, the dimension of the space is sp \attention Only the interfaces specific to this class are listed below. Refer to the concepts for the rest. -\attention Known bugs: the functor `Kernel_d::Intersect_d` is not yet implemented. `Kernel_d::Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Kernel_d::Orientation_d` only works for points, not vectors. +\attention Known bugs: the functor `Kernel_d::Intersect_d` is not yet implemented. `Kernel_d::Contained_in_affine_hull` assumes that the iterators refer to an affinely independent family. `Kernel_d::Orientation_d` only works for points, not vectors. Visual Studio 2015 is not supported. \attention This kernel requires the \ref thirdpartyEigen "Eigen" library. diff --git a/NewKernel_d/test/NewKernel_d/Epick_d.cpp b/NewKernel_d/test/NewKernel_d/Epick_d.cpp index a86ac47685d..197e5cd85f9 100644 --- a/NewKernel_d/test/NewKernel_d/Epick_d.cpp +++ b/NewKernel_d/test/NewKernel_d/Epick_d.cpp @@ -720,9 +720,11 @@ int main(){ test2(); test2i(); test3(); test3(); +#if !defined _MSC_VER || _MSC_VER >= 1910 test2>>(); test3>>(); test3>(); +#endif } #endif From 45efa5a6c0335fddf3c54e2de5dfc67b1f29508c Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Tue, 4 Jun 2019 16:30:12 +0200 Subject: [PATCH 54/56] Tame a warning from MSVC 2015 ``` ...\include\CGAL/NewKernel_d/utils.h(85): warning C4552: '*': operator has no effect; expected operator with side-effect ...\include\CGAL/transforming_iterator.h(65): note: see reference to function template instantiation 'decltype(auto) CGAL::Scale::operator ()(FT) const' being compiled with [ FT=const double & ] ``` --- NewKernel_d/include/CGAL/NewKernel_d/utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/utils.h b/NewKernel_d/include/CGAL/NewKernel_d/utils.h index b3ebf0e10af..725a3c86697 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/utils.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/utils.h @@ -82,7 +82,7 @@ struct Has_type_different_from template decltype(auto) operator()(FT&& x)const { - return scale*std::forward(x); + return (scale*std::forward(x)); } }; template struct Divide { From de45c8341b3cdb1c9a413fedbdd4a47658c2d7c1 Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 5 Jun 2019 09:13:11 +0200 Subject: [PATCH 55/56] Protect std::max from macro substitution (the min/max macros...) --- Filtered_kernel/include/CGAL/Lazy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index 4369e9b28c1..68dd199809c 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -339,7 +339,7 @@ class Lazy_rep_n : Lazy_rep_n(const AC& ac, const EC& ec, LL&&...ll) : Lazy_rep(ac(CGAL::approx(ll)...)), EC(ec), l(std::forward(ll)...) { - this->set_depth(std::max({ -1, (int)CGAL::depth(ll)...}) + 1); + this->set_depth((std::max)({ -1, (int)CGAL::depth(ll)...}) + 1); } #ifdef CGAL_LAZY_KERNEL_DEBUG private: From 1957ecc26343281ce411888d40efc67132954feb Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Thu, 20 Jun 2019 10:14:26 +0200 Subject: [PATCH 56/56] Fix a warning See https://github.com/CGAL/cgal/pull/3660#issuecomment-503915741 --- NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h index e7a61332e57..65f73a2a182 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h @@ -149,7 +149,8 @@ template struct Compute_cartesian_coordinate { typedef Tag_true Is_exact; typedef decltype(std::declval()[0]) result_type; - result_type operator()(first_argument_type const& v,int i)const{ + template + result_type operator()(first_argument_type const& v,index_type i)const{ return v[i]; } };

l) const { return operator()(l.begin(),l.end()); } -#else - //TODO -#endif }; } @@ -1213,15 +1140,9 @@ template struct Compare_lexicographically : private Store_kernel { CI c(this->kernel()); -#ifdef CGAL_CXX11 auto a_begin=c(a,Begin_tag()); auto b_begin=c(b,Begin_tag()); auto a_end=c(a,End_tag()); -#else - typename CI::result_type a_begin=c(a,Begin_tag()); - typename CI::result_type b_begin=c(b,Begin_tag()); - typename CI::result_type a_end=c(a,End_tag()); -#endif result_type res; // can't we do slightly better for Uncertain<*> ? // after res=...; if(is_uncertain(res))return indeterminate(); @@ -1285,15 +1206,9 @@ template struct Equal_points : private Store_kernel { CI c(this->kernel()); -#ifdef CGAL_CXX11 auto a_begin=c(a,Begin_tag()); auto b_begin=c(b,Begin_tag()); auto a_end=c(a,End_tag()); -#else - typename CI::result_type a_begin=c(a,Begin_tag()); - typename CI::result_type b_begin=c(b,Begin_tag()); - typename CI::result_type a_end=c(a,End_tag()); -#endif result_type res = true; // Is using CGAL::possibly for Uncertain really an optimization? From 16af3fcf81bbd712e80c3da39f2dbaf539d6f3b4 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 15:21:04 +0100 Subject: [PATCH 23/56] Remove macro CGAL_BOOSTD --- NewKernel_d/include/CGAL/NewKernel_d/Cartesian_change_FT.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/KernelD_converter.h | 6 +++--- NewKernel_d/include/CGAL/NewKernel_d/utils.h | 2 -- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_change_FT.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_change_FT.h index c4bd9292612..25a22695385 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_change_FT.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_change_FT.h @@ -48,7 +48,7 @@ struct Cartesian_change_FT_base : public typedef transforming_iterator Vector_cartesian_const_iterator; //FIXME: use Iterator_list! /* - template::value_tag,FT_tag>::value> + template::value_tag,FT_tag>::value> struct Iterator : Get_type {}; template struct Iterator { typedef transforming_iterator::type> type; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/KernelD_converter.h b/NewKernel_d/include/CGAL/NewKernel_d/KernelD_converter.h index ce32236d774..f92eb11d1cd 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/KernelD_converter.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/KernelD_converter.h @@ -81,7 +81,7 @@ class KernelD_converter_ typedef typename Get_type::type K2_Obj; typedef typename Get_functor >::type K1_Conv; typedef KO_converter KOC; - typedef CGAL_BOOSTD is_same no_converter; + typedef std::is_same no_converter; typedef typename internal::Map_taglist_to_typelist::type::template contains duplicate; // Disable the conversion in some cases: @@ -99,10 +99,10 @@ class KernelD_converter_ //typedef typename KOC::result_type K2_Obj; public: using Base::operator(); // don't use directly, just make it accessible to the next level - K2_Obj helper(K1_Obj const& o,CGAL_BOOSTD true_type)const{ + K2_Obj helper(K1_Obj const& o, std::true_type)const{ return KOC()(this->myself().kernel(),this->myself().kernel2(),this->myself(),o); } - K2_Obj helper(K1_Obj const& o,CGAL_BOOSTD false_type)const{ + K2_Obj helper(K1_Obj const& o, std::false_type)const{ return K1_Conv(this->myself().kernel())(this->myself().kernel2(),this->myself(),o); } K2_Obj operator()(argument_type const& o)const{ diff --git a/NewKernel_d/include/CGAL/NewKernel_d/utils.h b/NewKernel_d/include/CGAL/NewKernel_d/utils.h index fa4c043138a..86448acef02 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/utils.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/utils.h @@ -43,8 +43,6 @@ #include #include -#define CGAL_BOOSTD std:: - namespace CGAL { namespace internal { BOOST_MPL_HAS_XXX_TRAIT_DEF(type) From c872a75e10a7501df84a9013ff1d1c844fcf3d6a Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 15:23:35 +0100 Subject: [PATCH 24/56] Remove macro CGAL_CONSTEXPR --- NewKernel_d/include/CGAL/Epeck_d.h | 4 ++-- NewKernel_d/include/CGAL/Epick_d.h | 12 ++++++------ .../include/CGAL/NewKernel_d/Cartesian_LA_base.h | 4 ++-- .../include/CGAL/NewKernel_d/Cartesian_base.h | 4 ++-- .../include/CGAL/NewKernel_d/Cartesian_change_FT.h | 8 ++++---- .../include/CGAL/NewKernel_d/Cartesian_filter_K.h | 8 ++++---- .../include/CGAL/NewKernel_d/Cartesian_filter_NT.h | 4 ++-- .../CGAL/NewKernel_d/Cartesian_static_filters.h | 8 ++++---- .../include/CGAL/NewKernel_d/Kernel_d_interface.h | 4 ++-- .../include/CGAL/NewKernel_d/Lazy_cartesian.h | 4 ++-- .../CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h | 8 ++++---- NewKernel_d/include/CGAL/NewKernel_d/utils.h | 1 - 12 files changed, 34 insertions(+), 35 deletions(-) diff --git a/NewKernel_d/include/CGAL/Epeck_d.h b/NewKernel_d/include/CGAL/Epeck_d.h index 8e88dc2d764..ced041e0887 100644 --- a/NewKernel_d/include/CGAL/Epeck_d.h +++ b/NewKernel_d/include/CGAL/Epeck_d.h @@ -46,8 +46,8 @@ template struct Epeck_d : CGAL_BASE { - CGAL_CONSTEXPR Epeck_d(){} - CGAL_CONSTEXPR Epeck_d(int d):CGAL_BASE(d){} + constexpr Epeck_d(){} + constexpr Epeck_d(int d):CGAL_BASE(d){} }; #undef CGAL_BASE } diff --git a/NewKernel_d/include/CGAL/Epick_d.h b/NewKernel_d/include/CGAL/Epick_d.h index 5728e41e745..f26a9faa547 100644 --- a/NewKernel_d/include/CGAL/Epick_d.h +++ b/NewKernel_d/include/CGAL/Epick_d.h @@ -44,8 +44,8 @@ template struct Epick_d_help1 : CGAL_BASE { - CGAL_CONSTEXPR Epick_d_help1(){} - CGAL_CONSTEXPR Epick_d_help1(int d):CGAL_BASE(d){} + constexpr Epick_d_help1(){} + constexpr Epick_d_help1(int d):CGAL_BASE(d){} }; #undef CGAL_BASE #define CGAL_BASE \ @@ -54,8 +54,8 @@ template struct Epick_d_help2 : CGAL_BASE { - CGAL_CONSTEXPR Epick_d_help2(){} - CGAL_CONSTEXPR Epick_d_help2(int d):CGAL_BASE(d){} + constexpr Epick_d_help2(){} + constexpr Epick_d_help2(int d):CGAL_BASE(d){} }; #undef CGAL_BASE #define CGAL_BASE \ @@ -67,8 +67,8 @@ template struct Epick_d : CGAL_BASE { - CGAL_CONSTEXPR Epick_d(){} - CGAL_CONSTEXPR Epick_d(int d):CGAL_BASE(d){} + constexpr Epick_d(){} + constexpr Epick_d(int d):CGAL_BASE(d){} }; #undef CGAL_BASE } diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_base.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_base.h index 533b953331c..cae9274f46a 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_base.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_base.h @@ -170,8 +170,8 @@ struct Cartesian_LA_base_d : public Dimension_base typedef CartesianDVectorBase::Identity_functor type; }; - CGAL_CONSTEXPR Cartesian_LA_base_d(){} - CGAL_CONSTEXPR Cartesian_LA_base_d(int d):Dimension_base(d){} + constexpr Cartesian_LA_base_d(){} + constexpr Cartesian_LA_base_d(int d):Dimension_base(d){} }; } //namespace CGAL diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_base.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_base.h index 72595f1a355..c7c6ed97ef4 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_base.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_base.h @@ -31,8 +31,8 @@ namespace CGAL { template < typename FT_, typename Dim_, typename Derived_=Default> struct Cartesian_base_d : public CGAL_BASE { - CGAL_CONSTEXPR Cartesian_base_d(){} - CGAL_CONSTEXPR Cartesian_base_d(int d):CGAL_BASE(d){} + constexpr Cartesian_base_d(){} + constexpr Cartesian_base_d(int d):CGAL_BASE(d){} }; #undef CGAL_BASE diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_change_FT.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_change_FT.h index 25a22695385..6d1725ac42e 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_change_FT.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_change_FT.h @@ -32,8 +32,8 @@ template < typename Base_, typename FT_, typename LA_=CGAL::LA_eigen struct Cartesian_change_FT : public Cartesian_change_FT_base { - CGAL_CONSTEXPR Cartesian_change_FT(){} - CGAL_CONSTEXPR Cartesian_change_FT(int d):Cartesian_change_FT_base(d){} + constexpr Cartesian_change_FT(){} + constexpr Cartesian_change_FT(int d):Cartesian_change_FT_base(d){} }; } //namespace CGAL diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_K.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_K.h index 7fa283baf11..50d24b3cf25 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_K.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_K.h @@ -33,12 +33,12 @@ template < typename Base_, typename AK_, typename EK_ > struct Cartesian_filter_K : public Base_, private Store_kernel, private Store_kernel2 { - CGAL_CONSTEXPR Cartesian_filter_K(){} - CGAL_CONSTEXPR Cartesian_filter_K(int d):Base_(d){} + constexpr Cartesian_filter_K(){} + constexpr Cartesian_filter_K(int d):Base_(d){} //FIXME: or do we want an instance of AK and EK belonging to this kernel, //instead of a reference to external ones? - CGAL_CONSTEXPR Cartesian_filter_K(AK_ const&a,EK_ const&b):Base_(),Store_kernel(a),Store_kernel2(b){} - CGAL_CONSTEXPR Cartesian_filter_K(int d,AK_ const&a,EK_ const&b):Base_(d),Store_kernel(a),Store_kernel2(b){} + constexpr Cartesian_filter_K(AK_ const&a,EK_ const&b):Base_(),Store_kernel(a),Store_kernel2(b){} + constexpr Cartesian_filter_K(int d,AK_ const&a,EK_ const&b):Base_(d),Store_kernel(a),Store_kernel2(b){} typedef Base_ Kernel_base; typedef AK_ AK; typedef EK_ EK; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_NT.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_NT.h index 99144377986..51a5cef6dd9 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_NT.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_filter_NT.h @@ -30,8 +30,8 @@ namespace CGAL { template < typename Base_ > struct Cartesian_filter_NT : public Base_ { - CGAL_CONSTEXPR Cartesian_filter_NT(){} - CGAL_CONSTEXPR Cartesian_filter_NT(int d):Base_(d){} + constexpr Cartesian_filter_NT(){} + constexpr Cartesian_filter_NT(int d):Base_(d){} typedef Base_ Kernel_base; typedef Cartesian_change_FT K1; typedef typename internal::Exact_field_selector::type>::Type Exact_nt; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h index 0963f87991d..49e6ae3a6e7 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_static_filters.h @@ -69,14 +69,14 @@ template struct Orientation_of_points_2 : private Store_k template struct Cartesian_static_filters : public R_ { - CGAL_CONSTEXPR Cartesian_static_filters(){} - CGAL_CONSTEXPR Cartesian_static_filters(int d):R_(d){} + constexpr Cartesian_static_filters(){} + constexpr Cartesian_static_filters(int d):R_(d){} }; template struct Cartesian_static_filters, R_, Derived_> : public R_ { - CGAL_CONSTEXPR Cartesian_static_filters(){} - CGAL_CONSTEXPR Cartesian_static_filters(int d):R_(d){} + constexpr Cartesian_static_filters(){} + constexpr Cartesian_static_filters(int d):R_(d){} typedef Cartesian_static_filters, R_, Derived_> Self; typedef typename Default::Get::type Derived; template struct Functor : Inherit_functor {}; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h index 9210cb07600..e1fae9c1958 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h @@ -29,8 +29,8 @@ namespace CGAL { template struct Kernel_d_interface : public Base_ { - CGAL_CONSTEXPR Kernel_d_interface(){} - CGAL_CONSTEXPR Kernel_d_interface(int d):Base_(d){} + constexpr Kernel_d_interface(){} + constexpr Kernel_d_interface(int d):Base_(d){} typedef Base_ Base; typedef Kernel_d_interface Kernel; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h index c62f3bbfde4..ddce8b7ead2 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h @@ -148,8 +148,8 @@ template struct Lazy_cartesian : Lazy_cartesian_types > { - CGAL_CONSTEXPR Lazy_cartesian(){} - CGAL_CONSTEXPR Lazy_cartesian(int d):ak(d),ek(d){} + constexpr Lazy_cartesian(){} + constexpr Lazy_cartesian(int d):ak(d),ek(d){} //TODO: Do we want to store an AK and an EK? Or just references? //FIXME: references would be better I guess. diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h index fb769112a4e..f21e74ced6b 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Cartesian_wrap.h @@ -122,8 +122,8 @@ CGAL_REGISTER_OBJECT_WRAPPER(Weighted_point); template < typename Base_ , typename Derived_ = Default > struct Cartesian_wrap : public Base_ { - CGAL_CONSTEXPR Cartesian_wrap(){} - CGAL_CONSTEXPR Cartesian_wrap(int d):Base_(d){} + constexpr Cartesian_wrap(){} + constexpr Cartesian_wrap(int d):Base_(d){} typedef Base_ Kernel_base; typedef Cartesian_wrap Self; // TODO: pass the 2 types Self and Derived to the wrappers, they can use Self for most purposes and Derived only for Kernel_traits' typedef R. @@ -178,8 +178,8 @@ struct Cartesian_wrap : public Base_ template < typename Base_ > struct Cartesian_refcount : public Base_ { - CGAL_CONSTEXPR Cartesian_refcount(){} - CGAL_CONSTEXPR Cartesian_refcount(int d):Base_(d){} + constexpr Cartesian_refcount(){} + constexpr Cartesian_refcount(int d):Base_(d){} typedef Base_ Kernel_base; typedef Cartesian_refcount Self; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/utils.h b/NewKernel_d/include/CGAL/NewKernel_d/utils.h index 86448acef02..bd2122590c1 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/utils.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/utils.h @@ -34,7 +34,6 @@ #define CGAL_FORWARDABLE(T) T&& #define CGAL_FORWARD(T,t) std::forward(t) #define CGAL_MOVE(t) std::move(t) -#define CGAL_CONSTEXPR constexpr #include #include #include From 31dac099c57098153feacee86fffa30bc5e0437d Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 15:26:36 +0100 Subject: [PATCH 25/56] Remove macro CGAL_MOVE --- .../include/CGAL/NewKernel_d/Coaffine.h | 6 ++-- .../include/CGAL/NewKernel_d/Types/Sphere.h | 2 +- .../CGAL/NewKernel_d/Types/Weighted_point.h | 4 +-- .../NewKernel_d/function_objects_cartesian.h | 28 +++++++++---------- NewKernel_d/include/CGAL/NewKernel_d/utils.h | 1 - 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h b/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h index d60b5d896a8..6c81198b37d 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Coaffine.h @@ -215,7 +215,7 @@ template struct In_flat_orientation : private Store_kernel { if(*it != d) m(i,1+*it)=1; } - result_type ret = LA::sign_of_determinant(CGAL_MOVE(m)); + result_type ret = LA::sign_of_determinant(std::move(m)); if(o.reverse) ret=-ret; return ret; } @@ -264,7 +264,7 @@ template struct In_flat_side_of_oriented_sphere : private Store_kernel m(d+1,d+1)+=CGAL_NTS square(m(d+1,j+1)); } - result_type ret = -LA::sign_of_determinant(CGAL_MOVE(m)); + result_type ret = -LA::sign_of_determinant(std::move(m)); if(o.reverse) ret=-ret; return ret; } @@ -313,7 +313,7 @@ template struct In_flat_power_side_of_power_sphere_raw : private Store m(d+1,d+1)+=CGAL_NTS square(m(d+1,j+1)); } - result_type ret = -LA::sign_of_determinant(CGAL_MOVE(m)); + result_type ret = -LA::sign_of_determinant(std::move(m)); if(o.reverse) ret=-ret; return ret; } diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Sphere.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Sphere.h index b6c12e11c83..febe28022bd 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Sphere.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Sphere.h @@ -60,7 +60,7 @@ template struct Construct_sphere : Store_kernel { // It should be possible to avoid copying the center by moving this code to a constructor. Point center = cc(f, e); FT const& r2 = sd(center, *f); - return this->operator()(CGAL_MOVE(center), r2); + return this->operator()(std::move(center), r2); } }; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h index 8bb92abdcfe..a23a838ce78 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Weighted_point.h @@ -186,11 +186,11 @@ template struct Power_center : Store_kernel { CGAL_assertion (i == d); Vec res = typename CVec::Dimension()(d);; //std::cout << "Mat: " << m << "\n Vec: " << one << std::endl; - LA::solve(res, CGAL_MOVE(m), CGAL_MOVE(b)); + LA::solve(res, std::move(m), std::move(b)); //std::cout << "Sol: " << res << std::endl; Point center = cp(d,LA::vector_begin(res),LA::vector_end(res)); FT const& r2 = pdp (wp0, center); - return cwp(CGAL_MOVE(center), r2); + return cwp(std::move(center), r2); } }; } diff --git a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h index 808bcafc2bb..1153a19bafc 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h @@ -68,7 +68,7 @@ template struct Orientation_of_vectors : private Store_kernel { m(i,j)=c(v,j); } } - return R::LA::sign_of_determinant(CGAL_MOVE(m)); + return R::LA::sign_of_determinant(std::move(m)); } template =3)>::type> @@ -208,7 +208,7 @@ template struct Linear_rank : private Store_kernel { m(j,i)=c(v,j); } } - return R::LA::rank(CGAL_MOVE(m)); + return R::LA::rank(std::move(m)); } }; } @@ -264,7 +264,7 @@ template struct Contained_in_linear_hull : private Store_kernel { int r1 = R::LA::rank(m); // FIXME: Don't use eigen directly, go through an interface in LA... m.conservativeResize(Eigen::NoChange, n); - int r2 = R::LA::rank(CGAL_MOVE(m)); + int r2 = R::LA::rank(std::move(m)); return r1 == r2; // TODO: This is very very far from optimal... } @@ -298,7 +298,7 @@ template struct Affine_rank : private Store_kernel { // TODO: cache p0[j] in case it is computed? } } - return R::LA::rank(CGAL_MOVE(m)); + return R::LA::rank(std::move(m)); } }; } @@ -363,8 +363,8 @@ template struct Contained_in_simplex : private Store_kernel { } // If the simplex has full dimension, there must be a solution, only the signs need to be checked. if (n == d+1) - LA::solve(a,CGAL_MOVE(m),CGAL_MOVE(b)); - else if (!LA::solve_and_check(a,CGAL_MOVE(m),CGAL_MOVE(b))) + LA::solve(a,std::move(m),std::move(b)); + else if (!LA::solve_and_check(a,std::move(m),std::move(b))) return false; for(int i=0;i struct Linear_base : private Store_kernel { m(i,j)=c(v,j); } } - Matrix b = R::LA::basis(CGAL_MOVE(m)); + Matrix b = R::LA::basis(std::move(m)); for(int i=0; i < R::LA::columns(b); ++i){ //*o++ = Vector(b.col(i)); typedef @@ -529,9 +529,9 @@ template struct Power_side_of_power_sphere_raw : private Store_kernel< } } if(d%2) - return -LA::sign_of_determinant(CGAL_MOVE(m)); + return -LA::sign_of_determinant(std::move(m)); else - return LA::sign_of_determinant(CGAL_MOVE(m)); + return LA::sign_of_determinant(std::move(m)); } }; } @@ -587,9 +587,9 @@ template struct Side_of_oriented_sphere : private Store_kernel { } } if(d%2) - return -LA::sign_of_determinant(CGAL_MOVE(m)); + return -LA::sign_of_determinant(std::move(m)); else - return LA::sign_of_determinant(CGAL_MOVE(m)); + return LA::sign_of_determinant(std::move(m)); } template =4)>::type> @@ -644,7 +644,7 @@ template struct Construct_circumcenter : Store_kernel { CGAL_assertion (i == d); Vec res = typename CVec::Dimension()(d);; //std::cout << "Mat: " << m << "\n Vec: " << one << std::endl; - LA::solve(res, CGAL_MOVE(m), CGAL_MOVE(b)); + LA::solve(res, std::move(m), std::move(b)); //std::cout << "Sol: " << res << std::endl; return cp(d,LA::vector_begin(res),LA::vector_end(res)); } @@ -688,7 +688,7 @@ template struct Construct_circumcenter : Store_kernel { for(j=0;j #define CGAL_FORWARDABLE(T) T&& #define CGAL_FORWARD(T,t) std::forward(t) -#define CGAL_MOVE(t) std::move(t) #include #include #include From 4b369cd70e0ba71a75614a6950ee6d785b255aa7 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 15:34:02 +0100 Subject: [PATCH 26/56] Remove macro CGAL_FORWARDABLE --- NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/utils.h | 1 - 7 files changed, 6 insertions(+), 7 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h index e1fae9c1958..f75c2e8df07 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h @@ -168,7 +168,7 @@ template struct Kernel_d_interface : public Base_ { typedef Kernel R_; // for the macro CGAL_FUNCTOR_INIT_STORE(Compute_squared_radius_d) typedef FT result_type; - template FT operator()(CGAL_FORWARDABLE(S) s)const{ + template FT operator()(S&& s)const{ return typename Get_functor::type(this->kernel())(CGAL_FORWARD(S,s)); } template FT operator()(I b, I e)const{ diff --git a/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h b/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h index f61f80a79f0..4ec34b0454d 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h @@ -89,7 +89,7 @@ namespace CGAL { struct Iterator_and_last { template - result_type operator()(int d,Iter const& f,Iter const& e,CGAL_FORWARDABLE(T) t) const { + result_type operator()(int d,Iter const& f,Iter const& e,T&& t) const { check_dim(d); CGAL_assertion(d==std::distance(f,e)+1); result_type a(d); diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h index ddce8b7ead2..85cdad76330 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h @@ -37,7 +37,7 @@ struct Nth_iterator_element : private Store_kernel { Nth_iterator_element(){} Nth_iterator_element(K const&k):Store_kernel(k){} typedef typename Get_type::value_tag>::type result_type; - template result_type operator()(CGAL_FORWARDABLE(U) u, int i) const { + template result_type operator()(U&& u, int i) const { typename Get_functor >::type ci(this->kernel()); return *cpp0x::next(ci(CGAL_FORWARD(U,u),Begin_tag()),i); } diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h index cca4b3d6754..feba00c8f2b 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h @@ -82,7 +82,7 @@ template struct Construct_segment : Store_kernel { } // T should only be std::piecewise_construct_t, but we shouldn't fail if it doesn't exist. template - result_type operator()(CGAL_FORWARDABLE(T),CGAL_FORWARDABLE(U) u,CGAL_FORWARDABLE(V) v)const{ + result_type operator()(T&&, U&& u, V&& v)const{ CP cp(this->kernel()); result_type r = {{ call_on_tuple_elements(cp, CGAL_FORWARD(U,u)), diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h b/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h index 71e17313ced..c63b8b179af 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h @@ -93,7 +93,7 @@ template struct Array_vector { struct Iterator_and_last { template - Vector operator()(unsigned CGAL_assertion_code(d),Iter const& f,Iter const& e,CGAL_FORWARDABLE(T) t) const { + Vector operator()(unsigned CGAL_assertion_code(d),Iter const& f,Iter const& e,T&& t) const { CGAL_assertion(d==std::distance(f,e)+1); CGAL_assertion(d<=d_); //TODO: optimize for forward iterators diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h b/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h index 1f2023c0785..74f221ad1de 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h @@ -73,7 +73,7 @@ template struct Vector_vector { struct Iterator_and_last { template - Vector operator()(int d,Iter const& f,Iter const& e,CGAL_FORWARDABLE(T) t) const { + Vector operator()(int d,Iter const& f,Iter const& e,T&& t) const { CGAL_assertion(d==std::distance(f,e)+1); Vector a; a.reserve(d+1); diff --git a/NewKernel_d/include/CGAL/NewKernel_d/utils.h b/NewKernel_d/include/CGAL/NewKernel_d/utils.h index 5afe9c2b844..b467741ffc9 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/utils.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/utils.h @@ -31,7 +31,6 @@ #include #include -#define CGAL_FORWARDABLE(T) T&& #define CGAL_FORWARD(T,t) std::forward(t) #include #include From 7b2dfaccffbb3db74834b13ed5d0d45703504332 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 15:37:38 +0100 Subject: [PATCH 27/56] Remove macro CGAL_FORWARD --- .../include/CGAL/NewKernel_d/Kernel_d_interface.h | 2 +- .../include/CGAL/NewKernel_d/LA_eigen/constructors.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h | 4 ++-- NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h | 2 +- NewKernel_d/include/CGAL/NewKernel_d/utils.h | 9 ++++----- 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h index f75c2e8df07..e536b083f0a 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_d_interface.h @@ -169,7 +169,7 @@ template struct Kernel_d_interface : public Base_ { CGAL_FUNCTOR_INIT_STORE(Compute_squared_radius_d) typedef FT result_type; template FT operator()(S&& s)const{ - return typename Get_functor::type(this->kernel())(CGAL_FORWARD(S,s)); + return typename Get_functor::type(this->kernel())(std::forward(s)); } template FT operator()(I b, I e)const{ return typename Get_functor::type(this->kernel())(b,e); diff --git a/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h b/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h index 4ec34b0454d..9590964f7f4 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/LA_eigen/constructors.h @@ -94,7 +94,7 @@ namespace CGAL { CGAL_assertion(d==std::distance(f,e)+1); result_type a(d); std::copy(f,e,&a[0]); - a[d-1]=CGAL_FORWARD(T,t); + a[d-1]=std::forward(t); return a; } }; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h index 85cdad76330..3ada5ce2efe 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Lazy_cartesian.h @@ -39,7 +39,7 @@ struct Nth_iterator_element : private Store_kernel { typedef typename Get_type::value_tag>::type result_type; template result_type operator()(U&& u, int i) const { typename Get_functor >::type ci(this->kernel()); - return *cpp0x::next(ci(CGAL_FORWARD(U,u),Begin_tag()),i); + return *cpp0x::next(ci(std::forward(u),Begin_tag()),i); } }; //typedef typename Functor::nth_element>::type nth_elem; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h index feba00c8f2b..4434182c382 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h @@ -85,8 +85,8 @@ template struct Construct_segment : Store_kernel { result_type operator()(T&&, U&& u, V&& v)const{ CP cp(this->kernel()); result_type r = {{ - call_on_tuple_elements(cp, CGAL_FORWARD(U,u)), - call_on_tuple_elements(cp, CGAL_FORWARD(V,v)) }}; + call_on_tuple_elements(cp, std::forward(u)), + call_on_tuple_elements(cp, std::forward(v)) }}; return r; } }; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h b/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h index c63b8b179af..85b7f638b3f 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Vector/array.h @@ -99,7 +99,7 @@ template struct Array_vector { //TODO: optimize for forward iterators Vector a; std::copy(f,e,a.begin()); - a.back()=CGAL_FORWARD(T,t); + a.back()=std::forward(t); return a; } }; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h b/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h index 74f221ad1de..17157fb950b 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Vector/vector.h @@ -78,7 +78,7 @@ template struct Vector_vector { Vector a; a.reserve(d+1); a.insert(a.end(),f,e); - a.push_back(CGAL_FORWARD(T,t)); + a.push_back(std::forward(t)); return a; } }; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/utils.h b/NewKernel_d/include/CGAL/NewKernel_d/utils.h index b467741ffc9..7b7981bc2ae 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/utils.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/utils.h @@ -31,7 +31,6 @@ #include #include -#define CGAL_FORWARD(T,t) std::forward(t) #include #include #include @@ -83,7 +82,7 @@ struct Has_type_different_from template decltype(auto) operator()(FT&& x)const { - return scale*CGAL_FORWARD(FT,x); + return scale*std::forward(x); } }; template struct Divide { @@ -104,7 +103,7 @@ struct Has_type_different_from NT operator()(FT&& x)const { return Rational_traits(). - make_rational(CGAL_FORWARD(FT,x),scale); + make_rational(std::forward(x),scale); } }; @@ -120,7 +119,7 @@ struct Has_type_different_from template decltype(auto) operator()(A&&a,B&&b)const { - return CGAL_FORWARD(A,a)*CGAL_FORWARD(B,b); + return std::forward(a)*std::forward(b); } }; template < class Ret > @@ -128,7 +127,7 @@ struct Has_type_different_from template decltype(auto) operator()(A&&a,B&&b)const { - return CGAL_FORWARD(A,a)/CGAL_FORWARD(B,b); + return std::forward(a)/std::forward(b); } }; From 7d9e2a45fca36dfe3e21b7ae08f9966cb8d12f38 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 15:54:56 +0100 Subject: [PATCH 28/56] Remove some result_of --- .../CGAL/NewKernel_d/Wrapper/Point_d.h | 107 +----------------- .../CGAL/NewKernel_d/Wrapper/Vector_d.h | 107 ++---------------- 2 files changed, 13 insertions(+), 201 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h index d4fe244e6c3..37bcef5d25a 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h @@ -31,7 +31,6 @@ #include #include #include -#include namespace CGAL { namespace Wrap { @@ -104,18 +103,18 @@ public: : Rep(CPBase()(std::move(v))) {} - typename boost::result_of::type cartesian(int i)const{ + decltype(auto) cartesian(int i)const{ return CCBase()(rep(),i); } - typename boost::result_of::type operator[](int i)const{ + decltype(auto) operator[](int i)const{ return CCBase()(rep(),i); } - typename boost::result_of::type cartesian_begin()const{ + decltype(auto) cartesian_begin()const{ return CPI()(rep(),Begin_tag()); } - typename boost::result_of::type cartesian_end()const{ + decltype(auto) cartesian_end()const{ return CPI()(rep(),End_tag()); } @@ -131,94 +130,6 @@ public: friend auto operator!=(Point_d const&p, Point_d const&q) { return !(p==q); } - /* - Direction_d direction() const - { - return R().construct_direction_d_object()(*this); - } - - Vector_d transform(const Aff_transformation_d &t) const - { - return t.transform(*this); - } - - Vector_d operator/(const RT& c) const - { - return R().construct_divided_vector_d_object()(*this,c); - } - - Vector_d operator/(const typename First_if_different::Type & c) const - { - return R().construct_divided_vector_d_object()(*this,c); - } - - typename Qualified_result_of::type - x() const - { - return R().compute_x_3_object()(*this); - } - - typename Qualified_result_of::type - y() const - { - return R().compute_y_3_object()(*this); - } - - typename Qualified_result_of::type - z() const - { - return R().compute_z_3_object()(*this); - } - - typename Qualified_result_of::type - hx() const - { - return R().compute_hx_3_object()(*this); - } - - typename Qualified_result_of::type - hy() const - { - return R().compute_hy_3_object()(*this); - } - - typename Qualified_result_of::type - hz() const - { - return R().compute_hz_3_object()(*this); - } - - typename Qualified_result_of::type - hw() const - { - return R().compute_hw_3_object()(*this); - } - - typename Qualified_result_of::type - cartesian(int i) const - { - CGAL_kernel_precondition( (i == 0) || (i == 1) || (i == 2) ); - if (i==0) return x(); - if (i==1) return y(); - return z(); - } - - typename Qualified_result_of::type - homogeneous(int i) const - { - CGAL_kernel_precondition( (i >= 0) || (i <= 3) ); - if (i==0) return hx(); - if (i==1) return hy(); - if (i==2) return hz(); - return hw(); - } - - typename Qualified_result_of::type - squared_length() const - { - return R().compute_squared_length_3_object()(*this); - } -*/ }; #if 0 template Point_d::Point_d(Point_d &)=default; @@ -227,14 +138,8 @@ template Point_d::Point_d(Point_d &)=default; template std::ostream& operator <<(std::ostream& os, const Point_d& p) { - typedef typename R_::Kernel_base Kbase; - typedef typename Get_functor >::type CPI; - // Should just be "auto"... - typename CGAL::decay::Rep,Begin_tag) - >::type>::type - b = p.cartesian_begin(), - e = p.cartesian_end(); + auto b = p.cartesian_begin(); + auto e = p.cartesian_end(); if(is_ascii(os)) { os << p.dimension(); diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h index 4df349df909..ec32210e88f 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h @@ -102,19 +102,19 @@ public: : Rep(CVBase()(std::move(v))) {} - typename boost::result_of::type cartesian(int i)const{ + decltype(auto) cartesian(int i)const{ return CCBase()(rep(),i); } - typename boost::result_of::type operator[](int i)const{ + decltype(auto) operator[](int i)const{ return CCBase()(rep(),i); } - typename boost::result_of::type cartesian_begin()const{ + decltype(auto) cartesian_begin()const{ return CVI()(rep(),Begin_tag()); } - typename boost::result_of::type cartesian_end()const{ + decltype(auto) cartesian_end()const{ return CVI()(rep(),End_tag()); } @@ -123,99 +123,12 @@ public: return typename Get_functor::type()(*this); } - /* - Direction_d direction() const - { - return R().construct_direction_d_object()(*this); - } - - Vector_d transform(const Aff_transformation_d &t) const - { - return t.transform(*this); - } - - Vector_d operator/(const RT& c) const - { - return R().construct_divided_vector_d_object()(*this,c); - } - - Vector_d operator/(const typename First_if_different::Type & c) const - { - return R().construct_divided_vector_d_object()(*this,c); - } - - typename Qualified_result_of::type - x() const - { - return R().compute_x_3_object()(*this); - } - - typename Qualified_result_of::type - y() const - { - return R().compute_y_3_object()(*this); - } - - typename Qualified_result_of::type - z() const - { - return R().compute_z_3_object()(*this); - } - - typename Qualified_result_of::type - hx() const - { - return R().compute_hx_3_object()(*this); - } - - typename Qualified_result_of::type - hy() const - { - return R().compute_hy_3_object()(*this); - } - - typename Qualified_result_of::type - hz() const - { - return R().compute_hz_3_object()(*this); - } - - typename Qualified_result_of::type - hw() const - { - return R().compute_hw_3_object()(*this); - } - - typename Qualified_result_of::type - cartesian(int i) const - { - CGAL_kernel_precondition( (i == 0) || (i == 1) || (i == 2) ); - if (i==0) return x(); - if (i==1) return y(); - return z(); - } - - typename Qualified_result_of::type - homogeneous(int i) const - { - CGAL_kernel_precondition( (i >= 0) || (i <= 3) ); - if (i==0) return hx(); - if (i==1) return hy(); - if (i==2) return hz(); - return hw(); - } - - int dimension() const // bad idea? - { - return rep.dimension(); - } -*/ int dimension() const { typedef typename Get_functor::type VDBase; return VDBase()(rep()); } - typename boost::result_of::type squared_length()const{ + decltype(auto) squared_length()const{ return SLBase()(rep()); } }; @@ -226,14 +139,8 @@ template Vector_d::Vector_d(Vector_d &)=default; template std::ostream& operator <<(std::ostream& os, const Vector_d& v) { - typedef typename R_::Kernel_base Kbase; - typedef typename Get_functor >::type CVI; - // Should just be "auto"... - typename CGAL::decay::Rep,Begin_tag) - >::type>::type - b = v.cartesian_begin(), - e = v.cartesian_end(); + auto b = v.cartesian_begin(); + auto e = v.cartesian_end(); if(is_ascii(os)) { os << v.dimension(); From 9fef604bc2846622bf5e48a4bdfba06c86a95bc6 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 16:03:07 +0100 Subject: [PATCH 29/56] Move some operators to inline friends. It gives nicer error messages... --- .../CGAL/NewKernel_d/Wrapper/Point_d.h | 105 +++++++------- .../CGAL/NewKernel_d/Wrapper/Vector_d.h | 129 +++++++++--------- 2 files changed, 111 insertions(+), 123 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h index 37bcef5d25a..6c1020063f1 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Point_d.h @@ -130,66 +130,61 @@ public: friend auto operator!=(Point_d const&p, Point_d const&q) { return !(p==q); } + friend std::ostream& operator <<(std::ostream& os, const Point_d& p) + { + auto b = p.cartesian_begin(); + auto e = p.cartesian_end(); + if(is_ascii(os)) + { + os << p.dimension(); + for(; b != e; ++b){ + os << " " << *b; + } + } + else + { + write(os, p.dimension()); + for(; b != e; ++b){ + write(os, *b); + } + } + return os; + } + + // TODO: test if the stream is binary or text? + friend std::istream& operator>>(std::istream &is, Point_d & p) + { + int dim; + if( is_ascii(is) ) + is >> dim; + else + { + read(is, dim); + } + + if(!is) return is; + std::vector coords(dim); + if(is_ascii(is)) + { + for(int i=0;i> iformat(coords[i]); + } + else + { + for(int i=0;i Point_d::Point_d(Point_d &)=default; #endif -template -std::ostream& operator <<(std::ostream& os, const Point_d& p) -{ - auto b = p.cartesian_begin(); - auto e = p.cartesian_end(); - if(is_ascii(os)) - { - os << p.dimension(); - for(; b != e; ++b){ - os << " " << *b; - } - } - else - { - write(os, p.dimension()); - for(; b != e; ++b){ - write(os, *b); - } - } - return os; -} - -// TODO: test if the stream is binary or text? -template -std::istream & -operator>>(std::istream &is, Point_d & p) -{ - typedef typename Get_type::type P; - typedef typename Get_type::type FT; - int dim; - if( is_ascii(is) ) - is >> dim; - else - { - read(is, dim); - } - - if(!is) return is; - std::vector coords(dim); - if(is_ascii(is)) - { - for(int i=0;i> iformat(coords[i]); - } - else - { - for(int i=0;i //Vector_d operator+(const Vector_d& v,const Vector_d& w) const diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h index ec32210e88f..4bfeb18f78b 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Wrapper/Vector_d.h @@ -131,79 +131,72 @@ public: decltype(auto) squared_length()const{ return SLBase()(rep()); } + + friend std::ostream& operator <<(std::ostream& os, const Vector_d& v) + { + auto b = v.cartesian_begin(); + auto e = v.cartesian_end(); + if(is_ascii(os)) + { + os << v.dimension(); + for(; b != e; ++b){ + os << " " << *b; + } + } + else + { + write(os, v.dimension()); + for(; b != e; ++b){ + write(os, *b); + } + } + + return os; + } + + friend std::istream & operator>>(std::istream &is, Vector_d & v) + { + int dim; + if( is_ascii(is) ) + is >> dim; + else + { + read(is, dim); + } + if(!is) return is; + + std::vector coords(dim); + if(is_ascii(is)) + { + for(int i=0;i> iformat(coords[i]); + } + else + { + for(int i=0;i::type()(v,w); + } + + friend Vector_d operator-(const Vector_d& v,const Vector_d& w) + { + return typename Get_functor::type()(v,w); + } }; #if 0 template Vector_d::Vector_d(Vector_d &)=default; #endif -template -std::ostream& operator <<(std::ostream& os, const Vector_d& v) -{ - auto b = v.cartesian_begin(); - auto e = v.cartesian_end(); - if(is_ascii(os)) - { - os << v.dimension(); - for(; b != e; ++b){ - os << " " << *b; - } - } - else - { - write(os, v.dimension()); - for(; b != e; ++b){ - write(os, *b); - } - } - - return os; -} - - -template -std::istream & -operator>>(std::istream &is, Vector_d & v) -{ - typedef typename Get_type::type V; - typedef typename Get_type::type FT; - int dim; - if( is_ascii(is) ) - is >> dim; - else - { - read(is, dim); - } - if(!is) return is; - - std::vector coords(dim); - if(is_ascii(is)) - { - for(int i=0;i> iformat(coords[i]); - } - else - { - for(int i=0;i -Vector_d operator+(const Vector_d& v,const Vector_d& w) -{ - return typename Get_functor::type()(v,w); -} - -template -Vector_d operator-(const Vector_d& v,const Vector_d& w) -{ - return typename Get_functor::type()(v,w); -} } //namespace Wrap } //namespace CGAL From 02cfcafb72ae09d2f2c84e68e87fa6e03632af58 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 16:16:20 +0100 Subject: [PATCH 30/56] Replace some boost with std. It doesn't help much, but we should still stop using those boost facilities that are now standard. --- .../CGAL/NewKernel_d/Cartesian_LA_functors.h | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h index da49afa43c2..e7a61332e57 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Cartesian_LA_functors.h @@ -28,6 +28,7 @@ #include #include #include +#include namespace CGAL { namespace CartesianDVectorBase { @@ -66,7 +67,7 @@ template struct Construct_LA_vector } template typename std::enable_if::value && - boost::is_same, Dimension>::value, + std::is_same, Dimension>::value, result_type>::type operator()(U&&...u)const{ return typename Constructor::Values()(std::forward(u)...); @@ -74,19 +75,19 @@ template struct Construct_LA_vector //template::value>::type,class=typename std::enable_if<(sizeof...(U)==static_dim+1)>::type,class=void> template typename std::enable_if::value && - boost::is_same, Dimension>::value, + std::is_same, Dimension>::value, result_type>::type operator()(U&&...u)const{ return Apply_to_last_then_rest()(typename Constructor::Values_divide(),std::forward(u)...); } template inline - typename boost::enable_if,result_type>::type operator() + typename std::enable_if_t::value,result_type> operator() (Iter f,Iter g,Cartesian_tag t)const { return this->operator()((int)std::distance(f,g),f,g,t); } template inline - typename boost::enable_if,result_type>::type operator() + typename std::enable_if_t::value,result_type> operator() (int d,Iter f,Iter g,Cartesian_tag)const { CGAL_assertion(d==std::distance(f,g)); @@ -94,28 +95,28 @@ template struct Construct_LA_vector return typename Constructor::Iterator()(d,f,g); } template inline - typename boost::enable_if,result_type>::type operator() + typename std::enable_if_t::value,result_type> operator() (Iter f,Iter g,Homogeneous_tag)const { --g; return this->operator()((int)std::distance(f,g),f,g,*g); } template inline - typename boost::enable_if,result_type>::type operator() + typename std::enable_if_t::value,result_type> operator() (int d,Iter f,Iter g,Homogeneous_tag)const { --g; return this->operator()(d,f,g,*g); } template inline - typename boost::enable_if,result_type>::type operator() + typename std::enable_if_t::value,result_type> operator() (Iter f,Iter g)const { // Shouldn't it try comparing dist(f,g) to the dimension if it is known? return this->operator()(f,g,typename R::Rep_tag()); } template inline - typename boost::enable_if,result_type>::type operator() + typename std::enable_if_t::value,result_type> operator() (int d,Iter f,Iter g)const { return this->operator()(d,f,g,typename R::Rep_tag()); @@ -123,7 +124,7 @@ template struct Construct_LA_vector // Last homogeneous coordinate given separately template inline - typename boost::enable_if,result_type>::type operator() + typename std::enable_if_t::value,result_type> operator() (int d,Iter f,Iter g,NT const&l)const { CGAL_assertion(d==std::distance(f,g)); @@ -132,7 +133,7 @@ template struct Construct_LA_vector return typename Constructor::Iterator()(d,CGAL::make_transforming_iterator(f,Divide(l)),CGAL::make_transforming_iterator(g,Divide(l))); } template inline - typename boost::enable_if,result_type>::type operator() + typename std::enable_if_t::value,result_type> operator() (Iter f,Iter g,NT const&l)const { return this->operator()((int)std::distance(f,g),f,g,l); From f099add88eb627dce8063426ce3a4fcc5ac86762 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Fri, 8 Feb 2019 16:54:08 +0100 Subject: [PATCH 31/56] Various small simplifications --- .../CGAL/NewKernel_d/Filtered_predicate2.h | 4 +--- .../NewKernel_d/Kernel_object_converter.h | 6 +++--- .../include/CGAL/NewKernel_d/Types/Segment.h | 4 ++-- .../NewKernel_d/function_objects_cartesian.h | 4 ++-- NewKernel_d/include/CGAL/NewKernel_d/utils.h | 21 ++++++------------- 5 files changed, 14 insertions(+), 25 deletions(-) diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h b/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h index 1fff3e19a49..323537d6776 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Filtered_predicate2.h @@ -60,8 +60,6 @@ class Filtered_predicate2 C2E c2e; C2A c2a; - typedef typename AP::result_type Ares; - public: typedef AP Approximate_predicate; @@ -92,7 +90,7 @@ public: try { // No forward here, the arguments may still be needed - Ares res = ap(c2a(args)...); + auto res = ap(c2a(args)...); if (is_certain(res)) return get_certain(res); } diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h index 3022ec4997a..93d279361dc 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Kernel_object_converter.h @@ -49,15 +49,15 @@ template struct Point_converter_help,K1,K2> { typedef typename Get_type::type argument_type; typedef typename Get_type::type result_type; - template - result_type help(Indices, K1 const& k1, K2 const& k2, C const& conv, argument_type const& p) const { + template + result_type help(std::index_sequence, K1 const& k1, K2 const& k2, C const& conv, argument_type const& p) const { typename Get_functor::type cc(k1); typename Get_functor >::type cp(k2); return cp(conv(cc(p,I))...); } template result_type operator()(K1 const& k1, K2 const& k2, C const& conv, argument_type const& p) const { - return help(typename N_increasing_indices::type(),k1,k2,conv,p); + return help(std::make_index_sequence(),k1,k2,conv,p); } }; } diff --git a/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h b/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h index 4434182c382..913700ba800 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/Types/Segment.h @@ -85,8 +85,8 @@ template struct Construct_segment : Store_kernel { result_type operator()(T&&, U&& u, V&& v)const{ CP cp(this->kernel()); result_type r = {{ - call_on_tuple_elements(cp, std::forward(u)), - call_on_tuple_elements(cp, std::forward(v)) }}; + call_on_tuple_elements(cp, std::forward(u)), + call_on_tuple_elements(cp, std::forward(v)) }}; return r; } }; diff --git a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h index 1153a19bafc..bc8427d3355 100644 --- a/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h +++ b/NewKernel_d/include/CGAL/NewKernel_d/function_objects_cartesian.h @@ -91,7 +91,7 @@ template struct Orientation_of_points,true> typedef typename Get_type::type Point; typedef typename Get_type::type result_type; templatestruct Help; - templatestruct Help > { + templatestruct Help > { template result_type operator()(C const&c,P const&x,T&&t)const{ return sign_of_determinant(c(std::get(t),I%d)-c(x,I%d)...); } @@ -99,7 +99,7 @@ template struct Orientation_of_points,true> template result_type operator()(P0 const&x,P&&...p)const{ static_assert(d==sizeof...(P),"Wrong number of arguments"); typename Get_functor::type c(this->kernel()); - return Help::type>()(c,x,std::forward_as_tuple(std::forward