From cd032f05fc82e754d8312ad0cb7e38f34c89b0ca Mon Sep 17 00:00:00 2001 From: Laurent Rineau Date: Wed, 18 Apr 2018 20:08:13 +0200 Subject: [PATCH] Do not store const& to the function/functor by copy by value However, one cannot store a function type directly, but only *pointers* to function types. So I used Boost MPL to discriminate between function types and other callable (such as lambdas or functors, that can be copied). --- .../CGAL/Implicit_to_labeling_function_wrapper.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Mesh_3/include/CGAL/Implicit_to_labeling_function_wrapper.h b/Mesh_3/include/CGAL/Implicit_to_labeling_function_wrapper.h index ae67e4a6938..43c87305bba 100644 --- a/Mesh_3/include/CGAL/Implicit_to_labeling_function_wrapper.h +++ b/Mesh_3/include/CGAL/Implicit_to_labeling_function_wrapper.h @@ -43,6 +43,8 @@ #include #include #include +#include +#include #include #include @@ -66,19 +68,22 @@ public: /// Constructor Implicit_to_labeling_function_wrapper(const Function_& f) - : r_f_(f) {} + : f_(f) {} // Default copy constructor, assignment operator, and destructor are ok /// Operator () return_type operator()(const Point_3& p) const { - return ( (r_f_(p)<0) ? 1 : 0 ); + return ( (f_(p)<0) ? 1 : 0 ); } private: + typedef typename boost::mpl::if_, + Function_*, + Function_>::type Stored_function; /// Function to wrap - const Function_& r_f_; + Stored_function f_; }; // end class Implicit_to_labeling_function_wrapper