From 0e0a2006462788362ca6043c59a66dd5ae86dfb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20M=C3=B6ller?= Date: Wed, 23 Nov 2011 17:52:38 +0000 Subject: [PATCH] * Using result_of instead of Qualified_result_of * limited refactoring in the lazy kernel * still bugs in circular_3 * still specialization problem with iso_rectangle --- .../include/CGAL/Cartesian/function_objects.h | 287 +++--- .../include/CGAL/Circular_arc_2.h | 28 +- .../include/CGAL/Circular_arc_point_2.h | 12 +- .../function_objects_on_circle_2.h | 88 +- .../function_objects_polynomial_circular.h | 164 ++-- Circular_kernel_2/include/CGAL/Line_arc_2.h | 18 +- .../include/CGAL/Circular_arc_3.h | 9 +- .../include/CGAL/Circular_arc_point_3.h | 9 +- .../function_objects_polynomial_sphere.h | 181 ++-- Circular_kernel_3/include/CGAL/Line_arc_3.h | 17 +- Filtered_kernel/include/CGAL/Lazy.h | 881 +++--------------- Filtered_kernel/include/CGAL/Lazy_kernel.h | 48 +- .../CGAL/Homogeneous/function_objects.h | 114 ++- Kernel_23/include/CGAL/Circle_2.h | 4 +- Kernel_23/include/CGAL/Circle_3.h | 8 +- Kernel_23/include/CGAL/Direction_2.h | 6 +- Kernel_23/include/CGAL/Direction_3.h | 8 +- Kernel_23/include/CGAL/Iso_cuboid_3.h | 34 +- Kernel_23/include/CGAL/Iso_rectangle_2.h | 22 +- Kernel_23/include/CGAL/Kernel/Type_mapper.h | 36 +- .../include/CGAL/Kernel/function_objects.h | 94 +- Kernel_23/include/CGAL/Plane_3.h | 8 +- Kernel_23/include/CGAL/Point_2.h | 16 +- Kernel_23/include/CGAL/Point_3.h | 18 +- Kernel_23/include/CGAL/Ray_2.h | 6 +- Kernel_23/include/CGAL/Ray_3.h | 12 +- Kernel_23/include/CGAL/Segment_2.h | 28 +- Kernel_23/include/CGAL/Segment_3.h | 37 +- Kernel_23/include/CGAL/Sphere_3.h | 4 +- Kernel_23/include/CGAL/Tetrahedron_3.h | 9 +- Kernel_23/include/CGAL/Triangle_2.h | 4 +- Kernel_23/include/CGAL/Triangle_3.h | 4 +- Kernel_23/include/CGAL/Vector_2.h | 16 +- Kernel_23/include/CGAL/Vector_3.h | 22 +- Kernel_23/include/CGAL/kernel_basic.h | 1 - .../include/CGAL/_test_cls_circle_2.h | 4 +- .../include/CGAL/_test_cls_iso_cuboid_3.h | 1 + STL_Extension/include/CGAL/min_max_n.h | 4 + 38 files changed, 836 insertions(+), 1426 deletions(-) diff --git a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h index 18180330912..2aa32a0dd22 100644 --- a/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h +++ b/Cartesian_kernel/include/CGAL/Cartesian/function_objects.h @@ -988,36 +988,35 @@ namespace CartesianKernelFunctors { typedef typename K::Point_2 Point_2; typedef typename K::Circle_2 Circle_2; public: - typedef FT result_type; + template + struct result { + typedef FT type; + }; + + template + struct result { + typedef const FT& type; + }; - const result_type& + const FT& operator()( const Circle_2& c) const { return c.rep().squared_radius(); } - result_type + FT operator()( const Point_2& /*p*/) const { return FT(0); } - result_type + FT operator()( const Point_2& p, const Point_2& q) const { return squared_radiusC2(p.x(), p.y(), q.x(), q.y()); } - result_type + FT operator()( const Point_2& p, const Point_2& q, const Point_2& r) const { return squared_radiusC2(p.x(), p.y(), q.x(), q.y(), r.x(), r.y()); } }; } //namespace CartesianKernelFunctors -#ifndef CGAL_CFG_DONT_OVERLOAD_TOO_MUCH -template < typename K> -struct Qualified_result_of, - typename K::Circle_2> -{ - typedef typename K::FT const & type; -}; -#endif - // For the non specialized template will do the right thing, // namely return a copy of an FT @@ -1104,22 +1103,22 @@ namespace CartesianKernelFunctors { template - class Compute_x_2 : Has_qrt + class Compute_x_2 { typedef typename K::FT FT; typedef typename K::Point_2 Point_2; typedef typename K::Vector_2 Vector_2; public: - typedef FT result_type; + typedef const FT& result_type; - const result_type & + result_type operator()(const Point_2& p) const { return p.rep().x(); } - const result_type & + result_type operator()(const Vector_2& v) const { return v.rep().x(); @@ -1127,22 +1126,22 @@ namespace CartesianKernelFunctors { }; template - class Compute_x_3 : Has_qrt + class Compute_x_3 { typedef typename K::FT FT; typedef typename K::Point_3 Point_3; typedef typename K::Vector_3 Vector_3; public: - typedef FT result_type; + typedef const FT& result_type; - const result_type & + result_type operator()(const Point_3& p) const { return p.rep().x(); } - const result_type & + result_type operator()(const Vector_3& v) const { return v.rep().x(); @@ -1151,22 +1150,22 @@ namespace CartesianKernelFunctors { template - class Compute_y_2 : Has_qrt + class Compute_y_2 { typedef typename K::FT FT; typedef typename K::Point_2 Point_2; typedef typename K::Vector_2 Vector_2; public: - typedef FT result_type; + typedef const FT& result_type; - const result_type & + result_type operator()(const Point_2& p) const { return p.rep().y(); } - const result_type & + result_type operator()(const Vector_2& v) const { return v.rep().y(); @@ -1175,22 +1174,22 @@ namespace CartesianKernelFunctors { template - class Compute_y_3 : Has_qrt + class Compute_y_3 { typedef typename K::FT FT; typedef typename K::Point_3 Point_3; typedef typename K::Vector_3 Vector_3; public: - typedef FT result_type; + typedef const FT& result_type; - const result_type & + result_type operator()(const Point_3& p) const { return p.rep().y(); } - const result_type & + result_type operator()(const Vector_3& v) const { return v.rep().y(); @@ -1198,22 +1197,22 @@ namespace CartesianKernelFunctors { }; template - class Compute_z_3 : Has_qrt + class Compute_z_3 { typedef typename K::FT FT; typedef typename K::Point_3 Point_3; typedef typename K::Vector_3 Vector_3; public: - typedef FT result_type; + typedef const FT& result_type; - const result_type & + result_type operator()(const Point_3& p) const { return p.rep().z(); } - const result_type & + result_type operator()(const Vector_3& v) const { return v.rep().z(); @@ -1223,15 +1222,15 @@ namespace CartesianKernelFunctors { template - class Compute_dx_2 : public Has_qrt + class Compute_dx_2 { typedef typename K::FT FT; - typedef typename K::Direction_2 Direction_2; + typedef typename K::Direction_2 Direction_2; public: - typedef FT result_type; + typedef const FT& result_type; - const result_type & + result_type operator()(const Direction_2& d) const { return d.rep().dx(); @@ -1239,15 +1238,15 @@ namespace CartesianKernelFunctors { }; template - class Compute_dx_3 : public Has_qrt + class Compute_dx_3 { typedef typename K::FT FT; - typedef typename K::Direction_3 Direction_3; + typedef typename K::Direction_3 Direction_3; public: - typedef FT result_type; + typedef const FT& result_type; - const result_type & + result_type operator()(const Direction_3& d) const { return d.rep().dx(); @@ -1255,15 +1254,15 @@ namespace CartesianKernelFunctors { }; template - class Compute_dy_2 : public Has_qrt + class Compute_dy_2 { typedef typename K::FT FT; - typedef typename K::Direction_2 Direction_2; + typedef typename K::Direction_2 Direction_2; public: - typedef FT result_type; + typedef const FT& result_type; - const result_type & + result_type operator()(const Direction_2& d) const { return d.rep().dy(); @@ -1271,15 +1270,15 @@ namespace CartesianKernelFunctors { }; template - class Compute_dy_3 : public Has_qrt + class Compute_dy_3 { typedef typename K::FT FT; - typedef typename K::Direction_3 Direction_3; + typedef typename K::Direction_3 Direction_3; public: - typedef FT result_type; + typedef const FT& result_type; - const result_type & + result_type operator()(const Direction_3& d) const { return d.rep().dy(); @@ -1287,15 +1286,15 @@ namespace CartesianKernelFunctors { }; template - class Compute_dz_3 : public Has_qrt + class Compute_dz_3 { typedef typename K::FT FT; typedef typename K::Direction_3 Direction_3; public: - typedef FT result_type; + typedef const FT& result_type; - const result_type & + result_type operator()(const Direction_3& d) const { return d.rep().dz(); @@ -1303,68 +1302,68 @@ namespace CartesianKernelFunctors { }; template - class Compute_hx_2 : public Has_qrt - { - typedef typename K::FT FT; - typedef typename K::Point_2 Point_2; - typedef typename K::Vector_2 Vector_2; - - public: - typedef FT result_type; - - const result_type & - operator()(const Point_2& p) const - { - return p.rep().hx(); - } - - const result_type & - operator()(const Vector_2& v) const - { - return v.rep().hx(); - } - }; - - template - class Compute_hx_3 : public Has_qrt - { - typedef typename K::FT FT; - typedef typename K::Point_3 Point_3; - typedef typename K::Vector_3 Vector_3; - - public: - typedef FT result_type; - - const result_type & - operator()(const Point_3& p) const - { - return p.rep().hx(); - } - - const result_type & - operator()(const Vector_3& v) const - { - return v.rep().hx(); - } - }; - - template - class Compute_hy_2 : public Has_qrt + class Compute_hx_2 { typedef typename K::FT FT; typedef typename K::Point_2 Point_2; typedef typename K::Vector_2 Vector_2; public: - typedef FT result_type; + typedef const FT& result_type; - const result_type & + result_type + operator()(const Point_2& p) const + { + return p.rep().hx(); + } + + result_type + operator()(const Vector_2& v) const + { + return v.rep().hx(); + } + }; + + template + class Compute_hx_3 + { + typedef typename K::FT FT; + typedef typename K::Point_3 Point_3; + typedef typename K::Vector_3 Vector_3; + + public: + typedef const FT& result_type; + + result_type + operator()(const Point_3& p) const + { + return p.rep().hx(); + } + + result_type + operator()(const Vector_3& v) const + { + return v.rep().hx(); + } + }; + + template + class Compute_hy_2 + { + typedef typename K::FT FT; + typedef typename K::Point_2 Point_2; + typedef typename K::Vector_2 Vector_2; + + public: + typedef const FT& result_type; + + result_type operator()(const Point_2& p) const { return p.rep().hy(); } - const result_type & + result_type operator()(const Vector_2& v) const { return v.rep().hy(); @@ -1372,22 +1371,22 @@ namespace CartesianKernelFunctors { }; template - class Compute_hy_3 : public Has_qrt + class Compute_hy_3 { typedef typename K::FT FT; typedef typename K::Point_3 Point_3; typedef typename K::Vector_3 Vector_3; public: - typedef FT result_type; + typedef const FT& result_type; - const result_type & + result_type operator()(const Point_3& p) const { return p.rep().hy(); } - const result_type & + result_type operator()(const Vector_3& v) const { return v.rep().hy(); @@ -1395,22 +1394,22 @@ namespace CartesianKernelFunctors { }; template - class Compute_hz_3 : public Has_qrt + class Compute_hz_3 { typedef typename K::FT FT; typedef typename K::Point_3 Point_3; typedef typename K::Vector_3 Vector_3; public: - typedef FT result_type; + typedef const FT& result_type; - const result_type & + result_type operator()(const Point_3& p) const { return p.rep().hz(); } - const result_type & + result_type operator()(const Vector_3& v) const { return v.rep().hz(); @@ -1418,22 +1417,22 @@ namespace CartesianKernelFunctors { }; template - class Compute_hw_2 : public Has_qrt + class Compute_hw_2 { typedef typename K::FT FT; typedef typename K::Point_2 Point_2; typedef typename K::Vector_2 Vector_2; public: - typedef FT result_type; + typedef const FT& result_type; - const result_type & + result_type operator()(const Point_2& p) const { return p.rep().hw(); } - const result_type & + result_type operator()(const Vector_2& v) const { return v.rep().hw(); @@ -1441,22 +1440,22 @@ namespace CartesianKernelFunctors { }; template - class Compute_hw_3 : public Has_qrt + class Compute_hw_3 { typedef typename K::FT FT; typedef typename K::Point_3 Point_3; typedef typename K::Vector_3 Vector_3; public: - typedef FT result_type; + typedef const FT& result_type; - const result_type & + result_type operator()(const Point_3& p) const { return p.rep().hw(); } - const result_type & + result_type operator()(const Vector_3& v) const { return v.rep().hw(); @@ -1465,15 +1464,15 @@ namespace CartesianKernelFunctors { template - class Compute_xmin_2 : public Has_qrt + class Compute_xmin_2 { typedef typename K::FT FT; typedef typename K::Iso_rectangle_2 Iso_rectangle_2; public: - typedef FT result_type; + typedef const FT& result_type; - const result_type & + result_type operator()(const Iso_rectangle_2& r) const { return (r.min)().x(); @@ -1481,15 +1480,15 @@ namespace CartesianKernelFunctors { }; template - class Compute_xmax_2 : public Has_qrt + class Compute_xmax_2 { typedef typename K::FT FT; typedef typename K::Iso_rectangle_2 Iso_rectangle_2; public: - typedef FT result_type; + typedef const FT& result_type; - const result_type & + result_type operator()(const Iso_rectangle_2& r) const { return (r.max)().x(); @@ -1497,15 +1496,15 @@ namespace CartesianKernelFunctors { }; template - class Compute_ymin_2 : public Has_qrt + class Compute_ymin_2 { typedef typename K::FT FT; typedef typename K::Iso_rectangle_2 Iso_rectangle_2; public: - typedef FT result_type; + typedef const FT& result_type; - const result_type & + result_type operator()(const Iso_rectangle_2& r) const { return (r.min)().y(); @@ -1513,15 +1512,15 @@ namespace CartesianKernelFunctors { }; template - class Compute_ymax_2 : public Has_qrt + class Compute_ymax_2 { typedef typename K::FT FT; typedef typename K::Iso_rectangle_2 Iso_rectangle_2; public: - typedef FT result_type; + typedef const FT& result_type; - const result_type & + result_type operator()(const Iso_rectangle_2& r) const { return (r.max)().y(); @@ -3346,7 +3345,15 @@ namespace CartesianKernelFunctors { typedef typename K::Iso_rectangle_2 Iso_rectangle_2; typedef typename K::Triangle_2 Triangle_2; public: - typedef Point_2 result_type; + template + struct result { + typedef const Point_2& type; + }; + + template + struct result { + typedef Point_2 type; + }; const Point_2 & operator()( const Segment_2& s, int i) const @@ -3370,22 +3377,6 @@ namespace CartesianKernelFunctors { } //namespace CartesianKernelFunctors -#ifndef CGAL_CFG_DONT_OVERLOAD_TOO_MUCH -template < typename K> -struct Qualified_result_of, typename K::Segment_2, int > -{ - typedef typename K::Point_2 const & type; -}; - -template < typename K> -struct Qualified_result_of, typename K::Triangle_2, int > -{ - typedef typename K::Point_2 const & type; -}; -#endif - -// For Iso_rectangle the non specialized template will do the right thing, namely return a copy of a point - namespace CartesianKernelFunctors { template diff --git a/Circular_kernel_2/include/CGAL/Circular_arc_2.h b/Circular_kernel_2/include/CGAL/Circular_arc_2.h index 4d72a741cd4..e6a106b2b4d 100644 --- a/Circular_kernel_2/include/CGAL/Circular_arc_2.h +++ b/Circular_kernel_2/include/CGAL/Circular_arc_2.h @@ -109,33 +109,25 @@ public: {} - typename Qualified_result_of - ::type - //const Circular_arc_point_2 & + typename boost::result_of::type source() const { return typename R::Construct_circular_source_vertex_2()(*this); } - typename Qualified_result_of - ::type - //const Circular_arc_point_2 & + typename boost::result_of::type target() const { return typename R::Construct_circular_target_vertex_2()(*this); } - typename Qualified_result_of - ::type - //const Circular_arc_point_2 & + typename boost::result_of::type left() const { return typename R::Construct_circular_min_vertex_2()(*this); } - typename Qualified_result_of - ::type - //const Circular_arc_point_2 & + typename boost::result_of::type right() const { return typename R::Construct_circular_max_vertex_2()(*this); @@ -151,25 +143,19 @@ public: return typename R::Is_y_monotone_2()(*this); } - typename Qualified_result_of - ::type - // const Circle_2 & + typename boost::result_of::type supporting_circle() const { return typename R::Construct_circle_2()(*this); } - typename Qualified_result_of - ::type - // const Point_2 & + typename boost::result_of::type center() const { return typename R::Construct_center_2()(*this); } - typename Qualified_result_of - ::type - // const FT & + typename boost::result_of::type squared_radius() const { return typename R::Compute_squared_radius_2()(*this); diff --git a/Circular_kernel_2/include/CGAL/Circular_arc_point_2.h b/Circular_kernel_2/include/CGAL/Circular_arc_point_2.h index b6ec210fa71..a835880c01a 100644 --- a/Circular_kernel_2/include/CGAL/Circular_arc_point_2.h +++ b/Circular_kernel_2/include/CGAL/Circular_arc_point_2.h @@ -25,6 +25,8 @@ #ifndef CGAL_CIRCULAR_ARC_POINT_2_H #define CGAL_CIRCULAR_ARC_POINT_2_H +#include + namespace CGAL { template < typename CircularKernel > @@ -72,17 +74,15 @@ public: : RCircular_arc_point_2(typename R::Construct_circular_arc_point_2()(p)) {} - typename Qualified_result_of - ::type - //const Root_of_2 & + typename + boost::result_of::type x() const { return typename R::Compute_circular_x_2()(*this); } - typename Qualified_result_of - ::type - //const Root_of_2 & + typename + boost::result_of::type y() const { return typename R::Compute_circular_y_2()(*this); diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_on_circle_2.h b/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_on_circle_2.h index e757e8b871e..3cdc2c7cbcd 100644 --- a/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_on_circle_2.h +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_on_circle_2.h @@ -37,39 +37,79 @@ namespace CircularFunctors { template < class CK > class Construct_circle_2 : public CK::Linear_kernel::Construct_circle_2 { - public: - - typedef typename CK::Circular_arc_2 Circular_arc_2; - typedef typename CK::Linear_kernel::Construct_circle_2::result_type - result_type; + CK::Linear_kernel::Construct_circle_2 Base_functor; - using CK::Linear_kernel::Construct_circle_2::operator(); + typedef typename CK::Linear_kernel::Construct_circle_2::result_type + forwarded_result_type; + typedef typename CK::FT FT; + typedef typename CK::Linear_kernel::Point_2 Point_2; + + public: + Construct_circle_2() : Base_functor(CK().construct_circle_2_object()) {} + + template + struct result { + // all forwarded smoothly + typedef forwarded_result_type type; + }; + + template + struct result { + // this one returns a reference + typedef const forwared_result_type& type; + }; + + // forward the functors from Base_functor + forwarded_result_type + operator()( const Point_2& center, const FT& squared_radius, + Orientation orientation = COUNTERCLOCKWISE) const + { + return Base_functor(center, squared_radius, orientation); + } + + forwarded_result_type + operator()( const Point_2& p, const Point_2& q, const Point_2& r) const + { + return Base_functor(p, q, r); + } + + forwarded_result_type + operator()( const Point_2& p, const Point_2& q, + Orientation orientation = COUNTERCLOCKWISE) const + { + return Base_functor(p, q, orientation); + } + + forwarded_result_type + operator()( const Point_2& p, const Point_2& q, + const FT& bulge) const + { + return Base_functor(p, q, bulge); + } + + forwarded_result_type + operator()( const Point_2& center, + Orientation orientation = COUNTERCLOCKWISE) const + { + return Base_functor(center, orientation); + } + + typedef typename CK::Circular_arc_2 Circular_arc_2; result_type - operator() ( const typename CK::Polynomial_for_circles_2_2 &eq ) - { - return construct_circle_2(eq); - } + operator() ( const typename CK::Polynomial_for_circles_2_2 &eq ) { + return construct_circle_2(eq); + } - const result_type& - operator() (const Circular_arc_2 & a) const - { - return (a.rep().supporting_circle()); - } + const result_type& + operator() (const Circular_arc_2 & a) const { + return (a.rep().supporting_circle()); + } }; } // namespace CircularFunctors -#ifndef CGAL_CFG_DONT_OVERLOAD_TOO_MUCH - template < typename K> - struct Qualified_result_of, - typename K::Circular_arc_2> - { - typedef const typename K::Circle_2 & type; - }; -#endif - } // namespace CGAL #endif // CGAL_CIRCULAR_KERNEL_FUNCTION_OBJECTS_ON_CIRCLE_2_H diff --git a/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h b/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h index 61c8d75ce58..93cc3dc830e 100644 --- a/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h +++ b/Circular_kernel_2/include/CGAL/Circular_kernel_2/function_objects_polynomial_circular.h @@ -829,17 +829,15 @@ namespace CircularFunctors { template - class Compute_circular_x_2: Has_qrt + class Compute_circular_x_2 { typedef typename CK::Circular_arc_point_2 Circular_arc_point_2; typedef typename CK::Root_of_2 Root_of_2; public: + typedef const Root_of_2& result_type; - typedef Root_of_2 result_type; - typedef const result_type & qualified_result_type; - - qualified_result_type operator() (const Circular_arc_point_2 & a) const + result_type operator() (const Circular_arc_point_2 & a) const { return (a.rep().x()); } @@ -847,17 +845,16 @@ namespace CircularFunctors { template - class Compute_circular_y_2: Has_qrt - { + class Compute_circular_y_2 + { typedef typename CK::Circular_arc_point_2 Circular_arc_point_2; typedef typename CK::Root_of_2 Root_of_2; public: - typedef Root_of_2 result_type; - typedef const result_type & qualified_result_type; + typedef const Root_of_2& result_type; - qualified_result_type operator() (const Circular_arc_point_2 & a) const + result_type operator() (const Circular_arc_point_2 & a) const { return (a.rep().y()); } @@ -865,27 +862,21 @@ namespace CircularFunctors { template - class Construct_circular_min_vertex_2 : Has_qrt + class Construct_circular_min_vertex_2 { typedef typename CK::Circular_arc_2 Circular_arc_2; typedef typename CK::Line_arc_2 Line_arc_2; typedef typename CK::Circular_arc_point_2 Circular_arc_point_2; public: + typedef const Circular_arc_point_2 & result_type; - typedef Circular_arc_point_2 result_type; - typedef const result_type & qualified_result_type; - - qualified_result_type operator() (const Circular_arc_2 & a) const + result_type operator() (const Circular_arc_2 & a) const { -// if (a.rep().Cache_minmax == 't') -// return (a.rep().source()); -// if (a.rep().Cache_minmax == 's') -// return (a.rep().target()); return (a.rep().left()); } - qualified_result_type operator() (const Line_arc_2 & a) const + result_type operator() (const Line_arc_2 & a) const { return (a.rep().left()); } @@ -893,7 +884,7 @@ namespace CircularFunctors { }; template - class Construct_circular_max_vertex_2: Has_qrt + class Construct_circular_max_vertex_2 { typedef typename CK::Circular_arc_2 Circular_arc_2; typedef typename CK::Line_arc_2 Line_arc_2; @@ -901,19 +892,14 @@ namespace CircularFunctors { public: - typedef Circular_arc_point_2 result_type; - typedef const result_type & qualified_result_type; + typedef const Circular_arc_point_2& result_type; - qualified_result_type operator() (const Circular_arc_2 & a) const + result_type operator() (const Circular_arc_2 & a) const { -// if (a.rep().Cache_minmax == 's') -// return (a.rep().source()); -// if (a.rep().Cache_minmax == 't') -// return (a.rep().target()); return (a.rep().right()); } - qualified_result_type operator() (const Line_arc_2 & a) const + result_type operator() (const Line_arc_2 & a) const { return (a.rep().right()); } @@ -921,7 +907,7 @@ namespace CircularFunctors { }; template - class Construct_circular_source_vertex_2: Has_qrt + class Construct_circular_source_vertex_2 { typedef typename CK::Circular_arc_2 Circular_arc_2; typedef typename CK::Line_arc_2 Line_arc_2; @@ -929,20 +915,19 @@ namespace CircularFunctors { public: - typedef Circular_arc_point_2 result_type; - typedef const result_type & qualified_result_type; + typedef const Circular_arc_point_2& result_type; - qualified_result_type operator() (const Circular_arc_2 & a) const + result_type operator() (const Circular_arc_2 & a) const { return a.rep().source(); } - qualified_result_type operator() (const Line_arc_2 & a) const + result_type operator() (const Line_arc_2 & a) const { return a.rep().source();} }; template - class Construct_circular_target_vertex_2: Has_qrt + class Construct_circular_target_vertex_2 { typedef typename CK::Circular_arc_2 Circular_arc_2; typedef typename CK::Line_arc_2 Line_arc_2; @@ -950,13 +935,12 @@ namespace CircularFunctors { public: - typedef Circular_arc_point_2 result_type; - typedef const result_type & qualified_result_type; + typedef const Circular_arc_point_2& result_type; - qualified_result_type operator() (const Circular_arc_2 & a) const + result_type operator() (const Circular_arc_2 & a) const { return a.rep().target();} - qualified_result_type operator() (const Line_arc_2 & a) const + result_type operator() (const Line_arc_2 & a) const { return a.rep().target();} }; @@ -1194,7 +1178,7 @@ namespace CircularFunctors { #ifndef CGAL_NO_DEPRECATED_CODE template - class Construct_supporting_circle_2: Has_qrt + class Construct_supporting_circle_2 { typedef typename CK::Circular_arc_2 Circular_arc_2; typedef typename CK::Circle_2 Circle_2; @@ -1211,7 +1195,7 @@ namespace CircularFunctors { template - class Construct_supporting_line_2: Has_qrt + class Construct_supporting_line_2 { typedef typename CK::Line_arc_2 Line_arc_2; typedef typename CK::Line_2 Line_2; @@ -1232,32 +1216,28 @@ namespace CircularFunctors { class Construct_center_2 #ifndef CGAL_CFG_MATCHING_BUG_6 : public CK::Linear_kernel::Construct_center_2 - #else - : public Has_qrt #endif { + typedef typename CK::Linear_kernel::Construct_center_2::result_type result_type; typedef typename CK::Circular_arc_2 Circular_arc_2; - public: - - #ifndef CGAL_CFG_MATCHING_BUG_6 - typedef typename CK::Linear_kernel::Construct_center_2::result_type result_type; - using CK::Linear_kernel::Construct_center_2::operator(); - #else - + public: +#ifndef CGAL_CFG_MATCHING_BUG_6 + using CK::Linear_kernel::Construct_center_2::operator(); +#else + typedef typename CK::Linear_kernel LK; typedef typename LK::Construct_center_2 LK_Construct_center_2; - typedef typename CK::Point_2 Point_2; - typedef typename CK::Circle_2 Circle_2; - public: - typedef Point_2 result_type; + typedef typename CK::Point_2 Point_2; + typedef typename CK::Circle_2 Circle_2; - const result_type& - operator()( const Circle_2& c) const - { return LK_Construct_center_2()(c); } + public: + result_type + operator()( const Circle_2& c) const + { return LK_Construct_center_2()(c); } + +#endif - #endif - - const result_type& + result_type operator()(const Circular_arc_2& c) const { return c.rep().center(); } @@ -1265,75 +1245,55 @@ namespace CircularFunctors { template class Compute_squared_radius_2 -#ifndef CGAL_CFG_MATCHING_BUG_6 - : public CK::Linear_kernel::Compute_squared_radius_2 -#endif { + + private: typedef typename CK::Circular_arc_2 Circular_arc_2; - public: - -#ifndef CGAL_CFG_MATCHING_BUG_6 - typedef typename CK::Linear_kernel::Compute_squared_radius_2::result_type result_type; - using CK::Linear_kernel::Compute_squared_radius_2::operator(); -#else - typedef typename CK::Linear_kernel LK; typedef typename LK::Compute_squared_radius_2 LK_Compute_squared_radius_2; typedef typename CK::FT FT; typedef typename CK::Point_2 Point_2; typedef typename CK::Circle_2 Circle_2; + typedef FT forwarded_result_type; public: - typedef FT result_type; + template + struct result { + typedef forwarded_result_type type; + }; + + template + struct result { + typedef const forwarded_result_type& type; + }; + + template + struct result { + typedef const forwarded_result_type& type; + }; - const result_type& + const forwarded_result_type& operator()( const Circle_2& c) const { return LK_Compute_squared_radius_2()(c); } - result_type + forwarded_result_type operator()( const Point_2& p) const { return LK_Compute_squared_radius_2()(p); } - result_type + forwarded_result_type operator()( const Point_2& p, const Point_2& q) const { return LK_Compute_squared_radius_2()(p, q); } - result_type + forwarded_result_type operator()( const Point_2& p, const Point_2& q, const Point_2& r) const { return LK_Compute_squared_radius_2()(p, q, r); } -#endif - - const result_type& + const forwarded_result_type& operator()(const Circular_arc_2& c) const { return c.rep().squared_radius(); } }; } // namespace CircularFunctors - -#ifndef CGAL_CFG_DONT_OVERLOAD_TOO_MUCH - template < typename K> - struct Qualified_result_of, - typename K::Circular_arc_2> - { - typedef typename K::Point_2 const & type; - }; - - template < typename K> - struct Qualified_result_of, - typename K::Circular_arc_2> - { - typedef typename K::FT const & type; - }; - - template < typename K> - struct Qualified_result_of, - typename K::Circle_2> - { - typedef typename K::FT const & type; - }; -#endif - } // namespace CGAL #endif // CGAL_CIRCULAR_KERNEL_FUNCTION_OBJECTS_POLYNOMIAL_CIRCULAR_H diff --git a/Circular_kernel_2/include/CGAL/Line_arc_2.h b/Circular_kernel_2/include/CGAL/Line_arc_2.h index 61695eeb745..52d4a37a694 100644 --- a/Circular_kernel_2/include/CGAL/Line_arc_2.h +++ b/Circular_kernel_2/include/CGAL/Line_arc_2.h @@ -25,6 +25,8 @@ #ifndef CGAL_LINE_ARC_2_H #define CGAL_LINE_ARC_2_H +#include + namespace CGAL { template @@ -92,33 +94,25 @@ public: : RLine_arc_2(a) {} - typename Qualified_result_of - ::type - //const Circular_arc_point_2 & + typename boost::result_of::type source() const { return typename R::Construct_circular_source_vertex_2()(*this); } - typename Qualified_result_of - ::type - //const Circular_arc_point_2 & + typename boost;:result_of::type target() const { return typename R::Construct_circular_target_vertex_2()(*this); } - typename Qualified_result_of - ::type - //const Circular_arc_point_2 & left() const + typename boost;:result_of::type left() const { return typename R::Construct_circular_min_vertex_2()(*this); } - typename Qualified_result_of - ::type - //const Circular_arc_point_2 & right() const + typename boost;:result_of::type right() const { return typename R::Construct_circular_max_vertex_2()(*this); diff --git a/Circular_kernel_3/include/CGAL/Circular_arc_3.h b/Circular_kernel_3/include/CGAL/Circular_arc_3.h index 56715fde081..8efb590ea34 100644 --- a/Circular_kernel_3/include/CGAL/Circular_arc_3.h +++ b/Circular_kernel_3/include/CGAL/Circular_arc_3.h @@ -119,22 +119,19 @@ namespace CGAL { : RCircular_arc_3(a) {} - typename Qualified_result_of - ::type + typename boost::result_of::type source() const { return typename R::Construct_circular_source_vertex_3()(*this); } - typename Qualified_result_of - ::type + typename boost::result_of::type target() const { return typename R::Construct_circular_target_vertex_3()(*this); } - typename Qualified_result_of - ::type + typename boost::result_of::type supporting_circle() const { return typename R::Construct_circle_3()(*this); diff --git a/Circular_kernel_3/include/CGAL/Circular_arc_point_3.h b/Circular_kernel_3/include/CGAL/Circular_arc_point_3.h index 58a9e27f3b5..0cff98e7d6d 100644 --- a/Circular_kernel_3/include/CGAL/Circular_arc_point_3.h +++ b/Circular_kernel_3/include/CGAL/Circular_arc_point_3.h @@ -196,18 +196,15 @@ public: - typename Qualified_result_of::type - //const Root_of_2 & + typename boost::result_of::type x() const { return typename R::Compute_circular_x_3()(*this);} - typename Qualified_result_of::type - //const Root_of_2 & + typename boost::result_of::type y() const { return typename R::Compute_circular_y_3()(*this);} - typename Qualified_result_of::type - //const Root_of_2 & + typename boost::result_of::type z() const { return typename R::Compute_circular_z_3()(*this);} diff --git a/Circular_kernel_3/include/CGAL/Circular_kernel_3/function_objects_polynomial_sphere.h b/Circular_kernel_3/include/CGAL/Circular_kernel_3/function_objects_polynomial_sphere.h index 4fcc9f19945..33bcee9fa25 100644 --- a/Circular_kernel_3/include/CGAL/Circular_kernel_3/function_objects_polynomial_sphere.h +++ b/Circular_kernel_3/include/CGAL/Circular_kernel_3/function_objects_polynomial_sphere.h @@ -106,47 +106,44 @@ template < class SK > \ CGAL_SPHERICAL_KERNEL_MACRO_FUNCTOR_COMPARE_(xyz) template - class Compute_circular_x_3: Has_qrt + class Compute_circular_x_3 { typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; - typedef typename SK::Root_of_2 Root_of_2; + typedef typename SK::Root_of_2 Root_of_2; public: - typedef Root_of_2 result_type; - typedef const result_type & qualified_result_type; + typedef const Root_of_2& result_type; - qualified_result_type operator() (const Circular_arc_point_3 & a) const + result_type operator() (const Circular_arc_point_3 & a) const { return (a.rep().x()); } }; template - class Compute_circular_y_3: Has_qrt + class Compute_circular_y_3 { typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; typedef typename SK::Root_of_2 Root_of_2; public: - typedef Root_of_2 result_type; - typedef const result_type & qualified_result_type; + typedef const Root_of_2& result_type; - qualified_result_type operator() (const Circular_arc_point_3 & a) const + result_type operator() (const Circular_arc_point_3 & a) const { return (a.rep().y()); } }; template - class Compute_circular_z_3: Has_qrt + class Compute_circular_z_3 { typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; typedef typename SK::Root_of_2 Root_of_2; public: - typedef Root_of_2 result_type; - typedef const result_type & qualified_result_type; + typedef const Root_of_2& result_type; - qualified_result_type operator() (const Circular_arc_point_3 & a) const + result_type operator() (const Circular_arc_point_3 & a) const { return (a.rep().z()); } }; @@ -616,89 +613,83 @@ template < class SK > \ template class Construct_line_3 -#ifndef CGAL_CFG_MATCHING_BUG_6 - - : public SK::Linear_kernel::Construct_line_3 -#endif { typedef typename SK::Line_arc_3 Line_arc_3; typedef typename SK::Line_3 Line_3; + typedef typename SK::Linear_kernel::Construct_line_3::result_type forwarded_result_type; public: - - typedef typename SK::Linear_kernel::Construct_line_3::result_type - result_type; - - typedef const result_type & qualified_result_type; - -#ifndef CGAL_CFG_MATCHING_BUG_6 - using SK::Linear_kernel::Construct_line_3::operator(); -#else - typedef typename SK::Point_3 Point_3; typedef typename SK::Direction_3 Direction_3; typedef typename SK::Vector_3 Vector_3; typedef typename SK::Segment_3 Segment_3; typedef typename SK::Ray_3 Ray_3; - typedef typename SK::Linear_kernel::Construct_line_3 LK_Construct_line_3; + + template + struct result { + typedef forwarded_result_type type; + }; - result_type + template + struct result { + typdef const forwarded_result_type& type; + }; + + forwarded_result_type operator()(Return_base_tag, const Point_3& p, const Point_3& q) const { return LK_Construct_line_3()(p, Vector_3(p, q)); } - result_type + forwarded_result_type operator()(Return_base_tag, const Point_3& p, const Direction_3& d) const { return operator()(Return_base_tag(), p, Vector_3(d.dx(), d.dy(), d.dz())); } - result_type + forwarded_result_type operator()(Return_base_tag, const Point_3& p, const Vector_3& v) const { return LK_Construct_line_3()(p, v); } - result_type + forwarded_result_type operator()(Return_base_tag, const Segment_3& s) const { return LK_Construct_line_3()(s.source(), Vector_3(s.source(), s.target())); } - result_type + forwarded_result_type operator()(Return_base_tag, const Ray_3& r) const { return LK_Construct_line_3()(r.source(), Vector_3(r.source(), r.second_point())); } - result_type + forwarded_result_type operator()(const Point_3& p, const Point_3& q) const { return this->operator()(Return_base_tag(), p, q); } - result_type + forwarded_result_type operator()(const Point_3& p, const Direction_3& d) const { return this->operator()(Return_base_tag(), p, d); } - result_type + forwarded_result_type operator()(const Point_3& p, const Vector_3& v) const { return this->operator()(Return_base_tag(), p, v); } - result_type + forwarded_result_type operator()(const Segment_3& s) const { return this->operator()(Return_base_tag(), s); } - result_type + forwarded_result_type operator()(const Ray_3& r) const { return this->operator()(Return_base_tag(), r); } - -#endif - qualified_result_type operator() (const Line_arc_3 & a) const + const forwarded_result_type& operator() (const Line_arc_3 & a) const { return (a.rep().supporting_line()); } - result_type + forwarded_result_type operator() ( const typename SK::Polynomials_for_line_3 &eq ) { return SphericalFunctors::construct_line_3(eq); } }; template < class SK > - class Construct_circle_3 : public SK::Linear_kernel::Construct_circle_3 + class Construct_circle_3 { - public: - + typedef typename SK::Linear_kernel::Construct_circle_3 Extended; + typedef typename Extended::result_type forwarded_result_type; typedef typename SK::FT FT; typedef typename SK::Point_3 Point_3; typedef typename SK::Plane_3 Plane_3; @@ -709,17 +700,61 @@ template < class SK > \ typedef typename SK::Circular_arc_3 Circular_arc_3; typedef typename SK::Kernel_base::Circle_3 RCircle_3; typedef typename Circle_3::Rep Rep; + public: + template + struct result { + typedef forwarded_result_type type; + }; + + template + struct result { + typedef const forwarded_result_type& type; + }; - typedef typename SK::Linear_kernel::Construct_circle_3::result_type result_type; - typedef const result_type & qualified_result_type; + forwarded_result_type + operator()(const Point_3& p, const FT& sr, + const Plane_3& plane) const + { return Extended()(p, sr, plane); } - using SK::Linear_kernel::Construct_circle_3::operator(); + forwarded_result_type + operator() (const Point_3& p, const FT& sr, + const Vector_3& v) const + { return Extended()(p, sr, v); } - result_type + forwarded_result_type + operator() (const Point_3& p, const FT& sr, + const Direction_3& d) const + { return Extended()(p, sr, d); } + + forwarded_result_type + operator() (const Sphere_3& s1, const Sphere_3& s2) const + { return Extended()(s1, s2); } + + forwarded_result_type + operator() (const Plane_3& p, const Sphere_3& s) const + { return Extended()(p, s); } + + forwarded_result_type + operator() (const Sphere_3& s, const Plane_3& p) const + { return Extended()(p, s); } + + forwarded_result_type + operator() (const Plane_3& p, const Sphere_3& s, int a) const + { return Extended()(p, s, a); } + + forwarded_result_type + operator() (const Sphere_3& s, const Plane_3& p, int a) const + { return Extended()(p, s, a); } + + forwarded_result_type + operator()( const Point_3& p1, const Point_3& p2, const Point_3& p3) const + { return Extended()(p1, p2, p3); } + + forwarded_result_type operator() ( const typename SK::Polynomials_for_circle_3 &eq ) { return Rep(construct_circle_3(eq)); } - qualified_result_type + const forwarded_result_type& operator() (const Circular_arc_3 & a) const { return (a.rep().supporting_circle()); } @@ -881,39 +916,37 @@ template < class SK > \ }; template - class Construct_circular_min_vertex_3 : Has_qrt + class Construct_circular_min_vertex_3 { typedef typename SK::Line_arc_3 Line_arc_3; typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; public: - typedef Circular_arc_point_3 result_type; - typedef const result_type & qualified_result_type; + typedef const Circular_arc_point_3& result_type; - qualified_result_type operator() (const Line_arc_3 & a) const + result_type operator() (const Line_arc_3 & a) const { return (a.rep().lower_xyz_extremity()); } }; template - class Construct_circular_max_vertex_3 : Has_qrt + class Construct_circular_max_vertex_3 { typedef typename SK::Line_arc_3 Line_arc_3; typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; public: - typedef Circular_arc_point_3 result_type; - typedef const result_type & qualified_result_type; + typedef const Circular_arc_point_3& result_type; - qualified_result_type operator() (const Line_arc_3 & a) const + result_type operator() (const Line_arc_3 & a) const { return (a.rep().higher_xyz_extremity()); } }; template - class Construct_circular_source_vertex_3 : Has_qrt + class Construct_circular_source_vertex_3 { typedef typename SK::Line_arc_3 Line_arc_3; typedef typename SK::Circular_arc_3 Circular_arc_3; @@ -921,19 +954,18 @@ template < class SK > \ public: - typedef Circular_arc_point_3 result_type; - typedef const result_type & qualified_result_type; + typedef const Circular_arc_point_3& result_type; - qualified_result_type operator() (const Line_arc_3 & a) const + result_type operator() (const Line_arc_3 & a) const { return (a.rep().source()); } - qualified_result_type operator() (const Circular_arc_3 & a) const + result_type operator() (const Circular_arc_3 & a) const { return (a.rep().source()); } }; template - class Construct_circular_target_vertex_3 : Has_qrt + class Construct_circular_target_vertex_3 { typedef typename SK::Line_arc_3 Line_arc_3; typedef typename SK::Circular_arc_point_3 Circular_arc_point_3; @@ -941,13 +973,12 @@ template < class SK > \ public: - typedef Circular_arc_point_3 result_type; - typedef const result_type & qualified_result_type; + typedef const Circular_arc_point_3& result_type; - qualified_result_type operator() (const Line_arc_3 & a) const + result_type operator() (const Line_arc_3 & a) const { return (a.rep().target()); } - qualified_result_type operator() (const Circular_arc_3 & a) const + result_type operator() (const Circular_arc_3 & a) const { return (a.rep().target()); } }; @@ -1844,20 +1875,6 @@ template < class SK > \ } // namespace SphericalFunctors -template < typename K > -struct Qualified_result_of, - typename K::Line_arc_3> -{ - typedef typename K::Line_3 const & type; -}; - -template < typename K > -struct Qualified_result_of, - typename K::Circular_arc_3> -{ - typedef typename K::Circle_3 const & type; -}; - } // namespace CGAL #endif // CGAL_SPHERICAL_KERNEL_FUNCTION_OBJECTS_POLYNOMIAL_SPHERE_H diff --git a/Circular_kernel_3/include/CGAL/Line_arc_3.h b/Circular_kernel_3/include/CGAL/Line_arc_3.h index 9e2d47e70d0..97f6b506bbf 100644 --- a/Circular_kernel_3/include/CGAL/Line_arc_3.h +++ b/Circular_kernel_3/include/CGAL/Line_arc_3.h @@ -121,37 +121,32 @@ namespace CGAL { Line_arc_3(const RLine_arc_3 &a) : RLine_arc_3(a) {} - - typename Qualified_result_of - ::type + + typename boost::result_of::type source() const { return typename R::Construct_circular_source_vertex_3()(*this); } - typename Qualified_result_of - ::type + typename boost::result_of::type target() const { return typename R::Construct_circular_target_vertex_3()(*this); } - typename Qualified_result_of - ::type + typename boost::result_of::type lower_xyz_extremity() const { return typename R::Construct_circular_min_vertex_3()(*this); } - typename Qualified_result_of - ::type + typename boost::result_of::type higher_xyz_extremity() const { return typename R::Construct_circular_max_vertex_3()(*this); } - typename Qualified_result_of - ::type + typename boost::result_of::type supporting_line() const { return typename R::Construct_line_3()(*this); diff --git a/Filtered_kernel/include/CGAL/Lazy.h b/Filtered_kernel/include/CGAL/Lazy.h index 721fe1006f7..4cf82b14aee 100644 --- a/Filtered_kernel/include/CGAL/Lazy.h +++ b/Filtered_kernel/include/CGAL/Lazy.h @@ -38,6 +38,16 @@ # include #endif +#include + +#include +#include +#include +#include +#include +#include + + namespace CGAL { template class Lazy; @@ -208,10 +218,10 @@ public: mutable ET *et; Lazy_rep () - : at(), et(NULL) {} + : at(), et(NULL){} Lazy_rep (const AT& a) - : at(a), et(NULL) {} + : at(a), et(NULL){} Lazy_rep (const AT& a, const ET& e) : at(a), et(new ET(e)) {} @@ -270,7 +280,6 @@ public: //____________________________________________________________ // The rep for the leaf node -// FIXME TODO : Factorize all the Lazy_rep_[0-8] !!! template class Lazy_rep_0 : public Lazy_rep @@ -304,532 +313,45 @@ public: } }; +// Macro helpers to build the kernel objects +#define TYPEMAP_AC(z, n, t) typedef typename Type_mapper< t##n, LK, AK >::type A##n; +#define TYPEMAP_EC(z, n, t) typedef typename Type_mapper< t##n, LK, EK >::type E##n; +#define LEXACT(z,n,t) CGAL::exact( l##n ) +#define LARGS(z, n, t) L##n const& l##n -//____________________________________________________________ +#define TMAP(z, n, d) typename Type_mapper< L##n, d##K, LK >::type +#define PRUNE_TREE(z, n, d) l##n = L##n (); +#define LINIT(z, n, d) l##n(l##n) +#define LN(z, n, d) d(l##n) +#define MLIST(z, n, d) mutable L##n l##n; -template -class Lazy_rep_1 - : public Lazy_rep - , private EC -{ - typedef typename AC::result_type AT; - typedef typename EC::result_type ET; - 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 - void - print_dag(std::ostream& os, int level) const - { - this->print_at_et(os, level); - if(this->is_lazy()){ - CGAL::msg(os, level, "DAG with one child node:"); - CGAL::print_dag(l1_, os, level+1); - } - } -#endif +#define 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 \ +{ \ + BOOST_PP_REPEAT(n, MLIST, _) \ + const EC& ec() const { return *this; } \ +public: \ + void update_exact() const { \ + this->et = new ET(ec()( BOOST_PP_ENUM(n, LEXACT, _) ) ); \ + BOOST_PP_REPEAT(n, PRUNE_TREE, _) \ + } \ + Lazy_rep_##n(const AC& ac, const EC& ec, BOOST_PP_ENUM(n, LARGS, _)) \ + : Lazy_rep(ac( BOOST_PP_ENUM(n, LN, CGAL::approx) )), EC(ec), BOOST_PP_ENUM(n, LINIT, _) \ + { this->set_depth(max_n( BOOST_PP_ENUM(n, LN, CGAL::depth) ) + 1); } \ }; +BOOST_PP_REPEAT_FROM_TO(1, 9, LAZY_REP, _) - -//____________________________________________________________ - -template -class Lazy_rep_2 - : public Lazy_rep - , private EC -{ - typedef typename AC::result_type AT; - typedef typename EC::result_type ET; - typedef Lazy_rep Base; - - mutable L1 l1_; - mutable L2 l2_; - - const EC& ec() const { return *this; } - -public: - - void - update_exact() const - { - this->et = new ET(ec()(CGAL::exact(l1_), CGAL::exact(l2_))); - this->at = E2A()(*(this->et)); - // Prune lazy tree - l1_ = L1(); - l2_ = L2(); - } - - Lazy_rep_2(const AC& ac, const EC& /*ec*/, const L1& l1, const L2& l2) - : Lazy_rep(ac(CGAL::approx(l1), CGAL::approx(l2))), - l1_(l1), l2_(l2) - { - this->set_depth(max_n(CGAL::depth(l1_), CGAL::depth(l2_)) + 1); - } - -#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::msg(os, level, "DAG with two child nodes:"); - CGAL::print_dag(l1_, os, level+1); - CGAL::print_dag(l2_, os, level+1); - } - } -#endif -}; - - -//____________________________________________________________ - -template -class Lazy_rep_3 - : public Lazy_rep - , private EC -{ - typedef typename AC::result_type AT; - typedef typename EC::result_type ET; - typedef Lazy_rep Base; - - mutable L1 l1_; - mutable L2 l2_; - mutable L3 l3_; - - const EC& ec() const { return *this; } - -public: - - void - update_exact() const - { - this->et = new ET(ec()(CGAL::exact(l1_), CGAL::exact(l2_), - CGAL::exact(l3_))); - this->at = E2A()(*(this->et)); - // Prune lazy tree - l1_ = L1(); - l2_ = L2(); - l3_ = L3(); - } - - Lazy_rep_3(const AC& ac, const EC& /*ec*/, - const L1& l1, const L2& l2, const L3& l3) - : Lazy_rep(ac(CGAL::approx(l1), CGAL::approx(l2), - CGAL::approx(l3))), - l1_(l1), l2_(l2), l3_(l3) - { - this->set_depth(max_n(CGAL::depth(l1_), - CGAL::depth(l2_), - CGAL::depth(l3_)) + 1); - } - -#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::msg(os, level, "DAG with three child nodes:"); - CGAL::print_dag(l1_, os, level+1); - CGAL::print_dag(l2_, os, level+1); - CGAL::print_dag(l3_, os, level+1); - } - } -#endif -}; - - -//____________________________________________________________ - -template -class Lazy_rep_4 - : public Lazy_rep - , private EC -{ - typedef typename AC::result_type AT; - typedef typename EC::result_type ET; - typedef Lazy_rep Base; - - mutable L1 l1_; - mutable L2 l2_; - mutable L3 l3_; - mutable L4 l4_; - - const EC& ec() const { return *this; } - -public: - - void - update_exact() const - { - this->et = new ET(ec()(CGAL::exact(l1_), CGAL::exact(l2_), - CGAL::exact(l3_), CGAL::exact(l4_))); - this->at = E2A()(*(this->et)); - // Prune lazy tree - l1_ = L1(); - l2_ = L2(); - l3_ = L3(); - l4_ = L4(); - } - - Lazy_rep_4(const AC& ac, const EC& /*ec*/, - const L1& l1, const L2& l2, const L3& l3, const L4& l4) - : Lazy_rep(ac(CGAL::approx(l1), CGAL::approx(l2), - CGAL::approx(l3), CGAL::approx(l4))), - l1_(l1), l2_(l2), l3_(l3), l4_(l4) - { - this->set_depth(max_n(CGAL::depth(l1_), - CGAL::depth(l2_), - CGAL::depth(l3_), - CGAL::depth(l4_)) + 1); - } - -#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::msg(os, level, "DAG with four child nodes:"); - CGAL::print_dag(l1_, os, level+1); - CGAL::print_dag(l2_, os, level+1); - CGAL::print_dag(l3_, os, level+1); - CGAL::print_dag(l4_, os, level+1); - } - } -#endif -}; - -//____________________________________________________________ - - -template -class Lazy_rep_5 - : public Lazy_rep - , private EC -{ - typedef typename AC::result_type AT; - typedef typename EC::result_type ET; - typedef Lazy_rep Base; - - mutable L1 l1_; - mutable L2 l2_; - mutable L3 l3_; - mutable L4 l4_; - mutable L5 l5_; - - const EC& ec() const { return *this; } - -public: - - void - update_exact() const - { - this->et = new ET(ec()(CGAL::exact(l1_), CGAL::exact(l2_), - CGAL::exact(l3_), CGAL::exact(l4_), - CGAL::exact(l5_))); - this->at = E2A()(*(this->et)); - // Prune lazy tree - l1_ = L1(); - l2_ = L2(); - l3_ = L3(); - l4_ = L4(); - l5_ = L5(); - } - - Lazy_rep_5(const AC& ac, const EC& /*ec*/, - const L1& l1, const L2& l2, const L3& l3, const L4& l4, - const L5& l5) - : Lazy_rep(ac(CGAL::approx(l1), CGAL::approx(l2), - CGAL::approx(l3), CGAL::approx(l4), - CGAL::approx(l5))), - l1_(l1), l2_(l2), l3_(l3), l4_(l4), l5_(l5) - { - this->set_depth(max_n(CGAL::depth(l1_), - CGAL::depth(l2_), - CGAL::depth(l3_), - CGAL::depth(l4_), - CGAL::depth(l5_)) + 1); - } - -#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::msg(os, level, "DAG with five child nodes:"); - CGAL::print_dag(l1_, os, level+1); - CGAL::print_dag(l2_, os, level+1); - CGAL::print_dag(l3_, os, level+1); - CGAL::print_dag(l4_, os, level+1); - CGAL::print_dag(l5_, os, level+1); - } - } -#endif -}; - -template -class Lazy_rep_6 - : public Lazy_rep - , private EC -{ - typedef typename AC::result_type AT; - typedef typename EC::result_type ET; - typedef Lazy_rep Base; - - mutable L1 l1_; - mutable L2 l2_; - mutable L3 l3_; - mutable L4 l4_; - mutable L5 l5_; - mutable L6 l6_; - - const EC& ec() const { return *this; } - -public: - - void - update_exact() const - { - this->et = new ET(ec()(CGAL::exact(l1_), CGAL::exact(l2_), - CGAL::exact(l3_), CGAL::exact(l4_), - CGAL::exact(l5_), CGAL::exact(l6_))); - this->at = E2A()(*(this->et)); - // Prune lazy tree - l1_ = L1(); - l2_ = L2(); - l3_ = L3(); - l4_ = L4(); - l5_ = L5(); - l6_ = L6(); - } - - Lazy_rep_6(const AC& ac, const EC& /*ec*/, - const L1& l1, const L2& l2, const L3& l3, const L4& l4, - const L5& l5, const L6& l6) - : Lazy_rep(ac(CGAL::approx(l1), CGAL::approx(l2), - CGAL::approx(l3), CGAL::approx(l4), - CGAL::approx(l5), CGAL::approx(l6))), - l1_(l1), l2_(l2), l3_(l3), l4_(l4), l5_(l5), l6_(l6) - { - this->set_depth(max_n(CGAL::depth(l1_), - CGAL::depth(l2_), - CGAL::depth(l3_), - CGAL::depth(l4_), - CGAL::depth(l5_), - CGAL::depth(l6_)) + 1); - } - -#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::msg(os, level, "DAG with 6 child nodes:"); - CGAL::print_dag(l1_, os, level+1); - CGAL::print_dag(l2_, os, level+1); - CGAL::print_dag(l3_, os, level+1); - CGAL::print_dag(l4_, os, level+1); - CGAL::print_dag(l5_, os, level+1); - CGAL::print_dag(l6_, os, level+1); - } - } -#endif -}; - -template -class Lazy_rep_7 - : public Lazy_rep - , private EC -{ - typedef typename AC::result_type AT; - typedef typename EC::result_type ET; - typedef Lazy_rep Base; - - mutable L1 l1_; - mutable L2 l2_; - mutable L3 l3_; - mutable L4 l4_; - mutable L5 l5_; - mutable L6 l6_; - mutable L7 l7_; - - const EC& ec() const { return *this; } - -public: - - void - update_exact() const - { - this->et = new ET(ec()(CGAL::exact(l1_), CGAL::exact(l2_), - CGAL::exact(l3_), CGAL::exact(l4_), - CGAL::exact(l5_), CGAL::exact(l6_), - CGAL::exact(l7_))); - this->at = E2A()(*(this->et)); - // Prune lazy tree - l1_ = L1(); - l2_ = L2(); - l3_ = L3(); - l4_ = L4(); - l5_ = L5(); - l6_ = L6(); - l7_ = L7(); - } - - Lazy_rep_7(const AC& ac, const EC& /*ec*/, - const L1& l1, const L2& l2, const L3& l3, const L4& l4, - const L5& l5, const L6& l6, const L7& l7) - : Lazy_rep(ac(CGAL::approx(l1), CGAL::approx(l2), - CGAL::approx(l3), CGAL::approx(l4), - CGAL::approx(l5), CGAL::approx(l6), - CGAL::approx(l7))), - l1_(l1), l2_(l2), l3_(l3), l4_(l4), l5_(l5), l6_(l6), l7_(l7) - { - this->set_depth(max_n(CGAL::depth(l1_), - CGAL::depth(l2_), - CGAL::depth(l3_), - CGAL::depth(l4_), - CGAL::depth(l5_), - CGAL::depth(l6_), - CGAL::depth(l7_)) + 1); - } - -#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::msg(os, level, "DAG with 7 child nodes:"); - CGAL::print_dag(l1_, os, level+1); - CGAL::print_dag(l2_, os, level+1); - CGAL::print_dag(l3_, os, level+1); - CGAL::print_dag(l4_, os, level+1); - CGAL::print_dag(l5_, os, level+1); - CGAL::print_dag(l6_, os, level+1); - CGAL::print_dag(l7_, os, level+1); - } - } -#endif -}; - -template -class Lazy_rep_8 - : public Lazy_rep - , private EC -{ - typedef typename AC::result_type AT; - typedef typename EC::result_type ET; - typedef Lazy_rep Base; - - mutable L1 l1_; - mutable L2 l2_; - mutable L3 l3_; - mutable L4 l4_; - mutable L5 l5_; - mutable L6 l6_; - mutable L7 l7_; - mutable L8 l8_; - - const EC& ec() const { return *this; } - -public: - - void - update_exact() const - { - this->et = new ET(ec()(CGAL::exact(l1_), CGAL::exact(l2_), - CGAL::exact(l3_), CGAL::exact(l4_), - CGAL::exact(l5_), CGAL::exact(l6_), - CGAL::exact(l7_), CGAL::exact(l8_))); - this->at = E2A()(*(this->et)); - // Prune lazy tree - l1_ = L1(); - l2_ = L2(); - l3_ = L3(); - l4_ = L4(); - l5_ = L5(); - l6_ = L6(); - l7_ = L7(); - l8_ = L8(); - } - - Lazy_rep_8(const AC& ac, const EC& /*ec*/, - const L1& l1, const L2& l2, const L3& l3, const L4& l4, - const L5& l5, const L6& l6, const L7& l7, const L8& l8) - : Lazy_rep(ac(CGAL::approx(l1), CGAL::approx(l2), - CGAL::approx(l3), CGAL::approx(l4), - CGAL::approx(l5), CGAL::approx(l6), - CGAL::approx(l7), CGAL::approx(l8))), - l1_(l1), l2_(l2), l3_(l3), l4_(l4), l5_(l5), l6_(l6), l7_(l7), l8_(l8) - { - this->set_depth(max_n(CGAL::depth(l1_), - CGAL::depth(l2_), - CGAL::depth(l3_), - CGAL::depth(l4_), - CGAL::depth(l5_), - CGAL::depth(l6_), - CGAL::depth(l7_), - CGAL::depth(l8_)) + 1); - } - -#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::msg(os, level, "DAG with 8 child nodes:"); - CGAL::print_dag(l1_, os, level+1); - CGAL::print_dag(l2_, os, level+1); - CGAL::print_dag(l3_, os, level+1); - CGAL::print_dag(l4_, os, level+1); - CGAL::print_dag(l5_, os, level+1); - CGAL::print_dag(l6_, os, level+1); - CGAL::print_dag(l7_, os, level+1); - CGAL::print_dag(l8_, os, level+1); - } - } -#endif -}; - +#undef TMAP +#undef PRUNE_TREE +#undef LINIT +#undef LAZY_REP +#undef LN +#undef MLIST template < typename K1, typename K2 > struct Approx_converter @@ -1184,10 +706,6 @@ private: Self_rep * ptr() const { return (Self_rep*) PTR; } }; - - - - // The magic functor for Construct_bbox_[2,3], as there is no Lazy template @@ -1217,6 +735,7 @@ struct Lazy_construction_bbox } }; + template struct Lazy_construction_nt { @@ -1225,82 +744,49 @@ struct Lazy_construction_nt { typedef typename LK::Approximate_kernel AK; typedef typename LK::Exact_kernel EK; typedef typename LK::E2A E2A; - typedef typename AC::result_type AT; - typedef typename EC::result_type ET; - typedef Lazy_exact_nt result_type; AC ac; EC ec; - template - result_type operator()(const L1& l1) const - { - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - Protect_FPU_rounding P; - try { - return new Lazy_rep_1, L1>(ac, ec, l1); - } catch (Uncertain_conversion_exception) { - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding P2(CGAL_FE_TONEAREST); - return new Lazy_rep_0 >(ec(CGAL::exact(l1))); - } - } + template + struct result { }; - template - result_type operator()(const L1& l1, const L2& l2) const - { - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - Protect_FPU_rounding P; - try { - return new Lazy_rep_2, L1,L2>(ac, ec, l1,l2); - } catch (Uncertain_conversion_exception) { - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding P2(CGAL_FE_TONEAREST); - return new Lazy_rep_0 >(ec(CGAL::exact(l1), CGAL::exact(l2))); - } - } +#define RESULT_NT(z, n, d) \ + template< typename F, BOOST_PP_ENUM_PARAMS(n, class T) > \ + struct result { \ + BOOST_PP_REPEAT(n, TYPEMAP_EC, T) \ + typedef Lazy_exact_nt< \ + typename boost::remove_cv< typename boost::remove_reference < \ + typename boost::result_of::type >::type >::type > type; \ + }; - template - result_type operator()(const L1& l1, const L2& l2, const L3& l3) const - { - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - Protect_FPU_rounding P; - try { - return new Lazy_rep_3, L1,L2,L3>(ac, ec, l1,l2,l3); - } catch (Uncertain_conversion_exception) { - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding P2(CGAL_FE_TONEAREST); - return new Lazy_rep_0 >(ec(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3))); - } - } + BOOST_PP_REPEAT_FROM_TO(1, 9, RESULT_NT, _) - template - result_type operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4) const - { - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - Protect_FPU_rounding P; - try { - return new Lazy_rep_4, L1,L2,L3,L4>(ac, ec, l1,l2,l3,l4); - } catch (Uncertain_conversion_exception) { - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding P2(CGAL_FE_TONEAREST); - return new Lazy_rep_0 >(ec(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3), CGAL::exact(l4))); - } - } +#define NT_OPERATOR(z, n, d) \ + template \ + typename boost::result_of::type \ + operator()( BOOST_PP_ENUM(n, LARGS, _) ) { \ + BOOST_PP_REPEAT(n, TYPEMAP_EC, L) \ + BOOST_PP_REPEAT(n, TYPEMAP_AC, L) \ + typedef typename boost::remove_cv< typename boost::remove_reference < \ + typename boost::result_of< EC(BOOST_PP_ENUM_PARAMS(n, E)) >::type >::type >::type ET; \ + typedef typename boost::remove_cv< typename boost::remove_reference < \ + typename boost::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, LEXACT, _) )); \ + } \ + } \ - template - result_type operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4, const L5& l5) const - { - CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); - Protect_FPU_rounding P; - try { - return new Lazy_rep_5, L1,L2,L3,L4,L5>(ac, ec, l1,l2,l3,l4,l5); - } catch (Uncertain_conversion_exception) { - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding P2(CGAL_FE_TONEAREST); - return new Lazy_rep_0 >(ec(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3), CGAL::exact(l4), CGAL::exact(l5))); - } - } + BOOST_PP_REPEAT_FROM_TO(1, 6, NT_OPERATOR, _) + +#undef INTERVAL_OPERATOR +#undef RESULT_NT }; @@ -1558,8 +1044,8 @@ public: typedef Lazy, std::pair, EFT, 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_1 >, First >, E2A, Lazy_pair>(First >(), First >(), lv))); + r2 = R2(Handle_2(new Lazy_rep_1 >, Second >, E2A, Lazy_pair>(Second >(), Second >(), lv))); } catch (Uncertain_conversion_exception) { CGAL_BRANCH_PROFILER_BRANCH(tmp); Protect_FPU_rounding P2(CGAL_FE_TONEAREST); @@ -1606,7 +1092,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_1, \ Ith, E2A, Lazy_vector> \ (Ith(i), Ith(i), lv))); \ continue; \ @@ -1679,14 +1165,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_1(ac, ec, l1)); 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_1< 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)); \ } @@ -1712,14 +1198,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_2(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_1, Object_cast, E2A, Lazy_object> Lcr; \ Lcr * lcr = new Lcr(Object_cast(), Object_cast(), lo); \ return make_object(typename LK::X(lcr)); \ } @@ -1735,8 +1221,8 @@ 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, \ - Ith_for_intersection, E2A, Lazy_object> \ + V[i] = typename LK::X(new Lazy_rep_1, \ + Ith_for_intersection, E2A, Lazy_object> \ (Ith_for_intersection(i), Ith_for_intersection(i), lo)); \ } \ return make_object(V); \ @@ -1766,14 +1252,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_3(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_1, Object_cast, E2A, Lazy_object> Lcr; \ Lcr * lcr = new Lcr(Object_cast(), Object_cast(), lo); \ return make_object(typename LK::X(lcr)); \ } @@ -1808,144 +1294,71 @@ struct Lazy_construction typedef typename LK::Exact_kernel EK; typedef typename EK::FT EFT; typedef typename Default::Get::type E2A; - typedef typename AC::result_type AT; - typedef typename EC::result_type ET; - typedef Lazy Handle; - typedef typename Type_mapper::type result_type; + + template + struct result { + // this does not default, if you want to make a lazy lazy-kernel, + // you are on your own + }; AC ac; EC ec; -public: + // acquire the result_type of the approximate kernel, map it back to the lazy kernel object +#define RESULT(z, n, d) \ +template< typename F, BOOST_PP_ENUM_PARAMS(n, class T) > \ +struct result { \ + BOOST_PP_REPEAT(n, TYPEMAP_AC, T) \ + typedef typename Type_mapper< typename boost::result_of::type, AK, LK>::type type; \ +}; - result_type + BOOST_PP_REPEAT_FROM_TO(1, 9, RESULT, _) + +#define CONSTRUCTION_OPERATOR(z, n, d) \ + template \ + typename boost::result_of::type \ + operator()( BOOST_PP_ENUM(n, LARGS, _) ) { \ + BOOST_PP_REPEAT(n, TYPEMAP_EC, L) \ + BOOST_PP_REPEAT(n, TYPEMAP_AC, L) \ + typedef typename boost::remove_cv< typename boost::remove_reference < \ + typename boost::result_of< EC(BOOST_PP_ENUM_PARAMS(n, E)) >::type >::type >::type ET; \ + typedef typename boost::remove_cv< typename boost::remove_reference < \ + typename boost::result_of< AC(BOOST_PP_ENUM_PARAMS(n, A)) >::type >::type >::type AT; \ + typedef Lazy< AT, ET, EFT, E2A> Handle; \ + typedef typename boost::result_of::type result_type; \ + 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)))); \ + } catch (Uncertain_conversion_exception) { \ + CGAL_BRANCH_PROFILER_BRANCH(tmp); \ + Protect_FPU_rounding P2(CGAL_FE_TONEAREST); \ + return result_type( Handle(new Lazy_rep_0(ec( BOOST_PP_ENUM(n, LEXACT, _) ))) ); \ + } \ + } + + // arity 1-8 + BOOST_PP_REPEAT_FROM_TO(1, 9, CONSTRUCTION_OPERATOR, _) + + // nullary + typename Type_mapper< typename boost::result_of::type ,AK, LK>::type operator()() const { + typedef typename boost::result_of::type AT; + typedef typename boost::result_of::type ET; + typedef Lazy Handle; + typedef typename Type_mapper< typename boost::result_of::type ,AK, LK>::type result_type; + return result_type( Handle(new Lazy_rep_0()) ); } - - template - result_type - operator()(const L1& l1) const - { - 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_1(ac, ec, l1)) ); - } catch (Uncertain_conversion_exception) { - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding P2(CGAL_FE_TONEAREST); - return result_type( Handle(new Lazy_rep_0(ec(CGAL::exact(l1)))) ); - } - } - - template - result_type - operator()(const L1& l1, const L2& l2) const - { - 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_2(ac, ec, l1, l2)) ); - } catch (Uncertain_conversion_exception) { - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding P2(CGAL_FE_TONEAREST); - return result_type( Handle(new Lazy_rep_0(ec(CGAL::exact(l1), CGAL::exact(l2)))) ); - } - } - - template - result_type - operator()(const L1& l1, const L2& l2, const L3& l3) const - { - 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_3(ac, ec, l1, l2, l3)) ); - } catch (Uncertain_conversion_exception) { - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding P2(CGAL_FE_TONEAREST); - return result_type( Handle(new Lazy_rep_0(ec(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3)))) ); - } - } - - template - result_type - operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4) const - { - 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_4(ac, ec, l1, l2, l3, l4)) ); - } catch (Uncertain_conversion_exception) { - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding P2(CGAL_FE_TONEAREST); - return result_type( Handle(new Lazy_rep_0(ec(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3), CGAL::exact(l4)))) ); - } - } - - template - result_type - operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4, const L5& l5) const - { - 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_5(ac, ec, l1, l2, l3, l4, l5)) ); - } catch (Uncertain_conversion_exception) { - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding P2(CGAL_FE_TONEAREST); - return result_type( Handle(new Lazy_rep_0(ec(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3), CGAL::exact(l4), CGAL::exact(l5)))) ); - } - } - - template - result_type - operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4, const L5& l5, const L6& l6) const - { - 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_6(ac, ec, l1, l2, l3, l4, l5, l6)) ); - } catch (Uncertain_conversion_exception) { - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding P2(CGAL_FE_TONEAREST); - return result_type( Handle(new Lazy_rep_0(ec(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3), CGAL::exact(l4), CGAL::exact(l5), CGAL::exact(l6)))) ); - } - } - - template - result_type - operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4, const L5& l5, const L6& l6, const L7& l7) const - { - 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_7(ac, ec, l1, l2, l3, l4, l5, l6, l7)) ); - } catch (Uncertain_conversion_exception) { - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding P2(CGAL_FE_TONEAREST); - return result_type( Handle(new Lazy_rep_0(ec(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3), CGAL::exact(l4), CGAL::exact(l5), CGAL::exact(l6), CGAL::exact(l7)))) ); - } - } - - template - result_type - operator()(const L1& l1, const L2& l2, const L3& l3, const L4& l4, const L5& l5, const L6& l6, const L7& l7, const L8& l8) const - { - 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_8(ac, ec, l1, l2, l3, l4, l5, l6, l7, l8)) ); - } catch (Uncertain_conversion_exception) { - CGAL_BRANCH_PROFILER_BRANCH(tmp); - Protect_FPU_rounding P2(CGAL_FE_TONEAREST); - return result_type( Handle(new Lazy_rep_0(ec(CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3), CGAL::exact(l4), CGAL::exact(l5), CGAL::exact(l6), CGAL::exact(l7), CGAL::exact(l8)))) ); - } - } - }; } //namespace CGAL +#undef TYPEMAP_AC +#undef TYPEMAP_EC +#undef LEXACT +#undef LARGS + + #endif // CGAL_LAZY_H diff --git a/Filtered_kernel/include/CGAL/Lazy_kernel.h b/Filtered_kernel/include/CGAL/Lazy_kernel.h index 3a147a261a1..8bc423075ba 100644 --- a/Filtered_kernel/include/CGAL/Lazy_kernel.h +++ b/Filtered_kernel/include/CGAL/Lazy_kernel.h @@ -32,9 +32,39 @@ #include #include #include +#include +#include +#include +#include namespace CGAL { +namespace internal { + +template +// helper to make result access lazy +struct Delayed_void_result { + typedef typename T::template result::type type; +}; + +template +struct foobar; + +// goes through the standard process of selecting the right +// Lazy_something after the kind of the return type has been +// determined +template +struct Standard_pick { + typedef typename boost::remove_cv< typename boost::remove_reference< T >::type >::type T_; + typedef typename boost::mpl::if_< boost::is_same< T_, typename AK::FT >, + Lazy_construction_nt, + typename boost::mpl::if_< boost::is_same< T_, Object >, + Lazy_construction_object, + Lazy_construction >::type + >::type type; +}; +} // internal + // Exact_kernel = exact kernel that will be made lazy // Kernel = lazy kernel @@ -147,15 +177,21 @@ public: intersect_with_iterators_2_object) #else #define CGAL_Kernel_cons(C, Cf) \ - typedef typename boost::mpl::if_< boost::is_same,\ - Lazy_construction_nt,\ - typename boost::mpl::if_,\ - Lazy_construction_object,\ - Lazy_construction >::type >::type C; \ - C Cf() const { return C(); } + typedef typename boost::mpl::eval_if< boost::mpl::not_< boost::is_same< typename boost::result_of< typename Approximate_kernel::C () >::type, void > >, \ + internal::Standard_pick< typename boost::result_of::type, Approximate_kernel, Exact_kernel, Kernel, typename Approximate_kernel::C, typename Exact_kernel::C >, \ + internal::Standard_pick< typename boost::mpl::eval_if< boost::is_same< typename boost::result_of< typename Approximate_kernel::C () >::type, void >, \ + internal::Delayed_void_result< typename Approximate_kernel::C >, \ + boost::mpl::identity >::type, \ + Approximate_kernel, Exact_kernel, Kernel, typename Approximate_kernel::C, typename Exact_kernel::C > \ + >::type C; \ + C Cf() const { return C(); } #endif //CGAL_INTERSECT_WITH_ITERATORS_2 + + + + #include diff --git a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h index 0d0986f60ee..c2af8973a8e 100644 --- a/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h +++ b/Homogeneous_kernel/include/CGAL/Homogeneous/function_objects.h @@ -1560,15 +1560,15 @@ namespace HomogeneousKernelFunctors { }; template - class Compute_dx_2 : public Has_qrt + class Compute_dx_2 { typedef typename K::RT RT; typedef typename K::Direction_2 Direction_2; public: - typedef RT result_type; + typedef const RT& result_type; - const result_type & + result_type operator()(const Direction_2& d) const { return d.rep().dx(); @@ -1576,15 +1576,15 @@ namespace HomogeneousKernelFunctors { }; template - class Compute_dx_3 : public Has_qrt + class Compute_dx_3 { typedef typename K::RT RT; typedef typename K::Direction_3 Direction_3; public: - typedef RT result_type; + typedef const RT& result_type; - const result_type & + result_type operator()(const Direction_3& d) const { return d.rep().dx(); @@ -1592,15 +1592,15 @@ namespace HomogeneousKernelFunctors { }; template - class Compute_dy_2 : public Has_qrt + class Compute_dy_2 { typedef typename K::RT RT; typedef typename K::Direction_2 Direction_2; public: - typedef RT result_type; + typedef const RT& result_type; - const result_type & + result_type operator()(const Direction_2& d) const { return d.rep().dy(); @@ -1608,15 +1608,15 @@ namespace HomogeneousKernelFunctors { }; template - class Compute_dy_3 : public Has_qrt + class Compute_dy_3 { typedef typename K::RT RT; typedef typename K::Direction_3 Direction_3; public: - typedef RT result_type; + typedef const RT& result_type; - const result_type & + result_type operator()(const Direction_3& d) const { return d.rep().dy(); @@ -1624,15 +1624,15 @@ namespace HomogeneousKernelFunctors { }; template - class Compute_dz_3 : public Has_qrt + class Compute_dz_3 { typedef typename K::RT RT; typedef typename K::Direction_3 Direction_3; public: - typedef RT result_type; + typedef const RT& result_type; - const result_type & + result_type operator()(const Direction_3& d) const { return d.rep().dz(); @@ -1640,7 +1640,7 @@ namespace HomogeneousKernelFunctors { }; template - class Compute_hx_2 : public Has_qrt + class Compute_hx_2 { typedef typename K::FT FT; typedef typename K::RT RT; @@ -1648,15 +1648,15 @@ namespace HomogeneousKernelFunctors { typedef typename K::Vector_2 Vector_2; public: - typedef RT result_type; + typedef const RT& result_type; - const result_type & + result_type operator()(const Point_2& p) const { return p.rep().hx(); } - const result_type & + result_type operator()(const Vector_2& v) const { return v.rep().hx(); @@ -1664,7 +1664,7 @@ namespace HomogeneousKernelFunctors { }; template - class Compute_hx_3 : public Has_qrt + class Compute_hx_3 { typedef typename K::FT FT; typedef typename K::RT RT; @@ -1672,15 +1672,15 @@ namespace HomogeneousKernelFunctors { typedef typename K::Vector_3 Vector_3; public: - typedef RT result_type; + typedef const RT& result_type; - const result_type & + result_type operator()(const Point_3& p) const { return p.rep().hx(); } - const result_type & + result_type operator()(const Vector_3& v) const { return v.rep().hx(); @@ -1688,7 +1688,7 @@ namespace HomogeneousKernelFunctors { }; template - class Compute_hy_2 : public Has_qrt + class Compute_hy_2 { typedef typename K::FT FT; typedef typename K::RT RT; @@ -1696,15 +1696,15 @@ namespace HomogeneousKernelFunctors { typedef typename K::Vector_2 Vector_2; public: - typedef RT result_type; + typedef const RT& result_type; - const result_type & + result_type operator()(const Point_2& p) const { return p.rep().hy(); } - const result_type & + result_type operator()(const Vector_2& v) const { return v.rep().hy(); @@ -1712,7 +1712,7 @@ namespace HomogeneousKernelFunctors { }; template - class Compute_hy_3 : public Has_qrt + class Compute_hy_3 { typedef typename K::FT FT; typedef typename K::RT RT; @@ -1720,15 +1720,15 @@ namespace HomogeneousKernelFunctors { typedef typename K::Vector_3 Vector_3; public: - typedef RT result_type; + typedef const RT & result_type; - const result_type & + result_type operator()(const Point_3& p) const { return p.rep().hy(); } - const result_type & + result_type operator()(const Vector_3& v) const { return v.rep().hy(); @@ -1736,7 +1736,7 @@ namespace HomogeneousKernelFunctors { }; template - class Compute_hz_3 : public Has_qrt + class Compute_hz_3 { typedef typename K::FT FT; typedef typename K::RT RT; @@ -1744,15 +1744,15 @@ namespace HomogeneousKernelFunctors { typedef typename K::Vector_3 Vector_3; public: - typedef RT result_type; + typedef const RT& result_type; - const result_type & + result_type operator()(const Point_3& p) const { return p.rep().hz(); } - const result_type & + result_type operator()(const Vector_3& v) const { return v.rep().hz(); @@ -1760,7 +1760,7 @@ namespace HomogeneousKernelFunctors { }; template - class Compute_hw_2 : public Has_qrt + class Compute_hw_2 { typedef typename K::FT FT; typedef typename K::RT RT; @@ -1768,15 +1768,15 @@ namespace HomogeneousKernelFunctors { typedef typename K::Vector_2 Vector_2; public: - typedef RT result_type; + typedef const RT& result_type; - const result_type & + result_type operator()(const Point_2& p) const { return p.rep().hw(); } - const result_type & + result_type operator()(const Vector_2& v) const { return v.rep().hw(); @@ -1784,7 +1784,7 @@ namespace HomogeneousKernelFunctors { }; template - class Compute_hw_3 : public Has_qrt + class Compute_hw_3 { typedef typename K::FT FT; typedef typename K::RT RT; @@ -1792,15 +1792,15 @@ namespace HomogeneousKernelFunctors { typedef typename K::Vector_3 Vector_3; public: - typedef RT result_type; + typedef const RT& result_type; - const result_type & + result_type operator()(const Point_3& p) const { return p.rep().hw(); } - const result_type & + result_type operator()(const Vector_3& v) const { return v.rep().hw(); @@ -3517,7 +3517,15 @@ namespace HomogeneousKernelFunctors { typedef typename K::Iso_rectangle_2 Iso_rectangle_2; typedef typename K::Triangle_2 Triangle_2; public: - typedef Point_2 result_type; + template + struct result { + typedef const Point_2& type; + }; + + template + struct result { + typedef Point_2 type; + }; const Point_2 & operator()( const Segment_2& s, int i) const @@ -3527,7 +3535,7 @@ namespace HomogeneousKernelFunctors { operator()( const Triangle_2& t, int i) const { return t.rep().vertex(i); } - const Point_2 + Point_2 operator()( const Iso_rectangle_2& r, int i) const { switch (i%4) { @@ -3547,22 +3555,6 @@ namespace HomogeneousKernelFunctors { } //namespace HomogeneousKernelFunctors -#ifndef CGAL_CFG_DONT_OVERLOAD_TOO_MUCH -template < typename K> -struct Qualified_result_of, typename K::Segment_2, int > -{ - typedef typename K::Point_2 const & type; -}; - -template < typename K> -struct Qualified_result_of, typename K::Triangle_2, int > -{ - typedef typename K::Point_2 const & type; -}; -#endif - -// For Iso_rectangle the non specialized template will do the right thing, namely return a copy of a point - namespace HomogeneousKernelFunctors { template diff --git a/Kernel_23/include/CGAL/Circle_2.h b/Kernel_23/include/CGAL/Circle_2.h index 472ed55bd3b..60f3da4e6bb 100644 --- a/Kernel_23/include/CGAL/Circle_2.h +++ b/Kernel_23/include/CGAL/Circle_2.h @@ -95,13 +95,13 @@ public: Circle_2(const Point_2 & center) : RCircle_2(typename R::Construct_circle_2()(Return_base_tag(), center, FT(0), COUNTERCLOCKWISE)) {} - typename Qualified_result_of::type + typename boost::result_of::type center() const { return R().construct_center_2_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type squared_radius() const { return R().compute_squared_radius_2_object()(*this); diff --git a/Kernel_23/include/CGAL/Circle_3.h b/Kernel_23/include/CGAL/Circle_3.h index 82a7c7ff0f5..9ad08384916 100644 --- a/Kernel_23/include/CGAL/Circle_3.h +++ b/Kernel_23/include/CGAL/Circle_3.h @@ -101,8 +101,8 @@ public: Circle_3(const Rep& r) : Rep(r) {} - typename Qualified_result_of - ::type + typename boost::result_of + ::type diametral_sphere() const { return typename R::Construct_sphere_3()(*this); @@ -118,8 +118,8 @@ public: return typename R::Construct_sphere_3()(*this).squared_radius(); } - typename Qualified_result_of - ::type + typename boost::result_of + ::type supporting_plane() const { return typename R::Construct_plane_3()(*this); diff --git a/Kernel_23/include/CGAL/Direction_2.h b/Kernel_23/include/CGAL/Direction_2.h index 9b0ce7d5ebc..e0b73981a26 100644 --- a/Kernel_23/include/CGAL/Direction_2.h +++ b/Kernel_23/include/CGAL/Direction_2.h @@ -98,19 +98,19 @@ public: return R().construct_perpendicular_direction_2_object()(*this,o); } - typename Qualified_result_of::type + typename boost::result_of::type dx() const { return R().compute_dx_2_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type dy() const { return R().compute_dy_2_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type delta(int i) const { CGAL_kernel_precondition( ( i == 0 ) || ( i == 1 ) ); diff --git a/Kernel_23/include/CGAL/Direction_3.h b/Kernel_23/include/CGAL/Direction_3.h index 5ad46664a35..0997cac8626 100644 --- a/Kernel_23/include/CGAL/Direction_3.h +++ b/Kernel_23/include/CGAL/Direction_3.h @@ -104,25 +104,25 @@ public: Vector_3 vector() const { return to_vector(); } - typename Qualified_result_of::type + typename boost::result_of::type dx() const { return R().compute_dx_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type dy() const { return R().compute_dy_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type dz() const { return R().compute_dz_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type delta(int i) const { CGAL_kernel_precondition( i >= 0 && i <= 2 ); diff --git a/Kernel_23/include/CGAL/Iso_cuboid_3.h b/Kernel_23/include/CGAL/Iso_cuboid_3.h index de7b8fd290d..5b5c2f74385 100644 --- a/Kernel_23/include/CGAL/Iso_cuboid_3.h +++ b/Kernel_23/include/CGAL/Iso_cuboid_3.h @@ -90,75 +90,67 @@ public: : Rep(typename R::Construct_iso_cuboid_3()(Return_base_tag(), min_hx, min_hy, min_hz, max_hx, max_hy, max_hz)) {} -// TODO FIXME : why is Qrt not working here ? -// TODO : the Cartesian and Homogeneous functors should be split here -// given that the Qrt differs. -// (or is the Homogeneous optimization simply not worth it ?) - //typename Qualified_result_of::type - Point_3 + typename boost::result_of::type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return R().construct_min_vertex_3_object()(*this); } - //typename Qualified_result_of::type - Point_3 + typename boost::result_of::type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return R().construct_max_vertex_3_object()(*this); } - //typename Qualified_result_of::type - Point_3 + typename boost::result_of::type vertex(int i) const { return R().construct_vertex_3_object()(*this,i); } - //typename Qualified_result_of::type - Point_3 + typename boost::result_of::type operator[](int i) const { return R().construct_vertex_3_object()(*this,i); } - typename Qualified_result_of::type + typename boost::result_of::type xmin() const { return R().compute_xmin_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type xmax() const { return R().compute_xmax_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type ymin() const { return R().compute_ymin_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type ymax() const { return R().compute_ymax_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type zmin() const { return R().compute_zmin_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type zmax() const { return R().compute_zmax_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type min_coord(int i) const { CGAL_kernel_precondition( i == 0 || i == 1 || i == 2 ); @@ -170,7 +162,7 @@ public: return zmin(); } - typename Qualified_result_of::type + typename boost::result_of::type max_coord(int i) const { CGAL_kernel_precondition( i == 0 || i == 1 || i == 2 ); @@ -218,7 +210,7 @@ public: return R().is_degenerate_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type volume() const { return R().compute_volume_3_object()(*this); diff --git a/Kernel_23/include/CGAL/Iso_rectangle_2.h b/Kernel_23/include/CGAL/Iso_rectangle_2.h index 6b22ad404b2..9b80b1ebd5d 100644 --- a/Kernel_23/include/CGAL/Iso_rectangle_2.h +++ b/Kernel_23/include/CGAL/Iso_rectangle_2.h @@ -87,13 +87,13 @@ public: : Rep(typename R::Construct_iso_rectangle_2()(Return_base_tag(), min_hx, min_hy, max_hx, max_hy, hw)) {} - typename Qualified_result_of::type + typename boost::result_of::type min BOOST_PREVENT_MACRO_SUBSTITUTION () const { return R().construct_min_vertex_2_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type max BOOST_PREVENT_MACRO_SUBSTITUTION () const { return R().construct_max_vertex_2_object()(*this); @@ -112,43 +112,45 @@ public: } - typename Qualified_result_of::type + // typename boost::result_of::type + Point_2 vertex(int i) const { return R().construct_vertex_2_object()(*this,i); } - typename Qualified_result_of::type + // typename boost::result_of::type + Point_2 operator[](int i) const { return R().construct_vertex_2_object()(*this,i); } - typename Qualified_result_of::type + typename boost::result_of::type xmin() const { return R().compute_xmin_2_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type xmax() const { return R().compute_xmax_2_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type ymin() const { return R().compute_ymin_2_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type ymax() const { return R().compute_ymax_2_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type min_coord(int i) const { CGAL_kernel_precondition( i == 0 || i == 1 ); @@ -158,7 +160,7 @@ public: return ymin(); } - typename Qualified_result_of::type + typename boost::result_of::type max_coord(int i) const { CGAL_kernel_precondition( i == 0 || i == 1 ); diff --git a/Kernel_23/include/CGAL/Kernel/Type_mapper.h b/Kernel_23/include/CGAL/Kernel/Type_mapper.h index be3bc8847fe..52df14a5717 100644 --- a/Kernel_23/include/CGAL/Kernel/Type_mapper.h +++ b/Kernel_23/include/CGAL/Kernel/Type_mapper.h @@ -26,28 +26,38 @@ #define CGAL_KERNEL_TYPE_MAPPER_H #include +#include +#include namespace CGAL { +namespace internal { + template + struct Type_mapper_impl { + typedef T type; + }; + +// Then we specialize for all kernel objects. +#define CGAL_Kernel_obj(X) \ + template < typename K1, typename K2 > \ + struct Type_mapper_impl < typename K1::X, K1, K2 > \ + { typedef typename K2::X type; }; + +#include + +} // internal + // This is a tool to obtain the K2::Point_2 from K1 and K1::Point_2. // Similarly for other kernel types. // TODO : add more specializations ? Use a different mechanism ? template < typename T, typename K1, typename K2 > -struct Type_mapper -{ - typedef T type; // By default, assume same type (e.g. Object). -}; - -// Then we specialize for all kernel objects. - -#define CGAL_Kernel_obj(X) \ - template < typename K1, typename K2 > \ - struct Type_mapper < typename K1::X, K1, K2 > \ - { typedef typename K2::X type; }; - -#include +struct Type_mapper : + internal::Type_mapper_impl< typename boost::remove_cv< + typename boost::remove_reference < T >::type + >::type, K1, K2 > +{ }; } //namespace CGAL diff --git a/Kernel_23/include/CGAL/Kernel/function_objects.h b/Kernel_23/include/CGAL/Kernel/function_objects.h index b258f009298..51e0040a4aa 100644 --- a/Kernel_23/include/CGAL/Kernel/function_objects.h +++ b/Kernel_23/include/CGAL/Kernel/function_objects.h @@ -766,32 +766,32 @@ namespace CommonKernelFunctors { }; template - class Construct_center_2 : Has_qrt + class Construct_center_2 { typedef typename K::Point_2 Point_2; typedef typename K::Circle_2 Circle_2; public: - typedef Point_2 result_type; + typedef const Point_2& result_type; - const Point_2 & + result_type operator()(const Circle_2& c) const { return c.rep().center(); } }; template - class Construct_center_3 : Has_qrt + class Construct_center_3 { typedef typename K::Point_3 Point_3; typedef typename K::Sphere_3 Sphere_3; typedef typename K::Circle_3 Circle_3; public: - typedef Point_3 result_type; + typedef const Point_3& result_type; - const Point_3 & + result_type operator()(const Sphere_3& s) const { return s.rep().center(); } - const Point_3 & + result_type operator()(const Circle_3& c) const { return c.rep().center(); } @@ -1064,38 +1064,38 @@ namespace CommonKernelFunctors { }; template - class Construct_max_vertex_2 : Has_qrt + class Construct_max_vertex_2 { typedef typename K::Point_2 Point_2; typedef typename K::Segment_2 Segment_2; typedef typename K::Iso_rectangle_2 Iso_rectangle_2; public: - typedef Point_2 result_type; + typedef const Point_2& result_type; - const Point_2& + result_type operator()(const Iso_rectangle_2& r) const { return (r.rep().max)(); } - const Point_2& + result_type operator()(const Segment_2& s) const { return (s.max)(); } }; template - class Construct_min_vertex_2 : Has_qrt + class Construct_min_vertex_2 { typedef typename K::Point_2 Point_2; typedef typename K::Segment_2 Segment_2; typedef typename K::Iso_rectangle_2 Iso_rectangle_2; public: - typedef Point_2 result_type; + typedef const Point_2& result_type; - const Point_2& + result_type operator()(const Iso_rectangle_2& r) const { return (r.rep().min)(); } - const Point_2& + result_type operator()(const Segment_2& s) const { return (s.min)(); } }; @@ -1633,83 +1633,83 @@ namespace CommonKernelFunctors { template - class Construct_source_2 : Has_qrt + class Construct_source_2 { typedef typename K::Segment_2 Segment_2; typedef typename K::Ray_2 Ray_2; typedef typename K::Point_2 Point_2; public: - typedef Point_2 result_type; + typedef const Point_2& result_type; - const result_type& + result_type operator()(const Segment_2& s) const { return s.rep().source(); } - const result_type& + result_type operator()(const Ray_2& r) const { return r.rep().source(); } }; template - class Construct_source_3 : Has_qrt + class Construct_source_3 { typedef typename K::Segment_3 Segment_3; typedef typename K::Ray_3 Ray_3; typedef typename K::Point_3 Point_3; public: - typedef Point_3 result_type; + typedef const Point_3& result_type; - const result_type& + result_type operator()(const Segment_3& s) const { return s.rep().source(); } - const result_type& + result_type operator()(const Ray_3& r) const { return r.rep().source(); } }; template - class Construct_target_2 : Has_qrt + class Construct_target_2 { typedef typename K::Segment_2 Segment_2; typedef typename K::Point_2 Point_2; public: - typedef Point_2 result_type; + typedef const Point_2& result_type; - const result_type& + result_type operator()(const Segment_2& s) const { return s.rep().target(); } }; template - class Construct_target_3 : Has_qrt + class Construct_target_3 { typedef typename K::Segment_3 Segment_3; typedef typename K::Point_3 Point_3; public: - typedef Point_3 result_type; + typedef const Point_3& result_type; - const result_type& + result_type operator()(const Segment_3& s) const { return s.rep().target(); } }; template - class Construct_second_point_2 : Has_qrt + class Construct_second_point_2 { typedef typename K::Ray_2 Ray_2; typedef typename K::Point_2 Point_2; public: - typedef Point_2 result_type; + typedef const Point_2& result_type; - const result_type& + result_type operator()(const Ray_2& r) const { return r.rep().second_point(); } }; template - class Construct_second_point_3 // : Has_qrt + class Construct_second_point_3 { typedef typename K::Ray_3 Ray_3; typedef typename K::Point_3 Point_3; @@ -1881,7 +1881,7 @@ namespace CommonKernelFunctors { }; template - class Construct_vertex_3 : Has_qrt + class Construct_vertex_3 { typedef typename K::Point_3 Point_3; typedef typename K::Segment_3 Segment_3; @@ -1889,21 +1889,29 @@ namespace CommonKernelFunctors { typedef typename K::Triangle_3 Triangle_3; typedef typename K::Tetrahedron_3 Tetrahedron_3; public: - typedef Point_3 result_type; + template + struct result { + typedef const Point_3& type; + }; - const Point_3 & + template + struct result { + typedef Point_3 type; + }; + + typename result< Construct_vertex_3(Segment_3) >::type operator()( const Segment_3& s, int i) const { return s.rep().vertex(i); } - const Point_3 & + typename result< Construct_vertex_3(Triangle_3) >::type operator()( const Triangle_3& t, int i) const { return t.rep().vertex(i); } - Point_3 + typename result< Construct_vertex_3(Iso_cuboid_3) >::type operator()( const Iso_cuboid_3& r, int i) const - { return r.rep().vertex(i); } + { typename result< Construct_vertex_3(Iso_cuboid_3) >::type asdf; return r.rep().vertex(i); } - const Point_3 & + typename result< Construct_vertex_3(Tetrahedron_3) >::type operator()( const Tetrahedron_3& t, int i) const { return t.rep().vertex(i); } }; @@ -2755,12 +2763,6 @@ namespace CommonKernelFunctors { }; } // namespace CommonKernelFunctors - - template - struct Qualified_result_of,Iso_cuboid_3 > : - qrt_or_not,false> - {}; - } //namespace CGAL #endif // CGAL_KERNEL_FUNCTION_OBJECTS_H diff --git a/Kernel_23/include/CGAL/Plane_3.h b/Kernel_23/include/CGAL/Plane_3.h index 50cd880667d..6e40e2a9672 100644 --- a/Kernel_23/include/CGAL/Plane_3.h +++ b/Kernel_23/include/CGAL/Plane_3.h @@ -113,25 +113,25 @@ public: return Direction_3(a(), b(), c()); } - typename Qualified_result_of::type + typename boost::result_of::type a() const { return R().compute_a_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type b() const { return R().compute_b_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type c() const { return R().compute_c_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type d() const { return R().compute_d_3_object()(*this); diff --git a/Kernel_23/include/CGAL/Point_2.h b/Kernel_23/include/CGAL/Point_2.h index e01e4a682b6..45f1cb0d897 100644 --- a/Kernel_23/include/CGAL/Point_2.h +++ b/Kernel_23/include/CGAL/Point_2.h @@ -85,26 +85,26 @@ public: : RPoint_2(typename R::Construct_point_2()(Return_base_tag(), hx, hy, hw)) {} - typename Qualified_result_of::type + typename boost::result_of::type x() const { return typename R::Compute_x_2()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type y() const { return typename R::Compute_y_2()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type cartesian(int i) const { CGAL_kernel_precondition( (i == 0) || (i == 1) ); return (i==0) ? x() : y(); } - typename Qualified_result_of::type + typename boost::result_of::type operator[](int i) const { return cartesian(i); @@ -122,19 +122,19 @@ public: - typename Qualified_result_of::type + typename boost::result_of::type hx() const { return typename R::Compute_hx_2()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type hy() const { return typename R::Compute_hy_2()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type hw() const { return typename R::Compute_hw_2()(*this); @@ -145,7 +145,7 @@ public: return 2; } - typename Qualified_result_of::type + typename boost::result_of::type homogeneous(int i) const { CGAL_kernel_precondition( (i >= 0) || (i <= 2) ); diff --git a/Kernel_23/include/CGAL/Point_3.h b/Kernel_23/include/CGAL/Point_3.h index 90b74eef8de..8f838f4c95a 100644 --- a/Kernel_23/include/CGAL/Point_3.h +++ b/Kernel_23/include/CGAL/Point_3.h @@ -85,49 +85,49 @@ public: : Rep(typename R::Construct_point_3()(Return_base_tag(), hx, hy, hz, hw)) {} - typename Qualified_result_of::type + typename boost::result_of::type x() const { return typename R::Compute_x_3()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type y() const { return typename R::Compute_y_3()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type z() const { return typename R::Compute_z_3()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type hx() const { return R().compute_hx_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type hy() const { return R().compute_hy_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type hz() const { return R().compute_hz_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type hw() const { return R().compute_hw_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type cartesian(int i) const { CGAL_kernel_precondition( (i == 0) || (i == 1) || (i == 2) ); @@ -146,7 +146,7 @@ public: return hw(); } - typename Qualified_result_of::type + typename boost::result_of::type operator[](int i) const { return cartesian(i); diff --git a/Kernel_23/include/CGAL/Ray_2.h b/Kernel_23/include/CGAL/Ray_2.h index 399456e222f..b5d434b38f0 100644 --- a/Kernel_23/include/CGAL/Ray_2.h +++ b/Kernel_23/include/CGAL/Ray_2.h @@ -86,13 +86,13 @@ public: : RRay_2(typename R::Construct_ray_2()(Return_base_tag(), sp, l)) {} - typename Qualified_result_of::type + typename boost::result_of::type source() const { return R().construct_source_2_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type second_point() const { return R().construct_second_point_2_object()(*this); @@ -116,7 +116,7 @@ public: } - typename Qualified_result_of::type + typename boost::result_of::type start() const { return source(); diff --git a/Kernel_23/include/CGAL/Ray_3.h b/Kernel_23/include/CGAL/Ray_3.h index 490024d7f29..e2d14dbe7fb 100644 --- a/Kernel_23/include/CGAL/Ray_3.h +++ b/Kernel_23/include/CGAL/Ray_3.h @@ -105,25 +105,25 @@ public: bool collinear_has_on(const Point_3 &p) const; */ - Point_3 point(int i) const // TODO : use Qrt + typename boost::result_of::type + point(int i) const // TODO : use Qrt { return R().construct_point_on_3_object()(*this, i); } - // FIXME : Use Qrt - //typename Qualified_result_of::type - Point_3 + typename boost::result_of::type source() const { return R().construct_source_3_object()(*this); } - Point_3 second_point() const // TODO : use Qrt + typename boost::result_of::type + second_point() const { return R().construct_second_point_3_object()(*this); } - Point_3 // FIXME : Use Qrt + typename boost::result_of::type start() const { return source(); diff --git a/Kernel_23/include/CGAL/Segment_2.h b/Kernel_23/include/CGAL/Segment_2.h index 20981a1b590..ee67cd0eae9 100644 --- a/Kernel_23/include/CGAL/Segment_2.h +++ b/Kernel_23/include/CGAL/Segment_2.h @@ -76,44 +76,44 @@ public: Segment_2(const Point_2 &sp, const Point_2 &ep) : RSegment_2(typename R::Construct_segment_2()(Return_base_tag(), sp,ep)) {} - typename Qualified_result_of::type + typename boost::result_of::type source() const { return R_().construct_source_2_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type target() const { return R_().construct_target_2_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type start() const { return source(); } - typename Qualified_result_of::type + typename boost::result_of::type end() const { return target(); } - typename Qualified_result_of::type + typename boost::result_of::type min BOOST_PREVENT_MACRO_SUBSTITUTION () const; - typename Qualified_result_of::type + typename boost::result_of::type max BOOST_PREVENT_MACRO_SUBSTITUTION () const; - typename Qualified_result_of::type + typename boost::result_of::type vertex(int i) const; - typename Qualified_result_of::type + typename boost::result_of::type point(int i) const; - typename Qualified_result_of::type + typename boost::result_of::type operator[](int i) const; bool is_horizontal() const; @@ -178,7 +178,7 @@ public: template < class R_ > CGAL_KERNEL_INLINE -typename Qualified_result_of >::type +typename boost::result_of )>::type Segment_2::min BOOST_PREVENT_MACRO_SUBSTITUTION () const { typename R_::Less_xy_2 less_xy; @@ -187,7 +187,7 @@ Segment_2::min BOOST_PREVENT_MACRO_SUBSTITUTION () const template < class R_ > CGAL_KERNEL_INLINE -typename Qualified_result_of >::type +typename boost::result_of )>::type Segment_2::max BOOST_PREVENT_MACRO_SUBSTITUTION () const { typename R_::Less_xy_2 less_xy; @@ -196,7 +196,7 @@ Segment_2::max BOOST_PREVENT_MACRO_SUBSTITUTION () const template < class R_ > CGAL_KERNEL_INLINE -typename Qualified_result_of, int >::type +typename boost::result_of, int )>::type Segment_2::vertex(int i) const { return (i%2 == 0) ? source() : target(); @@ -204,7 +204,7 @@ Segment_2::vertex(int i) const template < class R_ > inline -typename Qualified_result_of, int >::type +typename boost::result_of, int )>::type Segment_2::point(int i) const { return vertex(i); @@ -212,7 +212,7 @@ Segment_2::point(int i) const template < class R_ > inline -typename Qualified_result_of, int >::type +typename boost::result_of, int )>::type Segment_2::operator[](int i) const { return vertex(i); diff --git a/Kernel_23/include/CGAL/Segment_3.h b/Kernel_23/include/CGAL/Segment_3.h index ee43db5cca1..7c1c8c376b1 100644 --- a/Kernel_23/include/CGAL/Segment_3.h +++ b/Kernel_23/include/CGAL/Segment_3.h @@ -74,54 +74,44 @@ public: Segment_3(const Point_3& sp, const Point_3& ep) : Rep(typename R::Construct_segment_3()(Return_base_tag(), sp, ep)) {} -// FIXME TODO : Use Qrt here ! - //typename Qualified_result_of::type - Point_3 + typename boost::result_of::type source() const { return R_().construct_source_3_object()(*this); } - //typename Qualified_result_of::type - Point_3 + typename boost::result_of::type target() const { return R_().construct_target_3_object()(*this); } - //typename Qualified_result_of::type - Point_3 + typename boost::result_of::type start() const { return source(); } - //typename Qualified_result_of::type - Point_3 + typename boost::result_of::type end() const { return target(); } - //typename Qualified_result_of::type - Point_3 + typename boost::result_of::type min BOOST_PREVENT_MACRO_SUBSTITUTION () const; - //typename Qualified_result_of::type - Point_3 + typename boost::result_of::type max BOOST_PREVENT_MACRO_SUBSTITUTION () const; - //typename Qualified_result_of::type - Point_3 + typename boost::result_of::type vertex(int i) const; - //typename Qualified_result_of::type - Point_3 + typename boost::result_of::type point(int i) const { return vertex(i); } - //typename Qualified_result_of::type - Point_3 + typename boost::result_of::type operator[](int i) const { return vertex(i); } @@ -179,8 +169,7 @@ public: template < class R_ > CGAL_KERNEL_INLINE -//typename Qualified_result_of >::type -typename R_::Point_3 +typename boost::result_of ) >::type Segment_3::min BOOST_PREVENT_MACRO_SUBSTITUTION () const { typename R_::Less_xyz_3 less_xyz; @@ -189,8 +178,7 @@ Segment_3::min BOOST_PREVENT_MACRO_SUBSTITUTION () const template < class R_ > CGAL_KERNEL_INLINE -//typename Qualified_result_of >::type -typename R_::Point_3 +typename boost::result_of ) >::type Segment_3::max BOOST_PREVENT_MACRO_SUBSTITUTION () const { typename R_::Less_xyz_3 less_xyz; @@ -199,8 +187,7 @@ Segment_3::max BOOST_PREVENT_MACRO_SUBSTITUTION () const template < class R_ > CGAL_KERNEL_INLINE -//typename Qualified_result_of, int >::type -typename R_::Point_3 +typename boost::result_of, int ) >::type Segment_3::vertex(int i) const { return (i%2 == 0) ? source() : target(); diff --git a/Kernel_23/include/CGAL/Sphere_3.h b/Kernel_23/include/CGAL/Sphere_3.h index 926efe13c8c..e574bdce23c 100644 --- a/Kernel_23/include/CGAL/Sphere_3.h +++ b/Kernel_23/include/CGAL/Sphere_3.h @@ -94,9 +94,7 @@ public: Sphere_3 orthogonal_transform(const Aff_transformation_3 &t) const; - // FIXME : why doesn't Qrt work here ? We loose optimization ! - //typename Qualified_result_of::type - Point_3_ + typename boost::result_of::type center() const { return R().construct_center_3_object()(*this); diff --git a/Kernel_23/include/CGAL/Tetrahedron_3.h b/Kernel_23/include/CGAL/Tetrahedron_3.h index 1d3f710bd34..de9acd1a70b 100644 --- a/Kernel_23/include/CGAL/Tetrahedron_3.h +++ b/Kernel_23/include/CGAL/Tetrahedron_3.h @@ -78,16 +78,13 @@ public: t.transform(this->vertex(3))); } - // FIXME TODO : Why doesn't Qrt work here ??? - //typename Qualified_result_of::type - Point_3 + typename boost::result_of::type vertex(int i) const { return R().construct_vertex_3_object()(*this,i); } - //typename Qualified_result_of::type - Point_3 + typename boost::result_of::type operator[](int i) const { return vertex(i); @@ -139,7 +136,7 @@ public: return R().has_on_unbounded_side_3_object()(*this, p); } - typename Qualified_result_of::type + typename boost::result_of::type volume() const { return R().compute_volume_3_object()(*this); diff --git a/Kernel_23/include/CGAL/Triangle_2.h b/Kernel_23/include/CGAL/Triangle_2.h index 0f29cb14f03..a63682bb760 100644 --- a/Kernel_23/include/CGAL/Triangle_2.h +++ b/Kernel_23/include/CGAL/Triangle_2.h @@ -107,13 +107,13 @@ public: return !(*this == t); } - typename Qualified_result_of::type + typename boost::result_of::type vertex(int i) const { return R().construct_vertex_2_object()(*this,i); } - typename Qualified_result_of::type + typename boost::result_of::type operator[](int i) const { return vertex(i); diff --git a/Kernel_23/include/CGAL/Triangle_3.h b/Kernel_23/include/CGAL/Triangle_3.h index eb19c066366..d507dbfe46b 100644 --- a/Kernel_23/include/CGAL/Triangle_3.h +++ b/Kernel_23/include/CGAL/Triangle_3.h @@ -90,13 +90,13 @@ public: } - typename Qualified_result_of::type + typename boost::result_of::type vertex(int i) const { return R().construct_vertex_3_object()(*this, i); } - typename Qualified_result_of::type + typename boost::result_of::type operator[](int i) const { return vertex(i); diff --git a/Kernel_23/include/CGAL/Vector_2.h b/Kernel_23/include/CGAL/Vector_2.h index da673057cd2..9cffc951587 100644 --- a/Kernel_23/include/CGAL/Vector_2.h +++ b/Kernel_23/include/CGAL/Vector_2.h @@ -99,26 +99,26 @@ public: : RVector_2(typename R::Construct_vector_2()(Return_base_tag(), x,y,w)) {} - typename Qualified_result_of::type + typename boost::result_of::type x() const { return R().compute_x_2_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type y() const { return R().compute_y_2_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type cartesian(int i) const { CGAL_kernel_precondition( (i == 0) || (i == 1) ); return (i==0) ? x() : y(); } - typename Qualified_result_of::type + typename boost::result_of::type operator[](int i) const { return cartesian(i); @@ -134,26 +134,26 @@ public: return typename R::Construct_cartesian_const_iterator_2()(*this,2); } - typename Qualified_result_of::type + typename boost::result_of::type hx() const { return R().compute_hx_2_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type hy() const { return R().compute_hy_2_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type hw() const { return R().compute_hw_2_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type homogeneous(int i) const { CGAL_kernel_precondition( (i >= 0) || (i <= 2) ); diff --git a/Kernel_23/include/CGAL/Vector_3.h b/Kernel_23/include/CGAL/Vector_3.h index 539209144ac..0017a37bd57 100644 --- a/Kernel_23/include/CGAL/Vector_3.h +++ b/Kernel_23/include/CGAL/Vector_3.h @@ -133,49 +133,49 @@ public: return R().construct_divided_vector_3_object()(*this,c); } - typename Qualified_result_of::type + typename boost::result_of::type x() const { return R().compute_x_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type y() const { return R().compute_y_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type z() const { return R().compute_z_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type hx() const { return R().compute_hx_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type hy() const { return R().compute_hy_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type hz() const { return R().compute_hz_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type hw() const { return R().compute_hw_3_object()(*this); } - typename Qualified_result_of::type + typename boost::result_of::type cartesian(int i) const { CGAL_kernel_precondition( (i == 0) || (i == 1) || (i == 2) ); @@ -184,7 +184,7 @@ public: return z(); } - typename Qualified_result_of::type + typename boost::result_of::type homogeneous(int i) const { CGAL_kernel_precondition( (i >= 0) || (i <= 3) ); @@ -199,7 +199,7 @@ public: return 3; } - typename Qualified_result_of::type + typename boost::result_of::type operator[](int i) const { return cartesian(i); @@ -215,7 +215,7 @@ public: return typename R::Construct_cartesian_const_iterator_3()(*this,3); } - typename Qualified_result_of::type + typename boost::result_of::type squared_length() const { return R().compute_squared_length_3_object()(*this); diff --git a/Kernel_23/include/CGAL/kernel_basic.h b/Kernel_23/include/CGAL/kernel_basic.h index 4abf52d553d..222811091a9 100644 --- a/Kernel_23/include/CGAL/kernel_basic.h +++ b/Kernel_23/include/CGAL/kernel_basic.h @@ -41,7 +41,6 @@ #include #include #include -#include #include #endif // CGAL_KERNEL_BASIC_H diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_circle_2.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_circle_2.h index b1db389a83d..5edc0313a15 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_circle_2.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_circle_2.h @@ -37,10 +37,10 @@ void _test_construct_radical_line(const K &k) { typedef typename K::Construct_circle_2 Construct_circle_2; typedef typename K::Construct_radical_line_2 Construct_radical_line_2; - Intersect_2 theIntersect_2 = k.intersect_2_object(); + // Intersect_2 theIntersect_2 = k.intersect_2_object(); Construct_circle_2 theConstruct_circle_2 = k.construct_circle_2_object(); Construct_radical_line_2 theConstruct_radical_line_2 = k.construct_radical_line_2_object(); - Has_on_2 theHas_on_2 = k.has_on_2_object(); + // Has_on_2 theHas_on_2 = k.has_on_2_object(); std::cout << "Testing radical_line(Circle,Circle)..." << std::endl; Circle_2 s = theConstruct_circle_2(Point_2(0,0),1); diff --git a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_iso_cuboid_3.h b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_iso_cuboid_3.h index 16bd0ab7e83..ceed783612d 100644 --- a/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_iso_cuboid_3.h +++ b/Kernel_23/test/Kernel_23/include/CGAL/_test_cls_iso_cuboid_3.h @@ -100,6 +100,7 @@ _test_cls_iso_cuboid_3(const R& ) assert( (r2.max)() == p3 ); assert( r1.vertex(0) == p1 ); + assert( r1[0] == p1 ); assert( r1.vertex(1) == p5 ); assert( r1.vertex(2) == p10); assert( r1.vertex(3) == p11); diff --git a/STL_Extension/include/CGAL/min_max_n.h b/STL_Extension/include/CGAL/min_max_n.h index 0820b2e14f4..75bb104bfcc 100644 --- a/STL_Extension/include/CGAL/min_max_n.h +++ b/STL_Extension/include/CGAL/min_max_n.h @@ -71,6 +71,10 @@ min_n(const T& t0, const T& t1, const T& t2, const T& t3, const T& t4, { return (std::min)(t0, min_n(t1, t2, t3, t4, t5, t6, t7)); } +template inline +const T& +max_n(const T& t) { return t; } + template < typename T > inline const T& max_n(const T& t0, const T& t1)