From b6a4607ecea033a3b54680b44cf33014d8097e46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20M=C3=B6ller?= Date: Tue, 24 Apr 2012 16:17:26 +0000 Subject: [PATCH] Removed mentioning of the Intersect metafunction. Switched everything to the yet unimplemented boost::result_of. --- .../Kernel_23/predicates_constructions.tex | 31 ++++++++++++------- .../Kernel_23_ref/Kernel_Intersect_2.tex | 12 +++---- .../Kernel_23_ref/Kernel_Intersect_3.tex | 7 +---- .../doc_tex/Kernel_23_ref/intersection.tex | 5 +-- Kernel_23/examples/Kernel_23/MyKernel.cpp | 3 +- .../examples/Kernel_23/intersections.cpp | 27 ++++++++-------- .../Kernel_d/predicates_constructions_d.tex | 8 +++-- .../Kernel_d_ref/Kernel_Intersect_d.tex | 3 +- 8 files changed, 48 insertions(+), 48 deletions(-) diff --git a/Kernel_23/doc_tex/Kernel_23/predicates_constructions.tex b/Kernel_23/doc_tex/Kernel_23/predicates_constructions.tex index cf2c1dea49e..b8f183784a4 100644 --- a/Kernel_23/doc_tex/Kernel_23/predicates_constructions.tex +++ b/Kernel_23/doc_tex/Kernel_23/predicates_constructions.tex @@ -62,18 +62,21 @@ There are number types on which no \ccStyle{sqrt} operation is defined, especially integer types and rationals. \end{itemize} -\subsection{Intersections and variant return values} +\subsection{Intersections and variant return types} Some functions can return different types of objects. To achieve this in a type safe way {\cgal} uses return values of type \ccStyle{boost::optional< boost::variant< T \ldots\ >} were T... is a list of all possible resulting geometric objects. The exact result type of an intersection can be determined by using the metafunction -\ccStyle{Result} in either \ccc{Kernel::Intersect_2} or -\ccc{Kernel::Intersect_3}. +\ccc{boost::result_of} or +\ccc{boost::result_of}, where +\ccc{Type1} and \ccc{Type2} are the types of the objects used in the +intersection computation. \ccExample -In the following example, the metafunction is used to provide the return value for the -\ccHtmlNoLinksFrom{intersection} computation: + +In the following example, \ccc{result_of} is used to query the return +value for the \ccHtmlNoLinksFrom{intersection} computation: \ccHtmlLinksOff% \begin{cprog} @@ -86,15 +89,19 @@ In the following example, the metafunction is used to provide the return value f std::cin >> segment_1 >> segment_2; - K::Intersect_2::template Result::Type - v = intersection(s1, s2); + /* C++11 */ + auto v = intersection(segment_1, segment_2); + + /* C++03 */ + /*boost::result_of::type */ + /* v = intersection(segment_1, segment_2); */ if(v) { /* not empty */ - if (const Point_2 *p = boost::get(&*v) ) { - /* do something with *p */ - } else if (const Segment_2 *s = boost::get(&*v) ) { - /* do something with *s */ - } + if (const Point_2 *p = boost::get(&*v) ) { + /* do something with *p */ + } else if (const Segment_2 *s = boost::get(&*v) ) { + /* do something with *s */ + } } else { /* empty intersection */ } diff --git a/Kernel_23/doc_tex/Kernel_23_ref/Kernel_Intersect_2.tex b/Kernel_23/doc_tex/Kernel_23_ref/Kernel_Intersect_2.tex index 610ed7d4be5..f686aaa30a0 100644 --- a/Kernel_23/doc_tex/Kernel_23_ref/Kernel_Intersect_2.tex +++ b/Kernel_23/doc_tex/Kernel_23_ref/Kernel_Intersect_2.tex @@ -3,14 +3,10 @@ A model for this must provide \ccCreationVariable{fo} -\ccMemberFunction{Kernel::Intersect_2::Result::Type operator()(Type1 obj1, Type2 obj2);} -{computes the \ccHtmlNoLinksFrom{intersection} region of two geometrical objects of type -\ccStyle{Type1} and \ccStyle{Type2}} - -The function is only defined for \ccStyle{Type1} and \ccStyle{Type2} -when \ccStyle{Result::Type} is also defined. - -\ccNestedType{Result}{A binary metafunction to determine the return type of \ccStyle{operator()}, when called with types \ccStyle{A} and \ccStyle{B}. Provides the typedef \ccStyle{Type}.} +\ccMemberFunction{typename + boost::result_of::type operator()(Type1 obj1, Type2 obj2);} + {computes the \ccHtmlNoLinksFrom{intersection} region of two geometrical objects of type + \ccStyle{Type1} and \ccStyle{Type2}} \ccRefines \ccc{AdaptableFunctor} (with two arguments) diff --git a/Kernel_23/doc_tex/Kernel_23_ref/Kernel_Intersect_3.tex b/Kernel_23/doc_tex/Kernel_23_ref/Kernel_Intersect_3.tex index f696662d806..320d6e00d63 100644 --- a/Kernel_23/doc_tex/Kernel_23_ref/Kernel_Intersect_3.tex +++ b/Kernel_23/doc_tex/Kernel_23_ref/Kernel_Intersect_3.tex @@ -3,14 +3,9 @@ A model for this must provide \ccCreationVariable{fo} -\ccMemberFunction{Kernel::Intersect_3::Result::Type operator()(Type1 obj1, Type2 obj2);} +\ccMemberFunction{boost::result_of::type operator()(Type1 obj1, Type2 obj2);} {computes the \ccHtmlNoLinksFrom{intersection} region of \ccStyle{obj1} and \ccStyle{obj2}} -The function is only defined for \ccStyle{Type1} and \ccStyle{Type2} -when \ccStyle{Result::Type} is also defined. - -\ccNestedType{Result}{A binary metafunction to determine the return type of \ccStyle{operator()}, when called with types \ccStyle{A} and \ccStyle{B}. Provides the typedef \ccStyle{Type}.} - \ccRefines \ccc{AdaptableFunctor} (with two or three arguments) diff --git a/Kernel_23/doc_tex/Kernel_23_ref/intersection.tex b/Kernel_23/doc_tex/Kernel_23_ref/intersection.tex index b0785e4e8d3..c06f1b09664 100644 --- a/Kernel_23/doc_tex/Kernel_23_ref/intersection.tex +++ b/Kernel_23/doc_tex/Kernel_23_ref/intersection.tex @@ -22,7 +22,7 @@ the macro \ccc{CGAL_INTERSECTION_VERSION} must be defined to \ccUnchecked{ \ccRefLabel{Kernel::intersection} -\ccFunction{Kernel::Intersect_23::Result::::Type intersection(Type1 obj1, Type2 obj2);} +\ccFunction{boost::result_of::type intersection(Type1 obj1, Type2 obj2);} {Two objects \ccStyle{obj1} and \ccStyle{obj2} intersect if there is a point \ccStyle{p} that is part of both \ccStyle{obj1} and \ccStyle{obj2}. The \ccHtmlNoLinksFrom{intersection} region of those two objects is defined as the set of all @@ -629,9 +629,6 @@ intersection point, and \ccc{obj3} are equal. \end{itemize} -A typedef for the result type is available through the special traits class -\ccStyle{template Intersection_traits_spherical}. - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \ccExample diff --git a/Kernel_23/examples/Kernel_23/MyKernel.cpp b/Kernel_23/examples/Kernel_23/MyKernel.cpp index 85ad7eab68d..fa5749d8234 100644 --- a/Kernel_23/examples/Kernel_23/MyKernel.cpp +++ b/Kernel_23/examples/Kernel_23/MyKernel.cpp @@ -55,7 +55,8 @@ int main() K::Intersect_2 intersection; - CGAL::Object o = intersection(s1, s2); + boost::result_of::type + intersect = intersection(s1, s2); K::Construct_cartesian_const_iterator_2 construct_it; K::Cartesian_const_iterator_2 cit = construct_it(a); diff --git a/Kernel_23/examples/Kernel_23/intersections.cpp b/Kernel_23/examples/Kernel_23/intersections.cpp index b5832a4b521..f41316f59b2 100644 --- a/Kernel_23/examples/Kernel_23/intersections.cpp +++ b/Kernel_23/examples/Kernel_23/intersections.cpp @@ -3,19 +3,21 @@ #include #include - #include using namespace CGAL; -typedef CGAL::Simple_cartesian K; -typedef K::Point_2 Point; -typedef CGAL::Creator_uniform_2 Pt_creator; -typedef K::Segment_2 Segment; +typedef CGAL::Simple_cartesian K; +typedef K::Point_2 Point; +typedef K::Segment_2 Segment; + +typedef CGAL::Creator_uniform_2 Pt_creator; typedef Random_points_on_segment_2 P1; -typedef Random_points_on_circle_2 P2; -typedef Creator_uniform_2< Point, Segment> Seg_creator; -typedef Join_input_iterator_2< P1, P2, Seg_creator> Seg_iterator; +typedef Random_points_on_circle_2 P2; +typedef Creator_uniform_2< Point, Segment> Seg_creator; +typedef Join_input_iterator_2< P1, P2, Seg_creator> Seg_iterator; + +using boost::result_of; int main() { @@ -37,7 +39,8 @@ int main() auto v = intersection(input.back(), input.front()); #else // without C++11 - K::Intersect_2::Result::Type v = intersection(input.back(), input.front()); + result_of::type v + = intersection(input.back(), input.front()); #endif // splitting results with Dispatch_output_iterator @@ -60,11 +63,9 @@ int main() [&s1] (const Segment& s) { return intersection(s1, s); }); #else // without + K::Intersect_2 intersector = K().intersect_2_object(); std::transform(input.begin(), input.end(), disp, - boost::bind(static_cast< - K::Intersect_2::Result::Type(*)(const Segment&, const Segment&) - >(&intersection), - input.front(), _1)); + boost::bind(intersector, input.front(), _1)); #endif std::cout << "Point intersections: " << points.size() << std::endl; diff --git a/Kernel_d/doc_tex/Kernel_d/predicates_constructions_d.tex b/Kernel_d/doc_tex/Kernel_d/predicates_constructions_d.tex index 418ae200945..5555b859de2 100644 --- a/Kernel_d/doc_tex/Kernel_d/predicates_constructions_d.tex +++ b/Kernel_d/doc_tex/Kernel_d/predicates_constructions_d.tex @@ -68,8 +68,9 @@ returns a \ccStyle{boost::optional< boost::variant< T \ldots\ > >} were T\textellipsis\ is a list of all possible resulting geometric objects. The exact result type of an intersection can be determined by using -the metafunction \ccStyle{Result} in either -\ccc{Kernel::Intersect_d}. +\ccStyle{boost::result_of::type} +where \ccStyle{Type1} and \ccStyle{Type2} are the types of the objects +used in the intersection query. \ccExample \ccHtmlLinksOff% @@ -79,7 +80,8 @@ the metafunction \ccStyle{Result} in either typedef Segment_d< K > Segment; Segment s1, s2; std::cin >> s1 >> s2; - K::Intersect_d::Result::Type + + boost::result_of::type v = intersection(s1, s2); if(v) { /* not empty */ diff --git a/Kernel_d/doc_tex/Kernel_d_ref/Kernel_Intersect_d.tex b/Kernel_d/doc_tex/Kernel_d_ref/Kernel_Intersect_d.tex index 3f51071787a..fb9414f3a7c 100644 --- a/Kernel_d/doc_tex/Kernel_d_ref/Kernel_Intersect_d.tex +++ b/Kernel_d/doc_tex/Kernel_d_ref/Kernel_Intersect_d.tex @@ -4,7 +4,8 @@ A model for this must provide: \ccCreationVariable{fo} \ccMemberFunction{ - Kernel::Intersect_d::Result, Type2 >::Type + typename + boost::result_of, Type2)>::type operator()(const Type1& p, const Type2& q);} {returns the result of the intersection of $p$ and $q$ in form of a polymorphic object. \ccc{Kernel_object} may be any of