Merge pull request #4878 from danston/Kernels-decltypes-danston

Improve decltype/result_of/invoke_result
This commit is contained in:
Laurent Rineau 2021-04-06 15:13:21 +02:00
commit 1b54449dc5
89 changed files with 501 additions and 800 deletions

View File

@ -45,11 +45,9 @@ typedef unspecified_type Do_intersect_3;
/*!
A functor object to construct the intersection between two geometric objects.
This functor must support the result_of protocol, that is the return
type of the `operator()(A, B)` is `CGAL::cpp11::result<Intersect_3(A,B)>`.
Provides the operators:
`CGAL::cpp11::result<Intersect_3(A,B)> operator()(const A& a, const B& b);`
`decltype(auto) operator()(const A& a, const B& b);`
where `A` and `B` are any relevant types among `Ray_3`, `Segment_3`, `Line_3`,
`Triangle_3`, `Plane_3` and `Bbox_3`.
Relevant herein means that a line primitive (ray, segment, line) is tested

View File

@ -20,7 +20,6 @@
#include <CGAL/disable_warnings.h>
#include <CGAL/AABB_primitive.h>
#include <CGAL/result_of.h>
#include <iterator>
namespace CGAL {
@ -31,14 +30,17 @@ namespace internal {
//classical typedefs
typedef Iterator key_type;
typedef typename GeomTraits::Point_3 value_type;
typedef typename cpp11::result_of<
typename GeomTraits::Construct_source_3(typename GeomTraits::Segment_3)
>::type reference;
// typedef decltype(
// std::declval<typename GeomTraits::Construct_source_3>()(
// std::declval<typename GeomTraits::Segment_3>())) reference;
typedef decltype(
typename GeomTraits::Construct_source_3()(
*std::declval<key_type&>())) reference;
typedef boost::readable_property_map_tag category;
typedef Source_of_segment_3_iterator_property_map<GeomTraits, Iterator> Self;
inline friend
typename Source_of_segment_3_iterator_property_map<GeomTraits,Iterator>::reference
get(Source_of_segment_3_iterator_property_map<GeomTraits,Iterator>, Iterator it)
inline friend reference
get(Self, key_type it)
{
return typename GeomTraits::Construct_source_3()( *it );
}
@ -57,7 +59,6 @@ namespace internal {
* \tparam GeomTraits is a traits class providing the nested type `Point_3` and `Segment_3`.
* It also provides the functor `Construct_source_3` that has an operator taking a `Segment_3`
* and returning its source as a type convertible to `Point_3`.
* In addition `Construct_source_3` must support the result_of protocol.
* \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Segment_3`
* \tparam CacheDatum is either `CGAL::Tag_true` or `CGAL::Tag_false`. In the former case,
* the datum is stored in the primitive, while in the latter it is

View File

@ -192,14 +192,14 @@ public:
typedef typename std::pair<typename GeomTraits::Point_3, typename Primitive::Id> Point_and_primitive_id;
/// `Intersection_and_primitive_id<Query>::%Type::first_type` is found according to
/// the result type of `GeomTraits::Intersect_3::operator()`,
/// (that is cpp11::result_of<GeomTraits::Intersect_3(Query, Primitive::Datum)>::type). If it is
/// the result type of `GeomTraits::Intersect_3::operator()`. If it is
/// `boost::optional<T>` then it is `T`, and the result type otherwise.
template<typename Query>
struct Intersection_and_primitive_id {
typedef typename cpp11::result_of<
typename GeomTraits::Intersect_3(Query, typename Primitive::Datum)
>::type Intersection_type;
typedef decltype(
std::declval<typename GeomTraits::Intersect_3>()(
std::declval<Query>(),
std::declval<typename Primitive::Datum>())) Intersection_type;
typedef std::pair<
typename internal::AABB_tree::Remove_optional<Intersection_type>::type,
@ -366,8 +366,7 @@ public:
template<typename Query>
boost::optional< typename Intersection_and_primitive_id<Query>::Type >
operator()(const Query& query, const typename AT::Primitive& primitive) const {
typename cpp11::result_of<typename GeomTraits::Intersect_3(Query, typename Primitive::Datum) >::type
inter_res = GeomTraits().intersect_3_object()(internal::Primitive_helper<AT>::get_datum(primitive,m_traits),query);
auto inter_res = GeomTraits().intersect_3_object()(internal::Primitive_helper<AT>::get_datum(primitive,m_traits),query);
if (!inter_res)
return boost::none;
return boost::make_optional( std::make_pair(*inter_res, primitive.id()) );

View File

@ -20,7 +20,6 @@
#include <CGAL/disable_warnings.h>
#include <CGAL/AABB_primitive.h>
#include <CGAL/result_of.h>
#include <iterator>
namespace CGAL {
@ -31,14 +30,18 @@ namespace internal {
//classical typedefs
typedef Iterator key_type;
typedef typename GeomTraits::Point_3 value_type;
typedef typename cpp11::result_of<
typename GeomTraits::Construct_vertex_3(typename GeomTraits::Triangle_3,int)
>::type reference;
// typedef decltype(
// std::declval<typename GeomTraits::Construct_vertex_3>()(
// std::declval<typename GeomTraits::Triangle_3>(),
// std::declval<int>())) reference;
typedef decltype(
typename GeomTraits::Construct_vertex_3()(
*std::declval<key_type&>(), 0)) reference;
typedef boost::readable_property_map_tag category;
typedef Point_from_triangle_3_iterator_property_map<GeomTraits, Iterator> Self;
inline friend
typename Point_from_triangle_3_iterator_property_map<GeomTraits,Iterator>::reference
get(Point_from_triangle_3_iterator_property_map<GeomTraits,Iterator>, Iterator it)
inline friend reference
get(Self, key_type it)
{
return typename GeomTraits::Construct_vertex_3()( *it, 0 );
}
@ -57,7 +60,6 @@ namespace internal {
* \tparam GeomTraits is a traits class providing the nested type `Point_3` and `Triangle_3`.
* It also provides the functor `Construct_vertex_3` that has an operator taking a `Triangle_3`
* and an integer as parameters and returning a triangle point as a type convertible to `Point_3`.
* In addition `Construct_vertex_3` must support the result_of protocol.
* \tparam Iterator is a model of `ForwardIterator` with its value type convertible to `GeomTraits::Triangle_3`
* \tparam CacheDatum is either `CGAL::Tag_true` or `CGAL::Tag_false`. In the former case,
* the datum is stored in the primitive, while in the latter it is

View File

@ -18,7 +18,6 @@
#include <CGAL/AABB_primitive.h>
#include <CGAL/result_of.h>
#include <iterator>
namespace CGAL
@ -31,14 +30,18 @@ namespace CGAL
//classical typedefs
typedef Iterator key_type;
typedef typename GeomTraits::Point_3 value_type;
typedef typename cpp11::result_of<
typename GeomTraits::Construct_vertex_3(typename GeomTraits::Tetrahedron_3, int)
>::type reference;
typedef decltype(
std::declval<typename GeomTraits::Construct_vertex_3>()(
std::declval<typename GeomTraits::Tetrahedron_3>(),
std::declval<int>())) reference;
// typedef decltype(
// typename GeomTraits::Construct_vertex_3()(
// *std::declval<key_type&>(), 0)) reference; // fails polyhedron demo!
typedef boost::readable_property_map_tag category;
typedef Point_from_cell_iterator_proprety_map<GeomTraits, Iterator> Self;
inline friend
typename Point_from_cell_iterator_proprety_map<GeomTraits, Iterator>::reference
get(Point_from_cell_iterator_proprety_map<GeomTraits, Iterator>, Iterator it)
inline friend reference
get(Self, key_type it)
{
typename GeomTraits::Construct_point_3 point;
return point(it->vertex(1)->point());

View File

@ -22,7 +22,6 @@
#include <CGAL/config.h>
#include <CGAL/result_of.h>
#include <CGAL/Bbox_2.h>
#include <CGAL/enum.h>
namespace CGAL {
@ -107,25 +106,25 @@ public:
{}
typename cpp11::result_of<typename R::Construct_circular_source_vertex_2(Circular_arc_2)>::type
decltype(auto)
source() const
{
return typename R::Construct_circular_source_vertex_2()(*this);
}
typename cpp11::result_of<typename R::Construct_circular_target_vertex_2(Circular_arc_2)>::type
decltype(auto)
target() const
{
return typename R::Construct_circular_target_vertex_2()(*this);
}
typename cpp11::result_of<typename R::Construct_circular_min_vertex_2(Circular_arc_2)>::type
decltype(auto)
left() const
{
return typename R::Construct_circular_min_vertex_2()(*this);
}
typename cpp11::result_of<typename R::Construct_circular_max_vertex_2(Circular_arc_2)>::type
decltype(auto)
right() const
{
return typename R::Construct_circular_max_vertex_2()(*this);
@ -141,19 +140,19 @@ public:
return typename R::Is_y_monotone_2()(*this);
}
typename cpp11::result_of<typename R::Construct_circle_2(Circular_arc_2)>::type
decltype(auto)
supporting_circle() const
{
return typename R::Construct_circle_2()(*this);
}
typename cpp11::result_of<typename R::Construct_center_2(Circular_arc_2)>::type
decltype(auto)
center() const
{
return typename R::Construct_center_2()(*this);
}
typename cpp11::result_of<typename R::Compute_squared_radius_2( Circular_arc_2)>::type
decltype(auto)
squared_radius() const
{
return typename R::Compute_squared_radius_2()(*this);

View File

@ -21,7 +21,6 @@
#include <CGAL/license/Circular_kernel_2.h>
#include <CGAL/result_of.h>
#include <CGAL/Bbox_2.h>
#include <CGAL/enum.h>
@ -72,15 +71,13 @@ public:
: RCircular_arc_point_2(typename R::Construct_circular_arc_point_2()(p))
{}
typename
cpp11::result_of<typename R::Compute_circular_x_2(Circular_arc_point_2)>::type
decltype(auto)
x() const
{
return typename R::Compute_circular_x_2()(*this);
}
typename
cpp11::result_of<typename R::Compute_circular_y_2(Circular_arc_point_2)>::type
decltype(auto)
y() const
{
return typename R::Compute_circular_y_2()(*this);

View File

@ -639,13 +639,13 @@ public:
return _support;
}
typename cpp11::result_of<typename CK::Construct_center_2(Circle_2)>::type
decltype(auto)
center() const
{
return supporting_circle().center();
}
typename cpp11::result_of<typename CK::Compute_squared_radius_2(Circle_2)>::type
decltype(auto)
squared_radius() const
{
return supporting_circle().squared_radius();

View File

@ -357,22 +357,8 @@ namespace CircularFunctors {
//using CK::Linear_kernel::Intersect_2::operator();
template<typename>
struct result;
template<typename F, typename A, typename B>
struct result<F(A,B)> {
typedef typename Intersection_traits<CK, A, B>::result_type type;
};
//need a specialization for the case of 3 object in CK
template<typename F, typename A, typename B, typename OutputIterator>
struct result<F(A,B,OutputIterator)> {
typedef OutputIterator type;
};
template<class A, class B>
typename Intersection_traits<CK, A, B>::result_type
decltype(auto)
operator()(const A& a, const B& b) const{
return typename CK::Linear_kernel::Intersect_2()(a,b);
}
@ -482,21 +468,6 @@ namespace CircularFunctors {
{
public:
template<typename>
struct result;
template<typename F>
struct result<F(typename CK::Line_2)>
{
typedef typename CK::Polynomial_1_2 type;
};
template<typename F>
struct result<F(typename CK::Circle_2)>
{
typedef typename CK::Polynomial_for_circles_2_2 type;
};
typename CK::Polynomial_1_2
operator() ( const typename CK::Line_2 & l )
{
@ -1014,22 +985,8 @@ namespace CircularFunctors {
typedef typename CK::Point_2 Point_2;
typedef typename CK::Circle_2 Circle_2;
public:
template<typename>
struct result{
typedef FT type;
};
template<typename F>
struct result<F(Circular_arc_2)> {
typedef typename cpp11::result_of<LK_Compute_squared_radius_2(Circle_2)>::type type;
};
template<typename F>
struct result<F(Circle_2)> {
typedef typename cpp11::result_of<LK_Compute_squared_radius_2(Circle_2)>::type type;
};
typename cpp11::result_of<LK_Compute_squared_radius_2(Circle_2)>::type
decltype(auto)
operator()( const Circle_2& c) const
{ return LK_Compute_squared_radius_2()(c); }
@ -1042,7 +999,7 @@ namespace CircularFunctors {
FT operator()( const Point_2& p, const Point_2& q, const Point_2& r) const
{ return LK_Compute_squared_radius_2()(p, q, r); }
typename cpp11::result_of<LK_Compute_squared_radius_2(Circle_2)>::type
decltype(auto)
operator()(const Circular_arc_2& c) const
{ return c.rep().squared_radius(); }

View File

@ -21,7 +21,6 @@
#include <CGAL/license/Circular_kernel_2.h>
#include <CGAL/result_of.h>
#include <CGAL/Bbox_2.h>
namespace CGAL {
@ -91,25 +90,25 @@ public:
: RLine_arc_2(a)
{}
typename cpp11::result_of< typename R::Construct_circular_source_vertex_2(Line_arc_2)>::type
decltype(auto)
source() const
{
return typename R::Construct_circular_source_vertex_2()(*this);
}
typename cpp11::result_of< typename R::Construct_circular_target_vertex_2(Line_arc_2)>::type
decltype(auto)
target() const
{
return typename R::Construct_circular_target_vertex_2()(*this);
}
typename cpp11::result_of< typename R::Construct_circular_min_vertex_2(Line_arc_2)>::type
decltype(auto)
left() const
{
return typename R::Construct_circular_min_vertex_2()(*this);
}
typename cpp11::result_of< typename R::Construct_circular_max_vertex_2(Line_arc_2)>::type
decltype(auto)
right() const
{
return typename R::Construct_circular_max_vertex_2()(*this);

View File

@ -20,7 +20,6 @@
#include <CGAL/license/Circular_kernel_3.h>
#include <CGAL/result_of.h>
#include <CGAL/Bbox_3.h>
namespace CGAL {
@ -117,19 +116,19 @@ namespace CGAL {
: RCircular_arc_3(a)
{}
typename cpp11::result_of<typename R::Construct_circular_source_vertex_3(Circular_arc_3)>::type
decltype(auto)
source() const
{
return typename R::Construct_circular_source_vertex_3()(*this);
}
typename cpp11::result_of<typename R::Construct_circular_target_vertex_3(Circular_arc_3)>::type
decltype(auto)
target() const
{
return typename R::Construct_circular_target_vertex_3()(*this);
}
typename cpp11::result_of<typename R::Construct_circle_3(Circular_arc_3)>::type
decltype(auto)
supporting_circle() const
{
return typename R::Construct_circle_3()(*this);

View File

@ -20,7 +20,6 @@
#include <CGAL/license/Circular_kernel_3.h>
#include <CGAL/result_of.h>
#include <CGAL/Bbox_3.h>
#include <iostream>
@ -196,15 +195,15 @@ public:
typename cpp11::result_of<typename R::Compute_circular_x_3(Circular_arc_point_3)>::type
decltype(auto)
x() const
{ return typename R::Compute_circular_x_3()(*this);}
typename cpp11::result_of<typename R::Compute_circular_y_3(Circular_arc_point_3)>::type
decltype(auto)
y() const
{ return typename R::Compute_circular_y_3()(*this);}
typename cpp11::result_of<typename R::Compute_circular_z_3(Circular_arc_point_3)>::type
decltype(auto)
z() const
{ return typename R::Compute_circular_z_3()(*this);}

View File

@ -567,15 +567,6 @@ template < class SK > \
typedef typename SK::Kernel_base::Circle_3 RCircle_3;
typedef typename Circle_3::Rep Rep;
public:
template<typename>
struct result {
typedef forwarded_result_type type;
};
template<typename F>
struct result<F(Circular_arc_3)> {
typedef const forwarded_result_type& type;
};
forwarded_result_type
operator()(const Point_3& p, const FT& sr,
@ -1019,44 +1010,17 @@ template < class SK > \
public:
template <typename>
struct result;
// the binary overload always goes to Linear::Intersect_3
template <typename F, typename A, typename B>
struct result<F(A, B)>
{ typedef typename Intersection_traits<SK, A, B>::result_type type; };
// This one is only for the spherical kernel, O is an output iterator
template <typename F, typename A, typename B, typename OutputIterator>
struct result<F(A, B, OutputIterator)>
{ typedef OutputIterator type;};
// there is no quaternary form in the linear Kernel
template <typename F, typename A, typename B, typename C, typename OutputIterator>
struct result<F(A, B, C, OutputIterator)>
{ typedef OutputIterator type; };
//only ternary from the linear kernel
template<typename F>
struct result<F(Plane_3, Plane_3, Plane_3)> {
typedef boost::optional<
boost::variant< Point_3,
Line_3,
Plane_3 > > type;
};
//using SK::Linear_kernel::Intersect_3::operator();
typedef typename SK::Linear_kernel::Intersect_3 Intersect_linear_3;
template<class A, class B>
typename Intersection_traits<SK, A, B>::result_type
decltype(auto)
operator()(const A& a, const B& b) const{
return Intersect_linear_3()(a,b);
}
typename result<Intersect_linear_3(Plane_3, Plane_3, Plane_3)>::type
decltype(auto)
operator()(const Plane_3& p, const Plane_3& q, const Plane_3& r) const
{
return Intersect_linear_3()(p, q, r);

View File

@ -41,33 +41,6 @@ namespace CGAL {
typedef typename SK::Polynomials_for_circle_3 result_type_for_circle;
//using LinearFunctors::Get_equation<SK>::operator();
template <typename>
struct result;
template <typename F>
struct result<F(typename SK::Sphere_3)>
{
typedef result_type_for_sphere type;
};
template <typename F>
struct result<F(typename SK::Plane_3)>
{
typedef result_type_for_plane type;
};
template <typename F>
struct result<F(typename SK::Line_3)>
{
typedef result_type_for_line type;
};
template <typename F>
struct result<F(typename SK::Circle_3)>
{
typedef result_type_for_circle type;
};
result_type_for_sphere
operator() ( const typename SK::Sphere_3 & s )
{

View File

@ -20,7 +20,6 @@
#include <CGAL/license/Circular_kernel_3.h>
#include <CGAL/result_of.h>
#include <CGAL/Bbox_3.h>
@ -122,31 +121,31 @@ namespace CGAL {
: RLine_arc_3(a)
{}
typename cpp11::result_of<typename R::Construct_circular_source_vertex_3(Line_arc_3)>::type
decltype(auto)
source() const
{
return typename R::Construct_circular_source_vertex_3()(*this);
}
typename cpp11::result_of<typename R::Construct_circular_target_vertex_3(Line_arc_3)>::type
decltype(auto)
target() const
{
return typename R::Construct_circular_target_vertex_3()(*this);
}
typename cpp11::result_of<typename R::Construct_circular_min_vertex_3(Line_arc_3)>::type
decltype(auto)
lower_xyz_extremity() const
{
return typename R::Construct_circular_min_vertex_3()(*this);
}
typename cpp11::result_of<typename R::Construct_circular_max_vertex_3(Line_arc_3)>::type
decltype(auto)
higher_xyz_extremity() const
{
return typename R::Construct_circular_max_vertex_3()(*this);
}
typename cpp11::result_of<typename R::Construct_line_3(Line_arc_3)>::type
decltype(auto)
supporting_line() const
{
return typename R::Construct_line_3()(*this);

View File

@ -22,7 +22,6 @@
#include <CGAL/Kernel_traits.h>
#include <CGAL/convex_hull_3.h>
#include <CGAL/result_of.h>
namespace CGAL {
namespace Convex_hull_3 {
@ -37,14 +36,14 @@ struct Forward_functor
Forward_functor(const PointPropertyMap& vpm, const F& f) : F(f), vpm_(vpm) {}
template <class Vertex>
typename cpp11::result_of<F(const Vertex&, const Vertex&)>::type
decltype(auto)
operator()(const Vertex& p, const Vertex& q) const
{
return static_cast<const F*>(this)->operator()(get(vpm_, p), get(vpm_, q));
}
template <class Vertex>
typename cpp11::result_of<F(const Vertex&, const Vertex&, const Vertex&)>::type
decltype(auto)
operator()(const Vertex& p, const Vertex& q, const Vertex& r) const
{
return static_cast<const F*>(this)->operator()(get(vpm_, p),
@ -53,7 +52,7 @@ struct Forward_functor
}
template <class Vertex>
typename cpp11::result_of<F(const Vertex&, const Vertex&, const Vertex&, const Vertex&)>::type
decltype(auto)
operator()(const Vertex& p, const Vertex& q, const Vertex& r, const Vertex& s) const
{
return static_cast<const F*>(this)->operator()(get(vpm_, p),

View File

@ -470,6 +470,7 @@ public:
};
// Macro helpers to build the kernel objects
#define CGAL_PARAM(z, n, t) std::declval<t##n>()
#define CGAL_TYPEMAP_AC(z, n, t) typedef typename Type_mapper< t##n, LK, AK >::type A##n;
#define CGAL_TYPEMAP_EC(z, n, t) typedef typename Type_mapper< t##n, LK, EK >::type E##n;
#define CGAL_LEXACT(z,n,t) CGAL::exact( l##n )
@ -857,7 +858,8 @@ struct Lazy_construction_bbox
CGAL_NO_UNIQUE_ADDRESS EC ec;
template <typename L1>
result_type operator()(const L1& l1) const
decltype(auto)
operator()(const L1& l1) const
{
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
// Protection is outside the try block as VC8 has the CGAL_CFG_FPU_ROUNDING_MODE_UNWINDING_VC_BUG
@ -977,20 +979,6 @@ struct Lazy_construction_nt {
CGAL_NO_UNIQUE_ADDRESS AC ac;
CGAL_NO_UNIQUE_ADDRESS EC ec;
template<typename>
struct result { };
#define CGAL_RESULT_NT(z, n, d) \
template< typename F, BOOST_PP_ENUM_PARAMS(n, class T) > \
struct result<F( BOOST_PP_ENUM_PARAMS(n, T) )> { \
BOOST_PP_REPEAT(n, CGAL_TYPEMAP_EC, T) \
typedef Lazy_exact_nt< \
typename boost::remove_cv< typename boost::remove_reference < \
typename cpp11::result_of<EC( BOOST_PP_ENUM_PARAMS(n, E) )>::type >::type >::type > type; \
};
BOOST_PP_REPEAT_FROM_TO(1, 6, CGAL_RESULT_NT, _)
template<class...L>
auto operator()(L const&...l) const ->
Lazy_exact_nt<std::remove_cv_t<std::remove_reference_t<decltype(ec(CGAL::exact(l)...))>>>
@ -1007,8 +995,6 @@ struct Lazy_construction_nt {
return new Lazy_rep_0<AT,ET,To_interval<ET> >(ec( CGAL::exact(l)... ));
}
}
#undef CGAL_RESULT_NT
};
@ -1404,7 +1390,7 @@ struct Lazy_construction_object
public:
template <typename L1>
result_type
decltype(auto)
operator()(const L1& l1) const
{
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
@ -1437,7 +1423,7 @@ public:
}
template <typename L1, typename L2>
result_type
decltype(auto)
operator()(const L1& l1, const L2& l2) const
{
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
@ -1491,7 +1477,7 @@ CGAL_Kernel_obj(Point_3)
}
template <typename L1, typename L2, typename L3>
result_type
decltype(auto)
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);
@ -1530,7 +1516,7 @@ CGAL_Kernel_obj(Point_3)
//____________________________________________________________
// The magic functor that has Lazy<Something> as result type.
// Two versions are distinguished: one that needs to fiddle
// with result_of and another that can forward the result types.
// with decltype and another that can forward the result types.
namespace internal {
BOOST_MPL_HAS_XXX_TRAIT_DEF(result_type)
@ -1652,20 +1638,23 @@ struct Lazy_construction_variant {
struct result<F( BOOST_PP_ENUM_PARAMS(n, T) )> { \
BOOST_PP_REPEAT(n, CGAL_TYPEMAP_AC, T) \
typedef typename Type_mapper< \
typename cpp11::result_of<AC( BOOST_PP_ENUM_PARAMS(n, A) )>::type, AK, LK>::type type; \
decltype(std::declval<AC>()(BOOST_PP_ENUM(n, CGAL_PARAM, A))), AK, LK>::type type; \
};
BOOST_PP_REPEAT_FROM_TO(1, 9, CGAL_RESULT, _)
template <typename L1, typename L2>
typename result<Lazy_construction_variant(L1, L2)>::type
decltype(auto)
operator()(const L1& l1, const L2& l2) const {
typedef typename cpp11::result_of<Lazy_construction_variant(L1, L2)>::type result_type;
typedef typename result<Lazy_construction_variant(L1, L2)>::type result_type;
typedef typename cpp11::result_of<AC(typename Type_mapper<L1, LK, AK>::type,
typename Type_mapper<L2, LK, AK>::type)>::type AT;
typedef typename cpp11::result_of<EC(typename Type_mapper<L1, LK, EK>::type,
typename Type_mapper<L2, LK, EK>::type)>::type ET;
// typedef decltype(std::declval<AC>()(std::declval<typename Type_mapper<L1, LK, AK>::type>(),
// std::declval<typename Type_mapper<L2, LK, AK>::type>())) AT;
// typedef decltype(std::declval<EC>()(std::declval<typename Type_mapper<L1, LK, EK>::type>(),
// std::declval<typename Type_mapper<L2, LK, EK>::type>())) ET;
typedef decltype(std::declval<AC const&>()(CGAL::approx(l1), CGAL::approx(l2))) AT;
typedef decltype(std::declval<EC const&>()( CGAL::exact(l1), CGAL::exact(l2))) ET;
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
Protect_FPU_rounding<Protection> P;
@ -1706,19 +1695,23 @@ struct Lazy_construction_variant {
}
template <typename L1, typename L2, typename L3>
typename result<Lazy_construction_variant(L1, L2, L3)>::type
decltype(auto)
operator()(const L1& l1, const L2& l2, const L3& l3) const {
typedef typename result<Lazy_construction_variant(L1, L2, L3)>::type result_type;
typedef typename cpp11::result_of<AC(typename Type_mapper<L1, LK, AK>::type,
typename Type_mapper<L2, LK, AK>::type,
typename Type_mapper<L3, LK, AK>::type)>::type AT;
typedef typename cpp11::result_of<EC(typename Type_mapper<L1, LK, EK>::type,
typename Type_mapper<L2, LK, EK>::type,
typename Type_mapper<L3, LK, EK>::type)>::type ET;
// typedef decltype(std::declval<AC>()(std::declval<typename Type_mapper<L1, LK, AK>::type>(),
// std::declval<typename Type_mapper<L2, LK, AK>::type>(),
// std::declval<typename Type_mapper<L3, LK, AK>::type>())) AT;
// typedef decltype(std::declval<EC>()(std::declval<typename Type_mapper<L1, LK, EK>::type>(),
// std::declval<typename Type_mapper<L2, LK, EK>::type>(),
// std::declval<typename Type_mapper<L3, LK, EK>::type>())) ET;
typedef decltype(std::declval<AC const&>()(CGAL::approx(l1), CGAL::approx(l2), CGAL::approx(l3))) AT;
typedef decltype(std::declval<EC const&>()( CGAL::exact(l1), CGAL::exact(l2), CGAL::exact(l3))) ET;
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp);
Protect_FPU_rounding<Protection> P;
try {
Lazy<AT, ET, E2A> lazy(new Lazy_rep_n<AT, ET, AC, EC, E2A, L1, L2, L3>(AC(), EC(), l1, l2, l3));
@ -1781,7 +1774,7 @@ struct Lazy_construction<LK, AC, EC, E2A_, true> {
#define CGAL_CONSTRUCTION_OPERATOR(z, n, d ) \
template<BOOST_PP_ENUM_PARAMS(n, class L)> \
result_type \
decltype(auto) \
operator()( BOOST_PP_ENUM(n, CGAL_LARGS, _) ) const { \
typedef Lazy< AT, ET, E2A> Handle; \
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \
@ -1799,7 +1792,7 @@ struct Lazy_construction<LK, AC, EC, E2A_, true> {
BOOST_PP_REPEAT_FROM_TO(1, 9, CGAL_CONSTRUCTION_OPERATOR, _)
// nullary
result_type
decltype(auto)
operator()() const
{
typedef Lazy<AT, ET, E2A> Handle;
@ -1830,27 +1823,18 @@ struct Lazy_construction<LK, AC, EC, E2A_, false>
CGAL_NO_UNIQUE_ADDRESS EC ec;
// acquire the result_type of the approximate kernel, map it back to the lazy kernel object
#define CGAL_RESULT(z, n, d) \
template< typename F, BOOST_PP_ENUM_PARAMS(n, class T) > \
struct result<F( BOOST_PP_ENUM_PARAMS(n, T) )> { \
BOOST_PP_REPEAT(n, CGAL_TYPEMAP_AC, T) \
typedef typename Type_mapper< typename cpp11::result_of<AC( BOOST_PP_ENUM_PARAMS(n, A) )>::type, AK, LK>::type type; \
};
BOOST_PP_REPEAT_FROM_TO(1, 9, CGAL_RESULT, _)
#define CGAL_CONSTRUCTION_OPERATOR(z, n, d) \
template<BOOST_PP_ENUM_PARAMS(n, class L)> \
typename cpp11::result_of<Lazy_construction(BOOST_PP_ENUM_PARAMS(n, L))>::type \
decltype(auto) \
operator()( BOOST_PP_ENUM(n, CGAL_LARGS, _) ) const { \
BOOST_PP_REPEAT(n, CGAL_TYPEMAP_EC, L) \
BOOST_PP_REPEAT(n, CGAL_TYPEMAP_AC, L) \
typedef typename boost::remove_cv< typename boost::remove_reference < \
typename cpp11::result_of< EC(BOOST_PP_ENUM_PARAMS(n, E)) >::type >::type >::type ET; \
typedef typename boost::remove_cv< typename boost::remove_reference < \
typename cpp11::result_of< AC(BOOST_PP_ENUM_PARAMS(n, A)) >::type >::type >::type AT; \
typedef typename Type_mapper<decltype(std::declval<EC>()(BOOST_PP_ENUM(n, CGAL_PARAM, E))),EK,EK>::type ET; \
typedef typename Type_mapper<decltype(std::declval<AC>()(BOOST_PP_ENUM(n, CGAL_PARAM, A))),AK,AK>::type AT; \
typedef Lazy< AT, ET, E2A> Handle; \
typedef typename cpp11::result_of<Lazy_construction(BOOST_PP_ENUM_PARAMS(n, L))>::type result_type; \
typedef typename result<Lazy_construction(BOOST_PP_ENUM_PARAMS(n, L))>::type result_type; \
CGAL_BRANCH_PROFILER(std::string(" failures/calls to : ") + std::string(CGAL_PRETTY_FUNCTION), tmp); \
Protect_FPU_rounding<Protection> P; \
try { \
@ -1866,13 +1850,13 @@ struct result<F( BOOST_PP_ENUM_PARAMS(n, T) )> { \
BOOST_PP_REPEAT_FROM_TO(1, 9, CGAL_CONSTRUCTION_OPERATOR, _)
// nullary
typename Type_mapper< typename cpp11::result_of<AC()>::type ,AK, LK>::type
decltype(auto)
operator()() const
{
typedef typename cpp11::result_of<AC()>::type AT;
typedef typename cpp11::result_of<EC()>::type ET;
typedef decltype(std::declval<AC>()()) AT;
typedef decltype(std::declval<EC>()()) ET;
typedef Lazy<AT, ET, E2A> Handle;
typedef typename Type_mapper< typename cpp11::result_of<AC()>::type ,AK, LK>::type result_type;
typedef typename Type_mapper<AT, AK, LK>::type result_type;
return result_type( Handle(new Lazy_rep_0<AT,ET,E2A>()) );
}

View File

@ -35,7 +35,7 @@ int main()
obj = CGAL::intersection(s1,s2);
// check the variant return type
CGAL::cpp11::result_of<K::Intersect_2(Triangle_2, Triangle_2) >::type o_variant = CGAL::intersection(t1,t2);
const auto o_variant = CGAL::intersection(t1,t2);
if(!o_variant) {
std::cerr << "ERROR, empty" << std::endl;
return EXIT_FAILURE;
@ -75,7 +75,7 @@ int main()
}
// check the variant return type
CGAL::cpp11::result_of<K::Intersect_3(Triangle_3, Triangle_3)>::type o_variant = CGAL::intersection(t1,t2);
const auto o_variant = CGAL::intersection(t1,t2);
if(!o_variant) {
std::cerr << "ERROR, empty" << std::endl;
return EXIT_FAILURE;

View File

@ -18,6 +18,7 @@
#include <CGAL/generators.h>
#include <CGAL/Random.h>
#include <CGAL/property_map.h>
#include <CGAL/result_of.h>
#include <vector>

View File

@ -17,7 +17,6 @@
#include <CGAL/Object.h>
#include <CGAL/assertions.h>
#include <CGAL/Dimension.h>
#include <CGAL/result_of.h>
#include <boost/type_traits/is_same.hpp>
#include <boost/variant.hpp>
@ -41,13 +40,13 @@
#define CGAL_INTERSECTION_FUNCTION(A, B, DIM) \
template<typename K> \
inline \
typename cpp11::result_of<BOOST_PP_CAT(typename K::Intersect_, DIM)(typename K::A, typename K::B)>::type \
decltype(auto) \
intersection(const A<K>& a, const B<K>& b) { \
return BOOST_PP_CAT(K().intersect_, BOOST_PP_CAT(DIM, _object()(a, b))); \
} \
template<typename K> \
inline \
typename cpp11::result_of<BOOST_PP_CAT(typename K::Intersect_, DIM)(typename K::A, typename K::B)>::type \
decltype(auto) \
intersection(const B<K>& a, const A<K>& b) { \
return BOOST_PP_CAT(K().intersect_, BOOST_PP_CAT(DIM, _object()(a, b))); \
}
@ -55,7 +54,7 @@
#define CGAL_INTERSECTION_FUNCTION_SELF(A, DIM) \
template<typename K> \
inline \
typename cpp11::result_of<BOOST_PP_CAT(typename K::Intersect_, DIM)(typename K::A, typename K::A)>::type \
decltype(auto) \
intersection(const A<K> & a, const A<K> & b) { \
return BOOST_PP_CAT(K().intersect_, BOOST_PP_CAT(DIM, _object()(a, b))); \
}
@ -123,11 +122,11 @@ namespace internal {
// the real type.
// Overloads for empty returns are also provided.
template<typename F, typename A, typename B, typename T>
inline typename cpp11::result_of<F(A, B)>::type
intersection_return(T&& t) { return typename cpp11::result_of<F(A, B)>::type(std::forward<T>(t)); }
decltype(auto)
intersection_return(T&& t) { return decltype(std::declval<F>()(std::declval<A>(), std::declval<B>()))(std::forward<T>(t)); }
template<typename F, typename A, typename B>
inline typename cpp11::result_of<F(A, B)>::type
intersection_return() { return typename cpp11::result_of<F(A, B)>::type(); }
decltype(auto)
intersection_return() { return decltype(std::declval<F>()(std::declval<A>(), std::declval<B>()))(); }
// Something similar to wrap around boost::get and object_cast to
// prevent ifdefing too much. Another way could be to introduce an
@ -153,14 +152,14 @@ const T* intersect_get(const boost::variant<BOOST_VARIANT_ENUM_PARAMS(U)> & v) {
}
template<typename A, typename B>
typename cpp11::result_of<typename CGAL::Kernel_traits<A>::Kernel::Intersect_2(A, B)>::type
decltype(auto)
intersection_impl(const A& a, const B& b, CGAL::Dimension_tag<2>) {
typedef typename CGAL::Kernel_traits<A>::Kernel Kernel;
return Kernel().intersect_2_object()(a, b);
}
template<typename A, typename B>
typename cpp11::result_of<typename CGAL::Kernel_traits<A>::Kernel::Intersect_3(A, B)>::type
decltype(auto)
intersection_impl(const A& a, const B& b, Dimension_tag<3>) {
typedef typename CGAL::Kernel_traits<A>::Kernel Kernel;
return Kernel().intersect_3_object()(a, b);

View File

@ -57,7 +57,7 @@ namespace CGAL {
// the special plane_3 function
template <class K>
inline
typename cpp11::result_of<typename K::Intersect_3(typename K::Plane_3, typename K::Plane_3, typename K::Plane_3)>::type
decltype(auto)
intersection(const Plane_3<K> &plane1, const Plane_3<K> &plane2,
const Plane_3<K> &plane3)
{

View File

@ -25,9 +25,9 @@ typedef CGAL::Bbox_3 Bbox_3;
template<class A, class B>
void call_intersection_global(const A& a, const B& b) {
typename CGAL::cpp11::result_of<K::Intersect_3(A, B)>::type x = CGAL::intersection(a, b);
typename CGAL::cpp11::result_of<K::Intersect_3(A, B)>::type y = CGAL::intersection(b, a);
typename CGAL::cpp11::result_of<K::Intersect_3(B, A)>::type z = CGAL::intersection(b, a);
const auto x = CGAL::intersection(a, b);
const auto y = CGAL::intersection(b, a);
const auto z = CGAL::intersection(b, a);
CGAL_USE(x);
CGAL_USE(y);
CGAL_USE(z);
@ -42,8 +42,8 @@ void call_do_intersect_global(const A& a, const B& b) {
template<class A, class B, class K>
void call_intersection_with_kernel(const A& a, const B& b, const K&) {
typedef typename K::Intersect_3 Intersect;
typename CGAL::cpp11::result_of<Intersect(A, B)>::type x = Intersect()(a, b);
typename CGAL::cpp11::result_of<Intersect(A, B)>::type y = Intersect()(b, a);
const auto x = Intersect()(a, b);
const auto y = Intersect()(b, a);
}
template<class A, class B, class K>
@ -83,7 +83,7 @@ int main(int argc, char**)
// call_intersection_global(Pl(), Cub());
// special
CGAL::cpp11::result_of<K::Intersect_3(Pl, Pl, Pl)>::type plplpl = CGAL::intersection(Pl(), Pl(), Pl());
const auto plplpl = CGAL::intersection(Pl(), Pl(), Pl());
call_intersection_global(Tr(), S());
call_intersection_global(Tr(), L());

View File

@ -46,10 +46,9 @@ the following function overloads are also available.
The iterator versions of those functions can be used in conjunction
with `Dispatch_output_iterator`.
Since both the number of intersections, if any, and their types, depend
on the arguments, the function expects an output iterator on
`cpp11::result_of<K::Intersect_2(Type1, Type2)>::%type`, as
presented below.
Since both the number of intersections, if any, and types of the interesection results
depend on the arguments, the function expects an output iterator on `K::Intersect_2(Type1, Type2)`
as presented below.
*/
/// @{

View File

@ -57,20 +57,16 @@ the following function overloads are also available.
The iterator versions of those functions can be used in conjunction
with `Dispatch_output_iterator`.
Since both the number of intersections, if any, and their types, depend
on the arguments, the function expects an output iterator on
`cpp11::result_of<Kernel::Intersect_3(Type1, Type2)>::%type`,
Since both the number of intersections, if any, and types of the interesection results
depend on the arguments, the function expects an output iterator on `Kernel::Intersect_3(Type1, Type2)`
as presented below.
*/
/// @{
/*!
Copies in the output iterator the intersection elements between the
two objects. `intersections` iterates on
elements of type `result_of< Intersect_3(SphericalType1, SphericalType2) >`, in lexicographic order,
when this ordering is defined on the computed objects,
where `SphericalType1` and `SphericalType2` can both be one of:
Constructs the intersection elements between the two input
objects and stores them in the OutputIterator in lexicographic order,
where both, `SphericalType1` and `SphericalType2`, can be either
- `Sphere_3<SphericalKernel>`,
- `Plane_3<SphericalKernel>`,
@ -90,7 +86,7 @@ type can be
and if the two objets `obj1` and `obj2` are equal,
- `Line_3<SphericalKernel>` or
`Circle_3<SphericalKernel>` when `SphericalType1` and `SphericalType2`
are two-dimensional objets intersecting along a curve (2 planes, or 2
are two-dimensional objects intersecting along a curve (2 planes, or 2
spheres, or one plane and one sphere),
- `Circular_arc_3<SphericalKernel>` in case of an overlap of
two circular arcs or

View File

@ -101,12 +101,15 @@ The following tables give the possible values for `Type1` and `Type2`.
\cgalHeading{2D Intersections}
The return type can be obtained through `CGAL::cpp11::result_of<Kernel::Intersect_2(A, B)>::%type`.
It is equivalent to `boost::optional< boost::variant< T... > >`, the last column in the table providing the template parameter pack.
The return type of intersecting two objects of the types `Type1` and `Type2` can be
specified through the placeholder type specifier `auto`. It is equivalent to
`boost::optional< boost::variant< T... > >`, the last column in the table providing
the template parameter pack.
<DIV ALIGN="CENTER">
<TABLE CELLPADDING=3 BORDER="1">
<TR> <TH> Type1 </TH>
<TR>
<TH> Type1 </TH>
<TH> Type2 </TH>
<TH> Return Type: `T...` </TH>
</TR>
@ -197,12 +200,15 @@ intersections existing with the type `Iso_rectangle_2`. Note that the return typ
\cgalHeading{3D Intersections}
The return type can be obtained through `CGAL::cpp11::result_of<Kernel::Intersect_3(A, B)>::%type`.
It is equivalent to `boost::optional< boost::variant< T... > >`, the last column in the table providing the template parameter pack.
The return type of intersecting two objects of the types `Type1` and `Type2` can be
specified through the placeholder type specifier `auto`. It is equivalent to
`boost::optional< boost::variant< T... > >`, the last column in the table providing
the template parameter pack.
<DIV ALIGN="CENTER">
<TABLE CELLPADDING=3 BORDER="1">
<TR> <TH> Type1 </TH>
<TR>
<TH> Type1 </TH>
<TH> Type2 </TH>
<TH> Return Type: `T...` </TH>
</TR>
@ -356,9 +362,9 @@ The following examples demonstrate the most common use of
`intersection()` functions with the 2D and 3D Linear %Kernel.
In the first two examples we intersect a segment and a line.
The result type can be obtained with `CGAL::cpp11::result_of`. It looks simpler
if you use a C++ compiler which supports `auto`,
but you must anyways know that the result type is a `boost::optional<boost::variant<..> >`, in order to unpack the point or segment.
The result type can be specified through the placeholder type specifier `auto`,
but you must anyway know that the result type is a `boost::optional<boost::variant<..> >`,
in order to unpack the point or segment.
<A HREF="https://www.boost.org/libs/optional/">`boost::optional`</A> comes in
as there might be no intersection. <A HREF="https://www.boost.org/libs/variant/">`boost::variant`</A> comes in
@ -380,7 +386,7 @@ a standard library algorithm.
*/
template <typename Kernel>
cpp11::result_of<Kernel::Intersect_23(Type1, Type2)>::type
decltype(auto)
intersection(Type1<Kernel> obj1, Type2<Kernel> obj2);
/*!
@ -388,7 +394,7 @@ returns the intersection of 3 planes, which can be a
point, a line, a plane, or empty.
*/
template <typename Kernel>
boost::optional< boost::variant< Point_3, Line_3, Plane_3 > >
decltype(auto)
intersection(const Plane_3<Kernel>& pl1,
const Plane_3<Kernel>& pl2,
const Plane_3<Kernel>& pl3);

View File

@ -8409,8 +8409,6 @@ public:
\cgalRefines `AdaptableFunctor` (with two arguments)
\sa \link intersection_grp `CGAL::intersection()` \endlink
\sa `CGAL::cpp11::result_of`
*/
class Intersect_2 {
public:
@ -8424,7 +8422,7 @@ public:
`Type1` and `Type2`, for all pairs `Type1` and `Type2`.
For details see the reference manual page for \link intersection_grp `CGAL::intersection()` \endlink.
*/
CGAL::cpp11::result_of<Kernel::Intersect_2(Type1, Type2)>::type
decltype(auto)
operator()(Type1 obj1, Type2 obj2);
/// @}
@ -8438,8 +8436,6 @@ public:
\cgalRefines `AdaptableFunctor` (with two or three arguments)
\sa intersection_linear_grp
\sa `CGAL::cpp11::result_of`
*/
class Intersect_3 {
public:
@ -8453,7 +8449,7 @@ public:
objects of type `Type1` and `Type2`.
For details see the reference manual page for \ref intersection_linear_grp.
*/
CGAL::cpp11::result_of<Kernel::Intersect_3(Type1, Type2)>::type
decltype(auto)
operator()(Type1 obj1, Type2 obj2);

View File

@ -493,23 +493,19 @@ especially integer types and rationals.
\subsection Kernel_23VariantReturnValues Intersections and Variant Return Types
Some functions, for example \link intersection_linear_grp `intersection()`\endlink, can return different types of objects. To achieve this
in a type-safe way \cgal uses return values of type
`boost::optional< boost::variant< T... > >` were `T...` is a
list of all possible resulting geometric objects. The exact result
type of an intersection can be determined through the metafunction
`cpp11::result_of<Kernel::Intersect_2(Type1, Type2)>` or
`cpp11::result_of<Kernel::Intersect_3(Type1, Type2)>`, where
`Type1` and `Type2` are the types of the objects used in the
intersection computation.
Some functions, for example \link intersection_linear_grp `intersection()`\endlink,
can return different types of objects. To achieve this in a type-safe way \cgal uses
return values of type `boost::optional< boost::variant< T... > >` where `T...` is a
list of all possible resulting geometric objects. The exact result type of an intersection
can be specified through the placeholder type specifier `auto`.
Example
-------
In the following example, `result_of` is used to query the type of the
return value for the intersection computation:
In the following example, `auto` is used to specify the type of the return value
for the intersection computation:
\code{.cpp}
typedef Cartesian<double> K;
@ -521,13 +517,9 @@ Segment_2 segment_1, segment_2;
std::cin >> segment_1 >> segment_2;
/* C++11 */
// auto v = intersection(segment_1, segment_2);
/* C++03 */
cpp11::result_of<K::Intersect_2(Segment_2, Segment_2)>::type
v = intersection(segment_1, segment_2);
if(v) {
/* use auto */
auto v = intersection(segment_1, segment_2);
if (v) {
/* not empty */
if (const Point_2 *p = boost::get<Point_2>(&*v) ) {
/* do something with *p */

View File

@ -56,8 +56,7 @@ int main()
K::Intersect_2 intersection;
CGAL::cpp11::result_of<K::Intersect_2(Segment, Segment)>::type
intersect = intersection(s1, s2);
const auto intersect = intersection(s1, s2);
K::Construct_cartesian_const_iterator_2 construct_it;
K::Cartesian_const_iterator_2 cit = construct_it(a);

View File

@ -25,8 +25,7 @@ int main(){
EK::Triangle_3 t2=to_exact(t1);
EK::Line_3 l2=to_exact(l1);
CGAL::cpp11::result_of<EK::Intersect_3(EK::Triangle_3, EK::Line_3)>::type
inter = CGAL::intersection(t2,l2);
const auto inter = CGAL::intersection(t2,l2);
// As we are sure that there IS an intersection
// and that the intersection IS a point

View File

@ -12,8 +12,7 @@ int main()
Segment_2 seg(Point_2(0,0), Point_2(2,2));
Line_2 lin(1,-1,0);
CGAL::cpp11::result_of<Intersect_2(Segment_2, Line_2)>::type
result = intersection(seg, lin);
const auto result = intersection(seg, lin);
if (result) {
if (const Segment_2* s = boost::get<Segment_2>(&*result)) {
std::cout << *s << std::endl;

View File

@ -26,11 +26,7 @@ int main()
Segment_2 seg(Point_2(0,0), Point_2(1,1));
Line_2 lin(1,-1,0);
// with C++11 support
// auto result = intersection(seg, lin);
// without C++11
CGAL::cpp11::result_of<Intersect_2(Segment_2, Line_2)>::type
result = intersection(seg, lin);
const auto result = intersection(seg, lin);
if (result) {
boost::apply_visitor(Intersection_visitor(), *result);
} else {

View File

@ -13,13 +13,12 @@ typedef CGAL::Creator_uniform_2< Point, Segment> Seg_creator;
typedef CGAL::Join_input_iterator_2< P1, P2, Seg_creator> Seg_iterator;
struct Intersector{
typedef CGAL::cpp11::result_of<K::Intersect_2(Segment,Segment)>::type result_type;
const Segment& s;
K::Intersect_2 intersect;
Intersector(const Segment& seg): s(seg) {}
result_type
decltype(auto)
operator() ( const Segment& other) const
{
return intersect(s, other);

View File

@ -18,7 +18,6 @@
#include <CGAL/config.h>
#include <CGAL/kernel_assertions.h>
#include <CGAL/result_of.h>
#include <CGAL/IO/io.h>
#include <CGAL/Dimension.h>
#include <CGAL/array.h>

View File

@ -24,7 +24,6 @@
#include <CGAL/Bbox_2.h>
#include <CGAL/Dimension.h>
#include <CGAL/number_utils.h>
#include <CGAL/result_of.h>
namespace CGAL {
@ -89,13 +88,13 @@ public:
Circle_2(const Point_2 & center)
: RCircle_2(typename R::Construct_circle_2()(Return_base_tag(), center, FT(0), COUNTERCLOCKWISE)) {}
typename cpp11::result_of<typename R::Construct_center_2(Circle_2)>::type
decltype(auto)
center() const
{
return R().construct_center_2_object()(*this);
}
typename cpp11::result_of<typename R::Compute_squared_radius_2(Circle_2)>::type
decltype(auto)
squared_radius() const
{
return R().compute_squared_radius_2_object()(*this);

View File

@ -93,8 +93,7 @@ public:
Circle_3(const Rep& r)
: Rep(r) {}
typename cpp11::result_of
<typename R::Construct_sphere_3( Circle_3)>::type
decltype(auto)
diametral_sphere() const
{
return typename R::Construct_sphere_3()(*this);
@ -110,8 +109,7 @@ public:
return typename R::Construct_sphere_3()(*this).squared_radius();
}
typename cpp11::result_of
<typename R::Construct_plane_3( Circle_3)>::type
decltype(auto)
supporting_plane() const
{
return typename R::Construct_plane_3()(*this);

View File

@ -23,7 +23,6 @@
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/representation_tags.h>
#include <CGAL/Dimension.h>
#include <CGAL/result_of.h>
#include <CGAL/IO/io.h>
namespace CGAL {
@ -93,19 +92,19 @@ public:
return R().construct_perpendicular_direction_2_object()(*this,o);
}
typename cpp11::result_of<typename R::Compute_dx_2( Direction_2)>::type
decltype(auto)
dx() const
{
return R().compute_dx_2_object()(*this);
}
typename cpp11::result_of<typename R::Compute_dy_2( Direction_2)>::type
decltype(auto)
dy() const
{
return R().compute_dy_2_object()(*this);
}
typename cpp11::result_of<typename R::Compute_dx_2( Direction_2)>::type
decltype(auto)
delta(int i) const
{
CGAL_kernel_precondition( ( i == 0 ) || ( i == 1 ) );

View File

@ -23,7 +23,6 @@
#include <CGAL/kernel_assertions.h>
#include <CGAL/representation_tags.h>
#include <CGAL/Dimension.h>
#include <CGAL/result_of.h>
#include <CGAL/IO/io.h>
namespace CGAL {
@ -99,25 +98,25 @@ public:
Vector_3 vector() const { return to_vector(); }
typename cpp11::result_of<typename R::Compute_dx_3(Direction_3)>::type
decltype(auto)
dx() const
{
return R().compute_dx_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_dy_3(Direction_3)>::type
decltype(auto)
dy() const
{
return R().compute_dy_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_dz_3(Direction_3)>::type
decltype(auto)
dz() const
{
return R().compute_dz_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_dx_3(Direction_3)>::type
decltype(auto)
delta(int i) const
{
CGAL_kernel_precondition( i >= 0 && i <= 2 );

View File

@ -86,67 +86,67 @@ public:
: Rep(typename R::Construct_iso_cuboid_3()(Return_base_tag(), bbox.xmin(), bbox.ymin(), bbox.zmin(),
bbox.xmax(), bbox.ymax(), bbox.zmax())) {}
typename cpp11::result_of<typename R::Construct_min_vertex_3( Iso_cuboid_3 )>::type
decltype(auto)
min BOOST_PREVENT_MACRO_SUBSTITUTION () const
{
return R().construct_min_vertex_3_object()(*this);
}
typename cpp11::result_of<typename R::Construct_max_vertex_3( Iso_cuboid_3 )>::type
decltype(auto)
max BOOST_PREVENT_MACRO_SUBSTITUTION () const
{
return R().construct_max_vertex_3_object()(*this);
}
typename cpp11::result_of<typename R::Construct_vertex_3( Iso_cuboid_3, int )>::type
decltype(auto)
vertex(int i) const
{
return R().construct_vertex_3_object()(*this,i);
}
typename cpp11::result_of<typename R::Construct_vertex_3( Iso_cuboid_3, int )>::type
decltype(auto)
operator[](int i) const
{
return R().construct_vertex_3_object()(*this,i);
}
typename cpp11::result_of<typename R::Compute_xmin_3( Iso_cuboid_3 )>::type
decltype(auto)
xmin() const
{
return R().compute_xmin_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_xmax_3( Iso_cuboid_3 )>::type
decltype(auto)
xmax() const
{
return R().compute_xmax_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_ymin_3( Iso_cuboid_3 )>::type
decltype(auto)
ymin() const
{
return R().compute_ymin_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_ymax_3( Iso_cuboid_3 )>::type
decltype(auto)
ymax() const
{
return R().compute_ymax_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_zmin_3( Iso_cuboid_3 )>::type
decltype(auto)
zmin() const
{
return R().compute_zmin_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_zmax_3( Iso_cuboid_3 )>::type
decltype(auto)
zmax() const
{
return R().compute_zmax_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_xmin_3( Iso_cuboid_3 )>::type
decltype(auto)
min_coord(int i) const
{
CGAL_kernel_precondition( i == 0 || i == 1 || i == 2 );
@ -158,7 +158,7 @@ public:
return zmin();
}
typename cpp11::result_of<typename R::Compute_xmax_3( Iso_cuboid_3 )>::type
decltype(auto)
max_coord(int i) const
{
CGAL_kernel_precondition( i == 0 || i == 1 || i == 2 );
@ -206,7 +206,7 @@ public:
return R().is_degenerate_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_volume_3( Iso_cuboid_3 )>::type
decltype(auto)
volume() const
{
return R().compute_volume_3_object()(*this);

View File

@ -22,7 +22,6 @@
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Bbox_2.h>
#include <CGAL/Dimension.h>
#include <CGAL/result_of.h>
namespace CGAL {
@ -82,13 +81,13 @@ public:
Iso_rectangle_2(const Bbox_2& bbox)
: Rep(typename R::Construct_iso_rectangle_2()(Return_base_tag(), bbox.xmin(), bbox.ymin(), bbox.xmax(), bbox.ymax())) {}
typename cpp11::result_of<typename R::Construct_min_vertex_2( Iso_rectangle_2 )>::type
decltype(auto)
min BOOST_PREVENT_MACRO_SUBSTITUTION () const
{
return R().construct_min_vertex_2_object()(*this);
}
typename cpp11::result_of<typename R::Construct_max_vertex_2( Iso_rectangle_2 )>::type
decltype(auto)
max BOOST_PREVENT_MACRO_SUBSTITUTION () const
{
return R().construct_max_vertex_2_object()(*this);
@ -107,43 +106,43 @@ public:
}
typename cpp11::result_of<typename R::Construct_vertex_2( Iso_rectangle_2, int )>::type
decltype(auto)
vertex(int i) const
{
return R().construct_vertex_2_object()(*this,i);
}
typename cpp11::result_of<typename R::Construct_vertex_2( Iso_rectangle_2, int )>::type
decltype(auto)
operator[](int i) const
{
return R().construct_vertex_2_object()(*this,i);
}
typename cpp11::result_of<typename R::Compute_xmin_2( Iso_rectangle_2 )>::type
decltype(auto)
xmin() const
{
return R().compute_xmin_2_object()(*this);
}
typename cpp11::result_of<typename R::Compute_xmax_2( Iso_rectangle_2 )>::type
decltype(auto)
xmax() const
{
return R().compute_xmax_2_object()(*this);
}
typename cpp11::result_of<typename R::Compute_ymin_2( Iso_rectangle_2 )>::type
decltype(auto)
ymin() const
{
return R().compute_ymin_2_object()(*this);
}
typename cpp11::result_of<typename R::Compute_ymax_2( Iso_rectangle_2 )>::type
decltype(auto)
ymax() const
{
return R().compute_ymax_2_object()(*this);
}
typename cpp11::result_of<typename R::Compute_xmin_2( Iso_rectangle_2 )>::type
decltype(auto)
min_coord(int i) const
{
CGAL_kernel_precondition( i == 0 || i == 1 );
@ -153,7 +152,7 @@ public:
return ymin();
}
typename cpp11::result_of<typename R::Compute_xmin_2( Iso_rectangle_2 )>::type
decltype(auto)
max_coord(int i) const
{
CGAL_kernel_precondition( i == 0 || i == 1 );

View File

@ -87,9 +87,13 @@ BOOST_PP_REPEAT_FROM_TO(1, 10, CGAL_VARIANT_TYPEMAP, _)
//};
// Then we specialize for all kernel objects.
// More details on why it is like that are here: https://github.com/CGAL/cgal/pull/4878#discussion_r459986501
#define CGAL_Kernel_obj(X) \
template < typename K1, typename K2 > \
struct Type_mapper_impl < typename K1::X, K1, K2 > \
{ typedef typename K2::X type; }; \
template < typename K1, typename K2 > \
struct Type_mapper_impl < typename K1::X::Rep, K1, K2 > \
{ typedef typename K2::X type; };
#include <CGAL/Kernel/interface_macros.h>

View File

@ -1715,8 +1715,7 @@ namespace CommonKernelFunctors {
Line l1 = construct_line(l11, l12);
Line l2 = construct_line(l21, l22);
typename cpp11::result_of<typename K::Intersect_3(Line,Line)>::type
res = typename K::Intersect_3()(l1,l2);
const auto res = typename K::Intersect_3()(l1,l2);
CGAL_assertion(res!=boost::none);
const Point* e_pt = boost::get<Point>(&(*res));
CGAL_assertion(e_pt!=nullptr);
@ -2115,8 +2114,7 @@ namespace CommonKernelFunctors {
Plane plane = construct_plane(p1, p2, p3);
Line line = construct_line( l1, l2 );
typename cpp11::result_of<typename K::Intersect_3(Plane,Line)>::type
res = typename K::Intersect_3()(plane,line);
const auto res = typename K::Intersect_3()(plane,line);
CGAL_assertion(res!=boost::none);
const Point* e_pt = boost::get<Point>(&(*res));
CGAL_assertion(e_pt!=nullptr);
@ -2129,8 +2127,7 @@ namespace CommonKernelFunctors {
{
Line line = construct_line( l1, l2 );
typename cpp11::result_of<typename K::Intersect_3(Plane,Line)>::type
res = typename K::Intersect_3()(plane,line);
const auto res = typename K::Intersect_3()(plane,line);
CGAL_assertion(res!=boost::none);
const Point* e_pt = boost::get<Point>(&(*res));
CGAL_assertion(e_pt!=nullptr);
@ -2593,15 +2590,6 @@ namespace CommonKernelFunctors {
typedef typename K::Triangle_3 Triangle_3;
typedef typename K::Tetrahedron_3 Tetrahedron_3;
public:
template<typename>
struct result {
typedef const Point_3& type;
};
template<typename T>
struct result<T(Iso_cuboid_3, int)> {
typedef Point_3 type;
};
const Point_3&
operator()( const Segment_3& s, int i) const
@ -3336,7 +3324,6 @@ namespace CommonKernelFunctors {
typedef typename K::Point_3 Point_3;
typedef typename K::Segment_3 Segment_3;
typedef typename K::Plane_3 Plane_3;
typedef typename K::Intersect_3 Intersect_3;
const Has_on_bounded_side_3& has_on_bounded_side = *this;
@ -3356,8 +3343,7 @@ namespace CommonKernelFunctors {
if(!K().do_intersect_3_object()(s1, s2)) return false;
const Circle_3 circ(s1, s2);
const Plane_3& plane = circ.supporting_plane();
typename CGAL::cpp11::result_of<Intersect_3(Plane_3, Segment_3)>::type
optional = K().intersect_3_object()(plane, Segment_3(a, b));
const auto optional = K().intersect_3_object()(plane, Segment_3(a, b));
CGAL_kernel_assertion_msg(bool(optional) == true,
"the segment does not intersect the supporting"
" plane");
@ -3548,17 +3534,10 @@ namespace CommonKernelFunctors {
class Intersect_2
{
public:
template<typename>
struct result;
template<typename F, typename A, typename B>
struct result<F(A,B)> {
typedef typename Intersection_traits<K, A, B>::result_type type;
};
// 25 possibilities, so I keep the template.
template <class T1, class T2>
typename Intersection_traits<K, T1, T2>::result_type
decltype(auto)
operator()(const T1& t1, const T2& t2) const
{ return Intersections::internal::intersection(t1, t2, K()); }
};
@ -3568,29 +3547,14 @@ namespace CommonKernelFunctors {
{
typedef typename K::Plane_3 Plane_3;
public:
template<typename>
struct result;
template<typename F, typename A, typename B>
struct result<F(A, B)> {
typedef typename Intersection_traits<K, A, B>::result_type type;
};
template<typename F>
struct result<F(Plane_3, Plane_3, Plane_3)> {
typedef boost::optional<
boost::variant< typename K::Point_3,
typename K::Line_3,
typename K::Plane_3 > > type;
};
// n possibilities, so I keep the template.
template <class T1, class T2>
typename cpp11::result_of< Intersect_3(T1, T2) >::type
decltype(auto)
operator()(const T1& t1, const T2& t2) const
{ return Intersections::internal::intersection(t1, t2, K() ); }
typename boost::optional< boost::variant< typename K::Point_3, typename K::Line_3, typename K::Plane_3 > >
decltype(auto)
operator()(const Plane_3& pl1, const Plane_3& pl2, const Plane_3& pl3)const
{ return Intersections::internal::intersection(pl1, pl2, pl3, K() ); }
};

View File

@ -21,7 +21,6 @@
// This file contains the definition of a kernel traits checker.
#include <CGAL/basic.h>
#include <CGAL/result_of.h>
#include <CGAL/use.h>
#include <utility>
@ -80,19 +79,14 @@ public:
{ }
template <class ... A>
typename Pairify<typename CGAL::cpp11::result_of<P1(const A&...)>::type,
typename CGAL::cpp11::result_of<P2(const A&...)>::type>::result_type
decltype(auto)
operator()(const A&... a) const
{
typedef typename CGAL::cpp11::result_of<P1(const A&...)>::type result_type_1;
typedef typename CGAL::cpp11::result_of<P2(const A&...)>::type result_type_2;
result_type_1 res1 = p1(a.first...);
result_type_2 res2 = p2(a.second...);
if (! cmp(res1, res2))
{
CGAL_kernel_assertion(false);
}
return Pairify<result_type_1, result_type_2>()(res1, res2);
auto res1 = p1(a.first...);
auto res2 = p2(a.second...);
CGAL_kernel_assertion(cmp(res1, res2));
return Pairify<decltype(res1), decltype(res2)>()(res1, res2);
}
};

View File

@ -21,7 +21,6 @@
#include <boost/type_traits/is_same.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Dimension.h>
#include <CGAL/result_of.h>
#include <CGAL/IO/io.h>
namespace CGAL {
@ -107,25 +106,25 @@ public:
return Direction_3(a(), b(), c());
}
typename cpp11::result_of<typename R::Compute_a_3( Plane_3)>::type
decltype(auto)
a() const
{
return R().compute_a_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_b_3( Plane_3)>::type
decltype(auto)
b() const
{
return R().compute_b_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_c_3( Plane_3)>::type
decltype(auto)
c() const
{
return R().compute_c_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_d_3( Plane_3)>::type
decltype(auto)
d() const
{
return R().compute_d_3_object()(*this);

View File

@ -24,7 +24,6 @@
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/representation_tags.h>
#include <CGAL/Dimension.h>
#include <CGAL/result_of.h>
namespace CGAL {
@ -93,26 +92,26 @@ public:
swap(a.rep(), b.rep());
}
typename cpp11::result_of<typename R::Compute_x_2(Point_2)>::type
decltype(auto)
x() const
{
return typename R::Compute_x_2()(*this);
}
typename cpp11::result_of<typename R::Compute_y_2(Point_2)>::type
decltype(auto)
y() const
{
return typename R::Compute_y_2()(*this);
}
typename cpp11::result_of<typename R::Compute_x_2(Point_2)>::type
decltype(auto)
cartesian(int i) const
{
CGAL_kernel_precondition( (i == 0) || (i == 1) );
return (i==0) ? x() : y();
}
typename cpp11::result_of<typename R::Compute_x_2(Point_2)>::type
decltype(auto)
operator[](int i) const
{
return cartesian(i);
@ -129,19 +128,19 @@ public:
}
typename cpp11::result_of<typename R::Compute_hx_2(Point_2)>::type
decltype(auto)
hx() const
{
return typename R::Compute_hx_2()(*this);
}
typename cpp11::result_of<typename R::Compute_hy_2(Point_2)>::type
decltype(auto)
hy() const
{
return typename R::Compute_hy_2()(*this);
}
typename cpp11::result_of<typename R::Compute_hw_2(Point_2)>::type
decltype(auto)
hw() const
{
return typename R::Compute_hw_2()(*this);
@ -152,7 +151,7 @@ public:
return 2;
}
typename cpp11::result_of<typename R::Compute_hx_2(Point_2)>::type
decltype(auto)
homogeneous(int i) const
{
CGAL_kernel_precondition( (i >= 0) || (i <= 2) );

View File

@ -90,49 +90,49 @@ public:
swap(a.rep(), b.rep());
}
typename cpp11::result_of<typename R::Compute_x_3( Point_3)>::type
decltype(auto)
x() const
{
return typename R::Compute_x_3()(*this);
}
typename cpp11::result_of<typename R::Compute_y_3( Point_3)>::type
decltype(auto)
y() const
{
return typename R::Compute_y_3()(*this);
}
typename cpp11::result_of<typename R::Compute_z_3( Point_3)>::type
decltype(auto)
z() const
{
return typename R::Compute_z_3()(*this);
}
typename cpp11::result_of<typename R::Compute_hx_3( Point_3)>::type
decltype(auto)
hx() const
{
return R().compute_hx_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_hy_3( Point_3)>::type
decltype(auto)
hy() const
{
return R().compute_hy_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_hz_3( Point_3)>::type
decltype(auto)
hz() const
{
return R().compute_hz_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_hw_3( Point_3)>::type
decltype(auto)
hw() const
{
return R().compute_hw_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_x_3( Point_3)>::type
decltype(auto)
cartesian(int i) const
{
CGAL_kernel_precondition( (i == 0) || (i == 1) || (i == 2) );
@ -151,7 +151,7 @@ public:
return hw();
}
typename cpp11::result_of<typename R::Compute_x_3(Point_3)>::type
decltype(auto)
operator[](int i) const
{
return cartesian(i);

View File

@ -23,7 +23,6 @@
#include <CGAL/kernel_assertions.h>
#include <CGAL/representation_tags.h>
#include <CGAL/Dimension.h>
#include <CGAL/result_of.h>
#include <CGAL/IO/io.h>
namespace CGAL {
@ -81,13 +80,13 @@ public:
: RRay_2(typename R::Construct_ray_2()(Return_base_tag(), sp, l)) {}
typename cpp11::result_of<typename R_::Construct_source_2( Ray_2)>::type
decltype(auto)
source() const
{
return R().construct_source_2_object()(*this);
}
typename cpp11::result_of<typename R_::Construct_second_point_2( Ray_2)>::type
decltype(auto)
second_point() const
{
return R().construct_second_point_2_object()(*this);
@ -108,7 +107,7 @@ public:
construct_scaled_vector(construct_vector(source(), second_point()), i));
}
typename cpp11::result_of<typename R_::Construct_source_2( Ray_2 )>::type
decltype(auto)
start() const
{
return source();

View File

@ -22,7 +22,6 @@
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/representation_tags.h>
#include <CGAL/Dimension.h>
#include <CGAL/result_of.h>
#include <CGAL/IO/io.h>
namespace CGAL {
@ -99,25 +98,25 @@ public:
bool collinear_has_on(const Point_3 &p) const;
*/
typename cpp11::result_of<typename R::Construct_point_on_3(Ray_3, FT)>::type
decltype(auto)
point(const FT i) const
{
return R().construct_point_on_3_object()(*this, i);
}
typename cpp11::result_of<typename R::Construct_source_3(Ray_3)>::type
decltype(auto)
source() const
{
return R().construct_source_3_object()(*this);
}
typename cpp11::result_of<typename R::Construct_second_point_3(Ray_3)>::type
decltype(auto)
second_point() const
{
return R().construct_second_point_3_object()(*this);
}
typename cpp11::result_of<typename R::Construct_source_3(Ray_3)>::type
decltype(auto)
start() const
{
return source();

View File

@ -23,7 +23,6 @@
#include <CGAL/Bbox_2.h>
#include <CGAL/Dimension.h>
#include <CGAL/kernel_config.h>
#include <CGAL/result_of.h>
namespace CGAL {
@ -70,45 +69,53 @@ public:
Segment_2(const Point_2 &sp, const Point_2 &ep)
: RSegment_2(typename R::Construct_segment_2()(Return_base_tag(), sp,ep)) {}
typename cpp11::result_of<typename R::Construct_source_2( Segment_2)>::type
decltype(auto)
source() const
{
return R_().construct_source_2_object()(*this);
}
typename cpp11::result_of<typename R::Construct_target_2( Segment_2)>::type
decltype(auto)
target() const
{
return R_().construct_target_2_object()(*this);
}
typename cpp11::result_of<typename R::Construct_source_2( Segment_2)>::type
decltype(auto)
start() const
{
return source();
}
typename cpp11::result_of<typename R::Construct_target_2( Segment_2)>::type
decltype(auto)
end() const
{
return target();
}
decltype(auto)
min BOOST_PREVENT_MACRO_SUBSTITUTION() const {
typename R_::Less_xy_2 less_xy;
return less_xy(source(), target()) ? source() : target();
}
typename cpp11::result_of<typename R_::Construct_min_vertex_2(Segment_2)>::type
min BOOST_PREVENT_MACRO_SUBSTITUTION() const;
decltype(auto)
max BOOST_PREVENT_MACRO_SUBSTITUTION() const {
typename R_::Less_xy_2 less_xy;
return less_xy(source(), target()) ? target() : source();
}
typename cpp11::result_of<typename R_::Construct_max_vertex_2( Segment_2)>::type
max BOOST_PREVENT_MACRO_SUBSTITUTION () const;
decltype(auto)
vertex(int i) const
{ return (i%2 == 0) ? source() : target(); }
typename cpp11::result_of<typename R_::Construct_vertex_2( Segment_2, int)>::type
vertex(int i) const;
decltype(auto)
point(int i) const
{ return vertex(i); }
typename cpp11::result_of<typename R_::Construct_vertex_2( Segment_2, int)>::type
point(int i) const;
typename cpp11::result_of<typename R_::Construct_vertex_2( Segment_2, int)>::type
operator[](int i) const;
decltype(auto)
operator[](int i) const
{ return vertex(i); }
bool is_horizontal() const;
bool is_vertical() const;
@ -170,47 +177,6 @@ public:
}
};
template < class R_ >
CGAL_KERNEL_INLINE
typename cpp11::result_of<typename R_::Construct_min_vertex_2( Segment_2<R_> )>::type
Segment_2<R_>::min BOOST_PREVENT_MACRO_SUBSTITUTION () const
{
typename R_::Less_xy_2 less_xy;
return less_xy(source(),target()) ? source() : target();
}
template < class R_ >
CGAL_KERNEL_INLINE
typename cpp11::result_of<typename R_::Construct_max_vertex_2( Segment_2<R_> )>::type
Segment_2<R_>::max BOOST_PREVENT_MACRO_SUBSTITUTION () const
{
typename R_::Less_xy_2 less_xy;
return less_xy(source(),target()) ? target() : source();
}
template < class R_ >
CGAL_KERNEL_INLINE
typename cpp11::result_of<typename R_::Construct_vertex_2( Segment_2<R_>, int )>::type
Segment_2<R_>::vertex(int i) const
{
return (i%2 == 0) ? source() : target();
}
template < class R_ >
inline
typename cpp11::result_of<typename R_::Construct_vertex_2( Segment_2<R_>, int )>::type
Segment_2<R_>::point(int i) const
{
return vertex(i);
}
template < class R_ >
inline
typename cpp11::result_of<typename R_::Construct_vertex_2( Segment_2<R_>, int )>::type
Segment_2<R_>::operator[](int i) const
{
return vertex(i);
}
template < class R_ >
CGAL_KERNEL_INLINE

View File

@ -68,44 +68,51 @@ public:
Segment_3(const Point_3& sp, const Point_3& ep)
: Rep(typename R::Construct_segment_3()(Return_base_tag(), sp, ep)) {}
typename cpp11::result_of<typename R::Construct_source_3(Segment_3)>::type
decltype(auto)
source() const
{
return R_().construct_source_3_object()(*this);
}
typename cpp11::result_of<typename R::Construct_target_3(Segment_3)>::type
decltype(auto)
target() const
{
return R_().construct_target_3_object()(*this);
}
typename cpp11::result_of<typename R::Construct_source_3(Segment_3)>::type
decltype(auto)
start() const
{
return source();
}
typename cpp11::result_of<typename R::Construct_target_3(Segment_3)>::type
decltype(auto)
end() const
{
return target();
}
typename cpp11::result_of<typename R_::Construct_min_vertex_3(Segment_3)>::type
min BOOST_PREVENT_MACRO_SUBSTITUTION () const;
decltype(auto)
min BOOST_PREVENT_MACRO_SUBSTITUTION() const {
typename R_::Less_xyz_3 less_xyz;
return less_xyz(source(), target()) ? source() : target();
}
typename cpp11::result_of<typename R_::Construct_max_vertex_3(Segment_3)>::type
max BOOST_PREVENT_MACRO_SUBSTITUTION () const;
decltype(auto)
max BOOST_PREVENT_MACRO_SUBSTITUTION() const {
typename R_::Less_xyz_3 less_xyz;
return less_xyz(source(), target()) ? target() : source();
}
typename cpp11::result_of<typename R_::Construct_vertex_3(Segment_3, int)>::type
vertex(int i) const;
decltype(auto)
vertex(int i) const
{ return (i%2 == 0) ? source() : target(); }
typename cpp11::result_of<typename R::Construct_vertex_3(Segment_3, int)>::type
decltype(auto)
point(int i) const
{ return vertex(i); }
typename cpp11::result_of<typename R::Construct_vertex_3(Segment_3, int)>::type
decltype(auto)
operator[](int i) const
{ return vertex(i); }
@ -161,32 +168,6 @@ public:
};
template < class R_ >
CGAL_KERNEL_INLINE
typename cpp11::result_of<typename R_::Construct_min_vertex_3( Segment_3<R_> ) >::type
Segment_3<R_>::min BOOST_PREVENT_MACRO_SUBSTITUTION () const
{
typename R_::Less_xyz_3 less_xyz;
return less_xyz(source(),target()) ? source() : target();
}
template < class R_ >
CGAL_KERNEL_INLINE
typename cpp11::result_of<typename R_::Construct_max_vertex_3( Segment_3<R_> ) >::type
Segment_3<R_>::max BOOST_PREVENT_MACRO_SUBSTITUTION () const
{
typename R_::Less_xyz_3 less_xyz;
return less_xyz(source(),target()) ? target() : source();
}
template < class R_ >
CGAL_KERNEL_INLINE
typename cpp11::result_of<typename R_::Construct_vertex_3( Segment_3<R_>, int ) >::type
Segment_3<R_>::vertex(int i) const
{
return (i%2 == 0) ? source() : target();
}
template < class R >
std::ostream &

View File

@ -86,7 +86,7 @@ public:
Sphere_3 orthogonal_transform(const Aff_transformation_3 &t) const;
typename cpp11::result_of<typename R::Construct_center_3( Sphere_3)>::type
decltype(auto)
center() const
{
return R().construct_center_3_object()(*this);

View File

@ -70,13 +70,13 @@ public:
t.transform(this->vertex(3)));
}
typename cpp11::result_of<typename R::Construct_vertex_3( Tetrahedron_3, int)>::type
decltype(auto)
vertex(int i) const
{
return R().construct_vertex_3_object()(*this,i);
}
typename cpp11::result_of<typename R::Construct_vertex_3( Tetrahedron_3, int)>::type
decltype(auto)
operator[](int i) const
{
return vertex(i);
@ -128,7 +128,7 @@ public:
return R().has_on_unbounded_side_3_object()(*this, p);
}
typename cpp11::result_of<typename R::Compute_volume_3( Tetrahedron_3)>::type
decltype(auto)
volume() const
{
return R().compute_volume_3_object()(*this);

View File

@ -22,7 +22,6 @@
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Bbox_2.h>
#include <CGAL/Dimension.h>
#include <CGAL/result_of.h>
#include <CGAL/IO/io.h>
namespace CGAL {
@ -101,13 +100,13 @@ public:
return !(*this == t);
}
typename cpp11::result_of<typename R::Construct_vertex_2( Triangle_2, int)>::type
decltype(auto)
vertex(int i) const
{
return R().construct_vertex_2_object()(*this,i);
}
typename cpp11::result_of<typename R::Construct_vertex_2( Triangle_2, int)>::type
decltype(auto)
operator[](int i) const
{
return vertex(i);

View File

@ -82,13 +82,13 @@ public:
}
typename cpp11::result_of<typename R::Construct_vertex_3( Triangle_3, int )>::type
decltype(auto)
vertex(int i) const
{
return R().construct_vertex_3_object()(*this, i);
}
typename cpp11::result_of<typename R::Construct_vertex_3( Triangle_3, int )>::type
decltype(auto)
operator[](int i) const
{
return vertex(i);

View File

@ -25,7 +25,6 @@
#include <CGAL/kernel_assertions.h>
#include <CGAL/representation_tags.h>
#include <CGAL/Dimension.h>
#include <CGAL/result_of.h>
#include <CGAL/IO/io.h>
namespace CGAL {
@ -103,26 +102,26 @@ public:
}
typename cpp11::result_of<typename R::Compute_x_2(Vector_2)>::type
decltype(auto)
x() const
{
return R().compute_x_2_object()(*this);
}
typename cpp11::result_of<typename R::Compute_y_2(Vector_2)>::type
decltype(auto)
y() const
{
return R().compute_y_2_object()(*this);
}
typename cpp11::result_of<typename R::Compute_y_2(Vector_2)>::type
decltype(auto)
cartesian(int i) const
{
CGAL_kernel_precondition( (i == 0) || (i == 1) );
return (i==0) ? x() : y();
}
typename cpp11::result_of<typename R::Compute_x_2(Vector_2)>::type
decltype(auto)
operator[](int i) const
{
return cartesian(i);
@ -138,26 +137,26 @@ public:
return typename R::Construct_cartesian_const_iterator_2()(*this,2);
}
typename cpp11::result_of<typename R::Compute_hx_2(Vector_2)>::type
decltype(auto)
hx() const
{
return R().compute_hx_2_object()(*this);
}
typename cpp11::result_of<typename R::Compute_hy_2(Vector_2)>::type
decltype(auto)
hy() const
{
return R().compute_hy_2_object()(*this);
}
typename cpp11::result_of<typename R::Compute_hw_2(Vector_2)>::type
decltype(auto)
hw() const
{
return R().compute_hw_2_object()(*this);
}
typename cpp11::result_of<typename R::Compute_hx_2(Vector_2)>::type
decltype(auto)
homogeneous(int i) const
{
CGAL_kernel_precondition( (i >= 0) || (i <= 2) );

View File

@ -25,7 +25,6 @@
#include <boost/type_traits/is_same.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Dimension.h>
#include <CGAL/result_of.h>
#include <CGAL/IO/io.h>
namespace CGAL {
@ -173,49 +172,49 @@ public:
return *this;
}
typename cpp11::result_of<typename R::Compute_x_3(Vector_3)>::type
decltype(auto)
x() const
{
return R().compute_x_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_y_3(Vector_3)>::type
decltype(auto)
y() const
{
return R().compute_y_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_z_3(Vector_3)>::type
decltype(auto)
z() const
{
return R().compute_z_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_hx_3(Vector_3)>::type
decltype(auto)
hx() const
{
return R().compute_hx_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_hy_3(Vector_3)>::type
decltype(auto)
hy() const
{
return R().compute_hy_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_hz_3(Vector_3)>::type
decltype(auto)
hz() const
{
return R().compute_hz_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_hw_3(Vector_3)>::type
decltype(auto)
hw() const
{
return R().compute_hw_3_object()(*this);
}
typename cpp11::result_of<typename R::Compute_x_3(Vector_3)>::type
decltype(auto)
cartesian(int i) const
{
CGAL_kernel_precondition( (i == 0) || (i == 1) || (i == 2) );
@ -224,7 +223,7 @@ public:
return z();
}
typename cpp11::result_of<typename R::Compute_hw_3(Vector_3)>::type
decltype(auto)
homogeneous(int i) const
{
CGAL_kernel_precondition( (i >= 0) || (i <= 3) );
@ -239,7 +238,7 @@ public:
return 3;
}
typename cpp11::result_of<typename R::Compute_x_3(Vector_3)>::type
decltype(auto)
operator[](int i) const
{
return cartesian(i);
@ -255,7 +254,7 @@ public:
return typename R::Construct_cartesian_const_iterator_3()(*this,3);
}
typename cpp11::result_of<typename R::Compute_squared_length_3(Vector_3)>::type
decltype(auto)
squared_length() const
{
return R().compute_squared_length_3_object()(*this);

View File

@ -24,7 +24,6 @@
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Bbox_2.h>
#include <CGAL/Dimension.h>
#include <CGAL/result_of.h>
#include <CGAL/Point_2.h>
namespace CGAL {
@ -83,50 +82,50 @@ public:
: Rep(typename R::Construct_weighted_point_2()(Return_base_tag(), x, y))
{}
typename cpp11::result_of<typename R::Construct_point_2( Weighted_point_2)>::type
decltype(auto)
point() const
{
return typename R::Construct_point_2()(*this);
}
typename cpp11::result_of<typename R::Compute_weight_2( Weighted_point_2)>::type
decltype(auto)
weight() const
{
return typename R::Compute_weight_2()(*this);
}
typename cpp11::result_of<typename R::Compute_x_2( Point_2)>::type
decltype(auto)
x() const
{
return typename R::Compute_x_2()(point());
}
typename cpp11::result_of<typename R::Compute_y_2( Point_2)>::type
decltype(auto)
y() const
{
return typename R::Compute_y_2()(point());
}
typename cpp11::result_of<typename R::Compute_hx_2( Point_2)>::type
decltype(auto)
hx() const
{
return R().compute_hx_2_object()(point());
}
typename cpp11::result_of<typename R::Compute_hy_2( Point_2)>::type
decltype(auto)
hy() const
{
return R().compute_hy_2_object()(point());
}
typename cpp11::result_of<typename R::Compute_hw_2( Point_2)>::type
decltype(auto)
hw() const
{
return R().compute_hw_2_object()(point());
}
typename cpp11::result_of<typename R::Compute_x_2( Point_2)>::type
decltype(auto)
cartesian(int i) const
{
CGAL_kernel_precondition( (i == 0) || (i == 1) );
@ -143,7 +142,7 @@ public:
return hw();
}
typename cpp11::result_of<typename R::Compute_x_2(Point_2)>::type
decltype(auto)
operator[](int i) const
{
return cartesian(i);

View File

@ -84,62 +84,62 @@ public:
: Rep(typename R::Construct_weighted_point_3()(Return_base_tag(), x, y, z))
{}
typename cpp11::result_of<typename R::Construct_point_3(Weighted_point_3)>::type
decltype(auto)
point() const
{
return typename R::Construct_point_3()(*this);
}
typename cpp11::result_of<typename R::Compute_weight_3(Weighted_point_3)>::type
decltype(auto)
weight() const
{
return typename R::Compute_weight_3()(*this);
}
typename cpp11::result_of<typename R::Compute_x_3(Point_3)>::type
decltype(auto)
x() const
{
return typename R::Compute_x_3()(point());
}
typename cpp11::result_of<typename R::Compute_y_3(Point_3)>::type
decltype(auto)
y() const
{
return typename R::Compute_y_3()(point());
}
typename cpp11::result_of<typename R::Compute_z_3(Point_3)>::type
decltype(auto)
z() const
{
return typename R::Compute_z_3()(point());
}
typename cpp11::result_of<typename R::Compute_hx_3(Point_3)>::type
decltype(auto)
hx() const
{
return R().compute_hx_3_object()(point());
}
typename cpp11::result_of<typename R::Compute_hy_3(Point_3)>::type
decltype(auto)
hy() const
{
return R().compute_hy_3_object()(point());
}
typename cpp11::result_of<typename R::Compute_hz_3(Point_3)>::type
decltype(auto)
hz() const
{
return R().compute_hz_3_object()(point());
}
typename cpp11::result_of<typename R::Compute_hw_3(Point_3)>::type
decltype(auto)
hw() const
{
return R().compute_hw_3_object()(point());
}
typename cpp11::result_of<typename R::Compute_x_3(Point_3)>::type
decltype(auto)
cartesian(int i) const
{
CGAL_kernel_precondition( (i == 0) || (i == 1) || (i == 2) );
@ -158,7 +158,7 @@ public:
return hw();
}
typename cpp11::result_of<typename R::Compute_x_3(Point_3)>::type
decltype(auto)
operator[](int i) const
{
return cartesian(i);

View File

@ -23,11 +23,6 @@
#include <iostream>
#include <cstdlib>
// This cannot be disabled for now until we have a clear idea which
// compilers implement N3276.
#include <CGAL/result_of.h>
#include <CGAL/assertions.h>
#include <CGAL/tags.h>
#include <CGAL/number_type_basic.h>

View File

@ -327,8 +327,7 @@ public:
//compute intersection points in projected plane
//We know that none of the segment is degenerate
typename CGAL::cpp11::result_of<typename R::Intersect_2(Segment_2, Segment_2)>::type
o = intersection(s1_2,s2_2);
auto o = intersection(s1_2,s2_2);
if(! o){
return boost::none;
}

View File

@ -17,8 +17,7 @@ template <class K1, class K2, class T1, class T2>
void test_2d(const T1& t1, const T2& t2)
{
CGAL::Cartesian_converter<K1,K2> convert;
typename CGAL::cpp11::result_of<typename K1::Intersect_2(T1, T2)>::type res1 =
CGAL::intersection(t1, t2);
const auto res1 = CGAL::intersection(t1, t2);
assert( is_intersection_empty( convert(res1) ) == is_intersection_empty(res1) );
}
@ -26,8 +25,7 @@ template <class K1, class K2, class T1, class T2>
void test_3d(const T1& t1, const T2& t2)
{
CGAL::Cartesian_converter<K1,K2> convert;
typename CGAL::cpp11::result_of<typename K1::Intersect_3(T1, T2)>::type res1 =
CGAL::intersection(t1, t2);
const auto res1 = CGAL::intersection(t1, t2);
assert( is_intersection_empty( convert(res1) ) == is_intersection_empty(res1) );
}
@ -112,7 +110,6 @@ void test_linear_intersections()
test_3d<K1,K2>(triangle_3, triangle_3);
CGAL::Cartesian_converter<K1,K2> convert;
typename CGAL::cpp11::result_of<typename K1::Intersect_3(Plane_3, Plane_3, Plane_3)>::type res1 =
CGAL::intersection(plane_3, plane_3, plane_3);
const auto res1 = CGAL::intersection(plane_3, plane_3, plane_3);
assert( is_intersection_empty( convert(res1) ) == is_intersection_empty(res1) );
}

View File

@ -34,14 +34,16 @@ The same functionality is also available through the functor `Kernel::Intersect_
The following table gives the possible values for `Type1` and `Type2`.
The return type can be obtained through `cpp11::result_of<Kernel::Intersect_d(A, B)>::%type`.
It is equivalent to `boost::optional< boost::variant< T... > >`, the last column in the table providing the template parameter pack.
The return type of intersecting two objects of the types `Type1` and `Type2` can be
specified through the placeholder type specifier `auto`. It is equivalent to
`boost::optional< boost::variant< T... > >`, the last column in the table providing
the template parameter pack.
<DIV ALIGN="CENTER">
<TABLE CELLPADDING=3 BORDER="1">
<TR> <TH> Type1 </TH>
<TR>
<TH> Type1 </TH>
<TH> Type2 </TH>
<TH> `T...` </TH>
</TR>
@ -143,13 +145,8 @@ struct Intersection_visitor {
template <class R>
void foo(Segment_d<R> seg, Line_d<R> lin)
{
// with C++11 support
// auto result = intersection(seg, lin);
// without C++11 support
typename cpp11::result_of<R::Intersect_d(Segment_d<R>, Line_d<R>)>::type
result = intersection(seg, lin);
// use auto
auto result = intersection(seg, lin);
if(result) { boost::apply_visitor(Intersection_visitor<R>(), *result); }
else { // no intersection
}
@ -160,10 +157,10 @@ void foo(Segment_d<R> seg, Line_d<R> lin)
\sa `Kernel_d::Intersect_d`
\sa <a HREF="https://www.boost.org/doc/libs/release/libs/optional/index.html">`boost::optional`</a>
\sa <a HREF="https://www.boost.org/doc/html/variant.html">`boost::variant`</a>
\sa `cpp11::result_of`
*/
cpp11::result_of<R::Intersect_d(Type1<R>, Type2<R>)>::type intersection(Type1<R> f1, Type2<R> f2);
decltype(auto)
intersection(Type1<R> f1, Type2<R> f2);
} /* namespace CGAL */

View File

@ -23,7 +23,7 @@ For a list of the possible return types, see `CGAL::intersection()`.
\pre `p` and `q` have the same dimension.
*/
template <class Type1, class Type2>
cpp11::result_of<Kernel::Intersect_d(Type1, Type2)>::type
decltype(auto)
operator()(const Type1& p, const Type2& q);
/// @}

View File

@ -480,17 +480,14 @@ that are part of flats (`R::Segment_d`, `R::Ray_d`,
returns a `boost::optional< boost::variant< T... > >`
where `T...` is a list of all possible resulting geometric objects.
The exact result type of an intersection can be determined by using
`cpp11::result_of<Kernel::Intersect_d(Type1, Type2)>::%type`
where `Type1` and `Type2` are the types of the objects
used in the intersection computation.
The return type of intersecting two objects of the types `Type1` and `Type2` can be
specified through the placeholder type specifier `auto`.
\subsubsection Kernel_dExample Example
In the following example, the object type is used as a return value for
the intersection computation, as there are
possibly different return values.
In the following example, the `auto` is used for the intersection computation,
as there are possibly different return values.
\code{.cpp}
typedef Cartesian_d<double> K;
@ -500,9 +497,9 @@ typedef Segment_d<K> Segment;
Segment s1, s2;
std::cin >> s1 >> s2;
cpp11::result_of<K::Intersect_d(Segment, Segment)>::type
v = intersection(s1, s2);
if(v) {
// use auto
auto v = intersection(s1, s2);
if (v) {
// not empty
if (const Point *p = boost::get<Point>(&*v) ) {
// do something with *p

View File

@ -25,7 +25,7 @@ namespace Intersections {
namespace internal {
template <class R>
typename cpp11::result_of<typename R::Intersect_d(typename R::Line_d, typename R::Line_d)>::type
decltype(auto)
intersection(const typename R::Line_d& l1, const typename R::Line_d& l2, const R&)
{
typedef typename R::Line_d_Line_d_pair ll_pair;
@ -46,7 +46,7 @@ intersection(const typename R::Line_d& l1, const typename R::Line_d& l2, const R
}
template <class R>
typename cpp11::result_of<typename R::Intersect_d(typename R::Ray_d, typename R::Ray_d)>::type
decltype(auto)
intersection(const typename R::Ray_d& l1, const typename R::Ray_d& l2, const R&)
{
typedef typename R::Ray_d_Ray_d_pair ll_pair;
@ -75,7 +75,7 @@ intersection(const typename R::Ray_d& l1, const typename R::Ray_d& l2, const R&)
}
template <class R>
typename cpp11::result_of<typename R::Intersect_d(typename R::Segment_d, typename R::Segment_d)>::type
decltype(auto)
intersection(const typename R::Segment_d& l1, const typename R::Segment_d& l2, const R&)
{
typedef typename R::Segment_d_Segment_d_pair ll_pair;
@ -99,7 +99,7 @@ intersection(const typename R::Segment_d& l1, const typename R::Segment_d& l2, c
}
template <class R>
typename cpp11::result_of<typename R::Intersect_d(typename R::Line_d, typename R::Ray_d)>::type
decltype(auto)
intersection(const typename R::Line_d& l, const typename R::Ray_d& r, const R&)
{
typedef typename R::Line_d_Ray_d_pair lr_pair;
@ -121,12 +121,12 @@ intersection(const typename R::Line_d& l, const typename R::Ray_d& r, const R&)
}
template <class R>
typename cpp11::result_of<typename R::Intersect_d(typename R::Ray_d, typename R::Line_d)>::type
decltype(auto)
intersection(const typename R::Ray_d& r, const typename R::Line_d& l, const R& k)
{ return intersection(l,r,k); }
template <class R>
typename cpp11::result_of<typename R::Intersect_d(typename R::Ray_d, typename R::Segment_d)>::type
decltype(auto)
intersection(const typename R::Ray_d& r, const typename R::Segment_d& s, const R&)
{
typedef typename R::Ray_d_Segment_d_pair rs_pair;
@ -150,12 +150,12 @@ intersection(const typename R::Ray_d& r, const typename R::Segment_d& s, const R
}
template <class R>
typename cpp11::result_of<typename R::Intersect_d(typename R::Segment_d, typename R::Ray_d)>::type
decltype(auto)
intersection(const typename R::Segment_d& s, const typename R::Ray_d& r, const R& k)
{ return intersection(r,s, k); }
template <class R>
typename cpp11::result_of<typename R::Intersect_d(typename R::Line_d, typename R::Segment_d)>::type
decltype(auto)
intersection(const typename R::Line_d& l, const typename R::Segment_d& s, const R&)
{
typedef typename R::Line_d_Segment_d_pair rs_pair;
@ -179,12 +179,12 @@ intersection(const typename R::Line_d& l, const typename R::Segment_d& s, const
}
template <class R>
typename cpp11::result_of<typename R::Intersect_d(typename R::Segment_d, typename R::Line_d)>::type
decltype(auto)
intersection(const typename R::Segment_d& s, const typename R::Line_d& l, const R& r)
{ return intersection(l,s,r); }
template <class R>
typename cpp11::result_of<typename R::Intersect_d(typename R::Line_d, typename R::Hyperplane_d)>::type
decltype(auto)
intersection(const typename R::Line_d& l, const typename R::Hyperplane_d& h, const R&)
{
typedef typename R::Line_d_Hyperplane_d_pair lh_pair;
@ -205,12 +205,12 @@ intersection(const typename R::Line_d& l, const typename R::Hyperplane_d& h, con
}
template <class R>
typename cpp11::result_of<typename R::Intersect_d(typename R::Hyperplane_d, typename R::Line_d)>::type
decltype(auto)
intersection(const typename R::Hyperplane_d& h, const typename R::Line_d& l, const R& r)
{ return intersection(l,h,r); }
template <class R>
typename cpp11::result_of<typename R::Intersect_d(typename R::Ray_d, typename R::Hyperplane_d)>::type
decltype(auto)
intersection(const typename R::Ray_d& r, const typename R::Hyperplane_d& h, const R&)
{
typedef typename R::Ray_d_Hyperplane_d_pair rh_pair;
@ -231,12 +231,12 @@ intersection(const typename R::Ray_d& r, const typename R::Hyperplane_d& h, cons
}
template <class R>
typename cpp11::result_of<typename R::Intersect_d(typename R::Hyperplane_d, typename R::Ray_d)>::type
decltype(auto)
intersection(const typename R::Hyperplane_d& h, const typename R::Ray_d& r, const R& k)
{ return intersection(r,h,k); }
template <class R>
typename cpp11::result_of<typename R::Intersect_d(typename R::Segment_d, typename R::Hyperplane_d)>::type
decltype(auto)
intersection(const typename R::Segment_d& s, const typename R::Hyperplane_d& h, const R&)
{
typedef typename R::Segment_d_Hyperplane_d_pair sh_pair;
@ -258,7 +258,7 @@ intersection(const typename R::Segment_d& s, const typename R::Hyperplane_d& h,
}
template <class R>
typename cpp11::result_of<typename R::Intersect_d(typename R::Hyperplane_d, typename R::Segment_d)>::type
decltype(auto)
intersection(const typename R::Hyperplane_d& h, const typename R::Segment_d& s, const R& r)
{ return intersection(s,h,r); }

View File

@ -145,7 +145,6 @@
#include <boost/type_traits/remove_reference.hpp>
#include <boost/utility.hpp>
#include <boost/utility/enable_if.hpp>
#include <boost/utility/result_of.hpp>
#include <boost/variant.hpp>
#include <boost/version.hpp>

View File

@ -312,11 +312,11 @@ public:
/*!
A constructor object that must provide the function operators:
`CGAL::cpp11::result_of< Kernel::Intersect_3(Segment_3, Plane_3)>::%type operator()(Segment_3 s, Plane_3 p)`
`boost::optional< boost::variant< T... > > operator()(Segment_3 s, Plane_3 p)`
`CGAL::cpp11::result_of< Kernel::Intersect_3(Ray_3, Iso_cuboid_3)>::%type operator()(Ray_3 r, Iso_cuboid i)`
`boost::optional< boost::variant< T... > > operator()(Ray_3 r, Iso_cuboid i)`
`CGAL::cpp11::result_of< Kernel::Intersect_3(Segment_3, Iso_cuboid_3)>::%type operator()(Segment_3 s, Iso_cuboid i)`
`boost::optional< boost::variant< T... > > operator()(Segment_3 s, Iso_cuboid i)`
which returns the intersection region of two geometrical objects.
*/

View File

@ -31,7 +31,6 @@
#include <CGAL/tuple.h>
#include <CGAL/Origin.h>
#include <CGAL/result_of.h>
#include <functional>
#include <CGAL/internal/Mesh_3/Handle_IO_for_pair_of_int.h>
@ -590,9 +589,7 @@ public:
template<typename Query>
Surface_patch clip_to_segment(const Query& query) const
{
typename cpp11::result_of<typename BGT::Intersect_3(Query, Iso_cuboid_3)>::type
clipped = CGAL::intersection(query, r_domain_.bbox_);
const auto clipped = CGAL::intersection(query, r_domain_.bbox_);
if(clipped)
if(const Segment_3* s = boost::get<Segment_3>(&*clipped))
return this->operator()(*s);
@ -720,9 +717,7 @@ public:
template<typename Query>
Intersection clip_to_segment(const Query& query) const
{
typename cpp11::result_of<typename BGT::Intersect_3(Query, Iso_cuboid_3)>::type
clipped = CGAL::intersection(query, r_domain_.bbox_);
const auto clipped = CGAL::intersection(query, r_domain_.bbox_);
if(clipped)
if(const Segment_3* s = boost::get<Segment_3>(&*clipped))
return this->operator()(*s);

View File

@ -261,15 +261,16 @@ lp_intersection(const typename K::Point_3& p, const typename K::Point_3& q,
// returns a point or the empty Object. In case of degeneracy, the empty
// Object is returned as well.
template <class K>
typename cpp11::result_of<
typename K::Intersect_3(typename K::Segment_3, typename K::Triangle_3)>::type
decltype(auto)
ts_intersection(const typename K::Triangle_3 &t,
const typename K::Segment_3 &s,
const K & k)
{
typedef typename cpp11::result_of<
typename K::Intersect_3(typename K::Segment_3, typename K::Triangle_3)
>::type result_type;
// typedef decltype(
// std::declval<typename K::Intersect_3>()(
// std::declval<typename K::Segment_3>(),
// std::declval<typename K::Triangle_3>())) result_type;
typedef decltype(typename K::Intersect_3()(s, t)) result_type;
CGAL_MESH_3_BRANCH_PROFILER(std::string("coplanar/calls in : ") +
std::string(CGAL_PRETTY_FUNCTION), tmp);
@ -399,8 +400,7 @@ ts_intersection(const typename K::Triangle_3 &t,
template <class K>
typename cpp11::result_of<
typename K::Intersect_3(typename K::Ray_3, typename K::Triangle_3)>::type
decltype(auto)
tr_intersection(const typename K::Triangle_3 &t,
const typename K::Ray_3 &r,
const K& k)
@ -410,9 +410,11 @@ tr_intersection(const typename K::Triangle_3 &t,
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(t) ) ;
CGAL_kernel_precondition( ! k.is_degenerate_3_object()(r) ) ;
typedef typename cpp11::result_of<
typename K::Intersect_3(typename K::Ray_3, typename K::Triangle_3)
>::type result_type;
// typedef decltype(
// std::declval<typename K::Intersect_3>()(
// std::declval<typename K::Ray_3>(),
// std::declval<typename K::Triangle_3>())) result_type;
typedef decltype(typename K::Intersect_3()(r, t)) result_type;
typedef typename K::Point_3 Point_3;
@ -471,20 +473,12 @@ public:
typedef typename K_::Segment_3 Segment_3;
typedef typename K_::Ray_3 Ray_3;
template <typename>
struct result;
template <typename F, typename A, typename B>
struct result<F(A, B)> {
typedef typename cpp11::result_of<typename K_::Intersect_3(A, B)>::type type;
};
typedef Exact_predicates_exact_constructions_kernel EK;
typedef Cartesian_converter<typename K_::Kernel, EK> To_exact;
typedef Cartesian_converter<EK, typename K_::Kernel> Back_from_exact;
template<class T1, class T2>
typename cpp11::result_of<typename K_::Intersect_3(T1, T2)>::type
decltype(auto)
operator() (const T1& t, const T2& s) const
{
// Switch to exact
@ -493,28 +487,32 @@ public:
EK::Intersect_3 exact_intersection = EK().intersect_3_object();
// Cartesian converters have an undocumented, optional< variant > operator
return typename cpp11::result_of<typename K_::Intersect_3(T1, T2)>::type
(back_from_exact(exact_intersection(to_exact(t), to_exact(s))));
// typedef decltype(
// std::declval<typename K_::Intersect_3>()(
// std::declval<T1>(), std::declval<T2>())) result_type;
typedef decltype(typename K_::Intersect_3()(t, s)) result_type;
return result_type(back_from_exact(exact_intersection(to_exact(t), to_exact(s))));
}
typename cpp11::result_of<typename K_::Intersect_3(Segment_3, Triangle_3)>::type
decltype(auto)
operator()(const Segment_3& s, const Triangle_3& t) const
{
return ts_intersection(t, s, K_());
}
typename cpp11::result_of<typename K_::Intersect_3(Segment_3, Triangle_3)>::type
decltype(auto)
operator()(const Triangle_3& t, const Segment_3& s) const
{
return ts_intersection(t, s, K_());
}
typename cpp11::result_of<typename K_::Intersect_3(Ray_3, Triangle_3)>::type
decltype(auto)
operator()(const Ray_3& r, const Triangle_3& t) const {
return tr_intersection(t, r, K_());
}
typename cpp11::result_of<typename K_::Intersect_3(Ray_3, Triangle_3)>::type
decltype(auto)
operator()(const Triangle_3& t, const Ray_3& r) const
{
return tr_intersection(t, r, K_());
@ -531,20 +529,12 @@ public:
typedef typename K_::Triangle_3 Triangle_3;
typedef typename K_::Segment_3 Segment_3;
template <typename>
struct result;
template <typename F, typename A, typename B>
struct result<F(A, B)> {
typedef typename cpp11::result_of<typename K_::Intersect_3(A, B)>::type type;
};
typedef Exact_predicates_exact_constructions_kernel EK;
typedef Cartesian_converter<typename K_::Kernel, EK> To_exact;
typedef Cartesian_converter<EK, typename K_::Kernel> Back_from_exact;
template<class T1, class T2>
typename cpp11::result_of<typename K_::Intersect_3(T1, T2)>::type
decltype(auto)
operator() (const T1& t, const T2& s) const
{
// Switch to exact
@ -553,8 +543,12 @@ public:
EK::Intersect_3 exact_intersection = EK().intersect_3_object();
// Cartesian converters have an undocumented, optional< variant > operator
return typename cpp11::result_of<typename K_::Intersect_3(T1, T2)>::type
(back_from_exact(exact_intersection(to_exact(t), to_exact(s))));
// typedef decltype(
// std::declval<typename K_::Intersect_3>()(
// std::declval<T1>(), std::declval<T2>())) result_type;
typedef decltype(typename K_::Intersect_3()(t, s)) result_type;
return result_type(back_from_exact(exact_intersection(to_exact(t), to_exact(s))));
}
};

View File

@ -385,8 +385,6 @@ struct Sizing_field_with_aabb_tree
//Compute distance to the curve on which p lies
typedef typename GeomTraits::Segment_3 Segment_3;
typedef typename GeomTraits::Plane_3 Plane_3;
typedef typename CGAL::cpp11::result_of<
typename GeomTraits::Intersect_3(Segment_3, Plane_3)>::type Intersection_result;
const typename Input_curves_AABB_tree_::Point_and_primitive_id& ppid
= domain.curves_aabb_tree().closest_point_and_primitive(p);
@ -417,8 +415,7 @@ struct Sizing_field_with_aabb_tree
if (curve_id != prim.id().first->first)
continue;//don't deal with the same curves as what is done above
Intersection_result int_res
= CGAL::intersection(prim.datum(), curr_ortho_plane);
const auto int_res = CGAL::intersection(prim.datum(), curr_ortho_plane);
if (int_res)
{
if (const Point_3* pp = boost::get<Point_3>(&*int_res))

View File

@ -439,9 +439,7 @@ public:
if(r_domain_.query_is_cached(q))
{
const AABB_primitive_id primitive_id = r_domain_.cached_primitive_id();
typename cpp11::result_of<
typename IGT::Intersect_3(typename Primitive::Datum, Query)>::type o
= IGT().intersect_3_object()(Primitive(primitive_id).datum(),q);
const auto o = IGT().intersect_3_object()(Primitive(primitive_id).datum(),q);
intersection = o ?
Intersection_and_primitive_id(*o, primitive_id) :
AABB_intersection();

View File

@ -63,7 +63,7 @@ public:
typedef C2E To_exact_converter;
typedef C2A To_approximate_converter;
// FIXME: should use result_of, see emails by Nico
// FIXME: should use result_of or decltype(auto), see emails by Nico
typedef typename EP::result_type result_type;
// AP::result_type must be convertible to EP::result_type.

View File

@ -134,7 +134,7 @@ typename typeset_intersection<typename K1::Object_list, typename K2::Object_list
KernelD_converter(){}
KernelD_converter(K1 const&a,K2 const&b):Store_kernel<K1>(a),Store_kernel2<K2>(b){}
// For boost::result_of, used in transforming_iterator
// For the (not anymore used in CGAL) boost result of, used in transforming_iterator
template<class T,int i=is_iterator<T>::value?42:0> struct result:Base::template result<T>{};
template<class T> struct result<Final_(T),42> {
typedef transforming_iterator<Final_,T> type;

View File

@ -127,15 +127,15 @@ template <class Base_> struct Kernel_d_interface : public Base_ {
typedef typename Get_functor<Base, Construct_ttag<Point_cartesian_const_iterator_tag> >::type CPI;
typedef typename Get_functor<Base, Construct_ttag<Vector_cartesian_const_iterator_tag> >::type CVI;
// FIXME: The following sometimes breaks compilation. The typedef below forces instantiation of this, which forces Point_d, which itself (in the wrapper) needs the derived kernel to tell it what the base kernel is, and that's a cycle. The exact circumstances are not clear, g++ and clang++ are ok in both C++03 and C++11, it is only clang in C++11 without CGAL_CXX11 that breaks. Relying on CPI::result_type is great for Epick_d but not Epeck_d.
//typedef typename CGAL::decay<typename boost::result_of<CPI(Point_d,CGAL::Begin_tag)>::type>::type result_type;
//typedef typename CGAL::decay<typename CPI::result_type>::type result_type;
//typedef decltype(std::declval<CPI>()(std::declval<Point_d>(),Begin_tag{})) result_type;
// typedef typename CGAL::decay<typename boost::result_of<CPI(Point_d,CGAL::Begin_tag)>::type>::type result_type;
// typedef typename CGAL::decay<typename CPI::result_type>::type result_type;
// typedef decltype(std::declval<CPI>()(std::declval<Point_d>(),Begin_tag{})) result_type;
// HACK
typedef typename Base::Point_cartesian_const_iterator result_type;
// Kernel_d requires a common iterator type for points and vectors
// TODO: provide this mixed functor in preKernel?
//CGAL_static_assertion((boost::is_same<typename CGAL::decay<typename boost::result_of<CVI(Vector_d,CGAL::Begin_tag)>::type>::type, result_type>::value));
//CGAL_static_assertion((boost::is_same<typename CGAL::decay<typename CVI::result_type>::type, result_type>::value));
// CGAL_static_assertion((boost::is_same<typename CGAL::decay<typename boost::result_of<CVI(Vector_d,CGAL::Begin_tag)>::type>::type, result_type>::value));
// CGAL_static_assertion((boost::is_same<typename CGAL::decay<typename CVI::result_type>::type, result_type>::value));
template <class Tag_>
auto operator()(Point_d const&p, Tag_ t)const{
return CPI(this->kernel())(p,t);

View File

@ -49,7 +49,7 @@ public:
typedef Dimension_tag<0> Feature_dimension;
typedef typename Get_type<Kbase, Point_tag>::type Rep;
//typedef typename CGAL::decay<typename boost::result_of<CPI(Rep,Begin_tag)>::type>::type Cartesian_const_iterator;
// typedef typename CGAL::decay<typename boost::result_of<CPI(Rep,Begin_tag)>::type>::type Cartesian_const_iterator;
const Rep& rep() const noexcept
{

View File

@ -22,7 +22,6 @@
#include <boost/type_traits.hpp>
#include <CGAL/Kernel/Return_base_tag.h>
#include <CGAL/Dimension.h>
#include <boost/utility/result_of.hpp>
namespace CGAL {
namespace Wrap {

View File

@ -787,8 +787,7 @@ public:
pt, geom_traits().construct_vector_2_object()(pt, ps));
boost::optional<FT> Dqt;
typename CGAL::cpp11::result_of<typename Traits_::Intersect_2(Line, Line)>::type
result = intersection(lab, lts);
const auto result = intersection(lab, lts);
if (result)
{
const Point* iq = boost::get<Point>(&(*result));

View File

@ -497,7 +497,7 @@ public:
// Spatial sorting can only be applied to bare points, so we need an adaptor
typedef typename Geom_traits::Construct_point_3 Construct_point_3;
typedef typename boost::result_of<const Construct_point_3(const Weighted_point&)>::type Ret;
typedef decltype(std::declval<const Construct_point_3>()(std::declval<const Weighted_point&>())) Ret;
typedef boost::function_property_map<Construct_point_3, Weighted_point, Ret> fpmap;
typedef CGAL::Spatial_sort_traits_adapter_3<Geom_traits, fpmap> Search_traits_3;

View File

@ -47,7 +47,6 @@
#include <boost/random/uniform_smallint.hpp>
#include <boost/random/variate_generator.hpp>
#include <boost/tuple/tuple.hpp>
#include <boost/utility/result_of.hpp>
#include <boost/unordered_map.hpp>
#include <iostream>
@ -650,7 +649,7 @@ public:
// but point() -like functions have return type Point
template<typename P> // can be Point or Point_3
typename boost::result_of<const typename GT::Construct_point_3(const P&)>::type
decltype(auto)
construct_point(const P& p) const {
return geom_traits().construct_point_3_object()(p);
}

View File

@ -800,9 +800,7 @@ private:
double angle_A = std::acos (CGAL::abs (plane1.orthogonal_vector() * plane2.orthogonal_vector()));
double angle_B = CGAL_PI - angle_A;
typename cpp11::result_of<typename Kernel::Intersect_3(Plane, Plane)>::type
result = CGAL::intersection(plane1, plane2);
const auto result = CGAL::intersection(plane1, plane2);
if (!result)
{
#ifdef CGAL_PSP3_VERBOSE
@ -1029,8 +1027,7 @@ private:
pts2.push_back (m_points[inde]);
}
typename cpp11::result_of<typename Kernel::Intersect_3(Plane, Plane)>::type
result = CGAL::intersection (plane1, ortho);
auto result = CGAL::intersection (plane1, ortho);
if (result)
{
if (const Line* l = boost::get<Line>(&*result))
@ -1194,16 +1191,12 @@ private:
const Plane& plane2 = m_planes[m_corners[i].planes[1]];
const Plane& plane3 = m_planes[m_corners[i].planes[2]];
typename cpp11::result_of<typename Kernel::Intersect_3(Plane, Plane)>::type
result = CGAL::intersection(plane1, plane2);
const auto result = CGAL::intersection(plane1, plane2);
if (result)
{
if (const Line* l = boost::get<Line>(&*result))
{
typename cpp11::result_of<typename Kernel::Intersect_3(Line, Plane)>::type
result2 = CGAL::intersection(*l, plane3);
const auto result2 = CGAL::intersection(*l, plane3);
if (result2)
{
if (const Point* p = boost::get<Point>(&*result2))

View File

@ -263,9 +263,7 @@ public:
p3(to_exact( get(vpm, source(h3,tm)) ),
to_exact( get(vpm, target(h3,tm)) ),
to_exact( get(vpm, target(next(h3,tm),tm))));
typename cpp11::result_of<
Exact_kernel::Intersect_3(Plane_3, Plane_3, Plane_3)
>::type inter_res = exact_intersection(p1, p2, p3);
const auto inter_res = exact_intersection(p1, p2, p3);
CGAL_assertion(inter_res != boost::none);
const Exact_kernel::Point_3* pt =
@ -389,9 +387,7 @@ public:
p3(get(vpm, source(h3,tm)),
get(vpm, target(h3,tm)),
get(vpm, target(next(h3,tm),tm)));
typename cpp11::result_of<
typename Exact_kernel::Intersect_3(Plane_3, Plane_3, Plane_3)
>::type inter_res = intersection(p1, p2, p3);
const auto inter_res = intersection(p1, p2, p3);
CGAL_assertion(inter_res != boost::none);
const Point_3* pt =

View File

@ -83,12 +83,7 @@ bool sorted_around_edge(
|| coplanar_orientation(o,o_prime,p2,q)==NEGATIVE );
typename Kernel::Orientation_3 orientation;
typedef typename Kernel::Point_3 Point_3;
typedef typename cpp11::result_of<
typename Kernel::Orientation_3(Point_3, Point_3, Point_3, Point_3)>::type
Orientation;
Orientation s0 = orientation(o_prime, o, p1, p2);
const auto s0 = orientation(o_prime, o, p1, p2);
if ( s0==COPLANAR ) {
//o, o_prime, p1 and p2 are coplanar
@ -98,8 +93,8 @@ bool sorted_around_edge(
}
//o, o_prime, p1 and p2 are not coplanar
Orientation s1 = orientation(o_prime, o, p1, q);
Orientation s2 = orientation(o_prime, o, q , p2);
const auto s1 = orientation(o_prime, o, p1, q);
const auto s2 = orientation(o_prime, o, q , p2);
if (s0 == POSITIVE) // the angle p1,o,p2 is smaller that Pi.
return ( s1 == POSITIVE )

View File

@ -276,8 +276,7 @@ class Polygon_mesh_slicer
get(m_vpmap, source(ed, m_tmesh)),
get(m_vpmap,target(ed, m_tmesh))
);
typename cpp11::result_of<typename Traits_::Intersect_3(Plane_3, Segment_3)>::type
inter = intersect_3(m_plane, s);
const auto inter = intersect_3(m_plane, s);
CGAL_assertion(inter != boost::none);
const Point_3* pt_ptr = boost::get<Point_3>(&(*inter));
current_poly.push_back( *pt_ptr );

View File

@ -3,16 +3,18 @@ namespace cpp11 {
/*!
\ingroup PkgSTLExtensionRef
Alias to the tr1 implementation from boost of the `result_of` mechanism.
When all compilers supported by %CGAL will have a Standard compliant implemention of the
the \cpp11 `decltype` feature, it will become an alias to <code>std::result_of</code>.
Alias to the implementation of the `std::result_of` mechanism. When all compilers
supported by \cgal have a Standard compliant implemention of the `std::invoke_result`
mechanism, it will become an alias to the <code>std::invoke_result</code>.
\sa <a href=https://www.boost.org/libs/utility/utility.htm#result_of><code>boost::result_of</code></a>
\sa <a href=https://en.cppreference.com/w/cpp/types/result_of><code>std::result_of</code></a>
*/
template <typename F>
struct result_of{
/// starting from boost version 1.44, it is `boost::tr1_result_of<F>::%type`, and
/// `boost::result_of<F>::%type` otherwise.
struct result_of {
/*!
It is a type `std::result_of<F>::%type`.
*/
typedef unspecified_type type;
};

View File

@ -24,7 +24,6 @@
#include <CGAL/assertions.h>
#include <CGAL/circulator.h>
#include <CGAL/Iterator_range.h>
#include <CGAL/result_of.h>
#include <CGAL/tuple.h>
#include <CGAL/use.h>
@ -660,7 +659,8 @@ class Join_input_iterator_1
public:
typedef typename std::iterator_traits<I1>::iterator_category iterator_category;
typedef std::decay_t<typename cpp11::result_of<Op(arg_type)>::type> value_type;
typedef std::decay_t<decltype(std::declval<Op>()(std::declval<arg_type>()))>
value_type;
typedef typename std::iterator_traits<I1>::difference_type difference_type;
typedef value_type const* pointer;
typedef value_type const& reference;
@ -746,7 +746,8 @@ class Join_input_iterator_2
public:
typedef typename std::iterator_traits<I1>::iterator_category iterator_category;
typedef typename cpp11::result_of<Op(arg_type_1, arg_type_2)>::type value_type;
typedef decltype(std::declval<Op>()(std::declval<arg_type_1>(), std::declval<arg_type_2>()))
value_type;
typedef typename std::iterator_traits<I1>::difference_type difference_type;
typedef value_type* pointer;
typedef value_type& reference;
@ -840,7 +841,7 @@ class Join_input_iterator_3
public:
typedef typename std::iterator_traits<I1>::iterator_category iterator_category;
typedef typename cpp11::result_of<Op(arg_type_1, arg_type_2, arg_type_3)>::type
typedef decltype(std::declval<Op>()(std::declval<arg_type_1>(), std::declval<arg_type_2>(), std::declval<arg_type_3>()))
value_type;
typedef typename std::iterator_traits<I1>::difference_type difference_type;
typedef value_type* pointer;

View File

@ -21,42 +21,53 @@
#include <CGAL/config.h>
#include <CGAL/disable_warnings.h>
// Address the warning C4003: not enough actual parameters for macro 'BOOST_PP_SEQ_DETAIL_IS_NOT_EMPTY'
// result_of.hpp includes files from boost/preprocessor
// This concerns boost 1_65_1
#if defined(BOOST_MSVC)
# pragma warning(push)
# pragma warning(disable: 4003)
#endif
#include <boost/utility/result_of.hpp>
#if defined(BOOST_MSVC)
# pragma warning(pop)
#endif
#if CGAL_CXX20 || __cpp_lib_is_invocable>=201703L
#include <boost/version.hpp>
// C++>=17
namespace CGAL{
#elif CGAL_CXX11
// Even if for now we use the tr1 result_of implementation, we use the cpp11
// namespace since in the future, that's the decltype version that will be used
namespace cpp11{
#include <type_traits>
template<typename F>
struct result_of
{
// from boost 1.44 release note https://www.boost.org/users/history/version_1_44_0.html :
// New template boost::tr1_result_of that implements the TR1 ResultOf protocol even if boost::result_of uses the C++0x decltype-based implementation.
#if BOOST_VERSION < 104400
typedef typename boost::result_of<F>::type type;
#else
typedef typename boost::tr1_result_of<F>::type type;
#else // C++<11
// Address the warning C4003: not enough actual parameters for macro 'BOOST_PP_SEQ_DETAIL_IS_NOT_EMPTY'
// result_of.hpp includes files from boost/preprocessor
// This concerns boost 1_65_1
#if defined(BOOST_MSVC)
#pragma warning(push)
#pragma warning(disable: 4003)
#endif
};
#include <boost/utility/result_of.hpp>
#if defined(BOOST_MSVC)
#pragma warning(pop)
#endif
#include <boost/version.hpp>
}
#endif // end C++<11
}
namespace CGAL {
namespace cpp11 {
#if CGAL_CXX20 || __cpp_lib_is_invocable>=201703L
template<typename Signature> class result_of;
template<typename F, typename... Args>
class result_of<F(Args...)> : public std::invoke_result<F, Args...> { };
#elif CGAL_CXX11
using std::result_of;
#else // C++<11
using boost::result_of;
#endif // end C++<11
} // end cpp11
} // end CGAL
#include <CGAL/enable_warnings.h>
#endif //CGAL_RESULT_OF_H
#endif // CGAL_RESULT_OF_H

View File

@ -12,7 +12,6 @@
#ifndef CGAL_TRANSFORMING_ITERATOR_H
#define CGAL_TRANSFORMING_ITERATOR_H
#include <boost/iterator/iterator_adaptor.hpp>
#include <boost/utility/result_of.hpp>
#include <boost/type_traits/is_empty.hpp>
#include <boost/type_traits/is_reference.hpp>
#include <boost/type_traits/is_integral.hpp>

View File

@ -152,7 +152,7 @@ public:
/*!
Function object type.
Must provide
`CGAL::cpp11::result_of<Intersect_2(A,B)>::%type operator()(A obj1, B obj2)`
`boost::optional< boost::variant< T... > > operator()(A obj1, B obj2)`
to compute the intersection between `obj1` and `obj2`, where `A` and `B` can be any type amongst
`Line_2`, `Ray_2`, `Segment_2`.
*/

View File

@ -977,8 +977,6 @@ private:
typename Traits::Construct_point_on_2 cpo2(m_traits.construct_point_on_2_object());
typename Traits::Compute_parametric_distance_along_segment_2 pdas2(m_traits.compute_parametric_distance_along_segment_2_object());
typedef typename cpp11::result_of<typename Traits::Intersect_2(Line_2, Line_2)>::type LineLineIntersectResult;
Point_2 leftPoint;
Point_2 rightPoint;
@ -1003,7 +1001,7 @@ private:
}
else
{
LineLineIntersectResult cgalIntersection = i2(cl2(segment), cl2(leftBoundary));
const auto cgalIntersection = i2(cl2(segment), cl2(leftBoundary));
if (!cgalIntersection || !boost::get<Point_2>(&*cgalIntersection))
{
@ -1015,7 +1013,7 @@ private:
}
else
{
Point_2* result = boost::get<Point_2>(&*cgalIntersection);
const Point_2* result = boost::get<Point_2>(&*cgalIntersection);
FT t0 = pdas2(cs2(segment), ct2(segment), *result);
if (t0 >= FT(1))
@ -1061,7 +1059,7 @@ private:
}
else
{
LineLineIntersectResult cgalIntersection = i2(cl2(segment), cl2(rightBoundary));
const auto cgalIntersection = i2(cl2(segment), cl2(rightBoundary));
if (!cgalIntersection || !boost::get<Point_2>(&*cgalIntersection))
{
@ -1073,7 +1071,7 @@ private:
}
else
{
Point_2* result = boost::get<Point_2>(&*cgalIntersection);
const Point_2* result = boost::get<Point_2>(&*cgalIntersection);
FT t0 = pdas2(cs2(segment), ct2(segment), *result);
if (t0 <= FT(0))
@ -1697,8 +1695,6 @@ private:
typename Traits::Construct_target_2 construct_target_2(m_traits.construct_target_2_object());
typename Traits::Intersect_2 intersect_2(m_traits.intersect_2_object());
typedef typename cpp11::result_of<typename Traits::Intersect_2 (Line_2, Line_2)>::type LineLineIntersectResult;
Cone_tree_node* current = startNode;
Point_2 currentLocation(startLocation);
@ -1713,7 +1709,7 @@ private:
const Point_2& currentSourceImage = current->source_image();
Ray_2 rayToLocation(construct_ray_2(currentSourceImage, currentLocation));
LineLineIntersectResult cgalIntersection = intersect_2(construct_line_2(entrySegment), construct_line_2(rayToLocation));
const auto cgalIntersection = intersect_2(construct_line_2(entrySegment), construct_line_2(rayToLocation));
CGAL_assertion(bool(cgalIntersection));

View File

@ -25,7 +25,6 @@
#include <CGAL/assertions.h>
#include <CGAL/boost/graph/helpers.h>
#include <CGAL/number_utils.h>
#include <CGAL/result_of.h>
#include <CGAL/Cartesian_converter.h>
#include <cmath>
@ -459,12 +458,10 @@ public:
result_type operator () (const Segment_2& s1, const Line_2& l1, const Segment_2& s2, const Line_2& l2) const
{
typedef typename CGAL::cpp11::result_of<Intersect_2(Line_2, Line_2)>::type LineLineIntersectResult;
Line_2 s1Line(m_construct_line_2(s1));
Line_2 s2Line(m_construct_line_2(s2));
LineLineIntersectResult intersectResult1(m_intersect_2(s1Line, l1));
const auto intersectResult1 = m_intersect_2(s1Line, l1);
CGAL_assertion(bool(intersectResult1));
if (!intersectResult1) return CGAL::SMALLER;
@ -476,7 +473,7 @@ public:
CGAL_assertion_code(FT t1 = m_parametric_distance_along_segment_2(s1, *p1_ptr);)
CGAL_assertion(t1 >= FT(-1)/FT(100000) && t1 <= FT(1)+FT(1)/FT(100000));
LineLineIntersectResult intersectResult2 = m_intersect_2(s2Line, l2);
const auto intersectResult2 = m_intersect_2(s2Line, l2);
CGAL_assertion(bool(intersectResult2));
if (!intersectResult2) return CGAL::SMALLER;