replace cpp11::function by std::function

This commit is contained in:
Sébastien Loriot 2019-03-20 10:00:19 +01:00
parent 124012d9f9
commit 5a30e88a92
23 changed files with 61 additions and 136 deletions

View File

@ -29,7 +29,7 @@
#include <CGAL/regular_neighbor_coordinates_2.h>
#include <CGAL/Origin.h>
#include <CGAL/function.h>
#include <functional>
#include <boost/any.hpp>
#include <boost/mpl/if.hpp>

View File

@ -31,7 +31,7 @@
#include <CGAL/algorithm.h>
#include <CGAL/double.h>
#include <CGAL/function_objects.h>
#include <CGAL/function.h>
#include <functional>
#include <CGAL/Origin.h>
#include <CGAL/point_generators_2.h>
#include <CGAL/Random.h>
@ -553,7 +553,7 @@ void _test_interpolation_functions_2_Delaunay_with_OutputFunctor(const Dt&, cons
// wrapping the lambda in a std function
CGAL::cpp11::function<std::pair<Coord_type, bool>(const Vertex_handle)> value_function_1 =
std::function<std::pair<Coord_type, bool>(const Vertex_handle)> value_function_1 =
[](const Vertex_handle vh) -> std::pair<Coord_type, bool> { return std::make_pair(vh->info()[1].value, true); };
std::function<std::pair<Vector, bool>(const Vertex_handle)> gradient_function_1 =
@ -679,7 +679,7 @@ void _test_interpolation_functions_2_Delaunay_with_OutputFunctor(const Dt&, cons
Traits(), 0, tolerance));
// wrapping the lambda in a std function
CGAL::cpp11::function<std::pair<Coord_type, bool>(const Vertex_handle)> value_function_1 =
std::function<std::pair<Coord_type, bool>(const Vertex_handle)> value_function_1 =
[](const Vertex_handle vh) -> std::pair<Coord_type, bool> { return std::make_pair(vh->info()[1].value, true); };
std::function<std::pair<Vector, bool>(const Vertex_handle)> gradient_function_1 =

View File

@ -66,7 +66,7 @@ public:
typedef int Subdomain_index;
/// The type of object that stores the function using type-erasure
typedef CGAL::cpp11::function<Subdomain_index(const Point_3&)> Labeling_function;
typedef std::function<Subdomain_index(const Point_3&)> Labeling_function;
///@}
/// \name Types imported from the geometric traits class

View File

@ -41,7 +41,7 @@
#include <CGAL/Origin.h>
#include <CGAL/result_of.h>
#include <CGAL/function.h>
#include <functional>
#include <CGAL/internal/Mesh_3/Handle_IO_for_pair_of_int.h>
#include <CGAL/internal/Mesh_3/indices_management.h>
@ -228,18 +228,18 @@ protected:
{}
/// The function which answers subdomain queries
typedef CGAL::cpp11::function<Subdomain_index(const Point_3&)> Function;
typedef std::function<Subdomain_index(const Point_3&)> Function;
Function function_;
/// The bounding box
const Iso_cuboid_3 bbox_;
typedef CGAL::cpp11::function<
typedef std::function<
Surface_patch_index(Subdomain_index,
Subdomain_index)> Construct_surface_patch_index;
Construct_surface_patch_index cstr_s_p_index;
/// The functor that decides which sub-domain indices correspond to the
/// outside of the domain.
typedef CGAL::cpp11::function<bool(Subdomain_index)> Null;
typedef std::function<bool(Subdomain_index)> Null;
Null null;
/// The random number generator used by Construct_initial_points
CGAL_Random_share_ptr_t p_rng_;

View File

@ -34,7 +34,7 @@
#include <CGAL/Image_3.h>
#include <CGAL/function_objects.h>
#include <CGAL/function.h>
#include <functional>
#include <boost/mpl/if.hpp>
namespace CGAL {
@ -56,7 +56,7 @@ template<typename Image_word_type = unsigned char,
class Image_to_labeled_function_wrapper
{
public:
typedef CGAL::cpp11::function<Return_type(Interpolation_type)>
typedef std::function<Return_type(Interpolation_type)>
Image_values_to_labels;
// Types

View File

@ -62,7 +62,7 @@ No default value.
is a mechanism to get feedback on the advancement of the algorithm while it's running and to interrupt it if needed. It is called regularly when the algorithm is running: the current advancement (between 0. and 1.) is passed as parameter. If it returns `true`, then the algorithm continues its execution normally; if it returns `false`, the algorithm is stopped.\n
The callback will be copied and therefore needs to be lightweight.\n
Note that when a callback is run on a parallelized algorithm with `CGAL::Parallel_tag`, it is called asynchronously on a separate thread and shouldn't access or modify the variables that are parameters of the algorithm.\n
\b Type: `CGAL::cpp11::function<bool(double)>`.\n
\b Type: `std::function<bool(double)>`.\n
\b Default: empty function.\n
\cgalNPEnd

View File

@ -634,7 +634,7 @@ point set:
\section Point_set_processing_3Callbacks Callbacks
Several functions of this package provide a callback mechanism that enables the user to track the progress of the algorithms and to interrupt them if needed. A callback, in this package, is an instance of `CGAL::cpp11::function<bool(double)>` that takes the advancement as a parameter (between 0. when the algorithm begins to 1. when the algorithm is completed) and that returns `true` if the algorithm should carry on, `false` otherwise. It is passed as a named parameter with an empty function as default.
Several functions of this package provide a callback mechanism that enables the user to track the progress of the algorithms and to interrupt them if needed. A callback, in this package, is an instance of `std::function<bool(double)>` that takes the advancement as a parameter (between 0. when the algorithm begins to 1. when the algorithm is completed) and that returns `true` if the algorithm should carry on, `false` otherwise. It is passed as a named parameter with an empty function as default.
Algorithms that support this mechanism are detailed in the [Reference Manual](@ref PkgPointSetProcessing3Ref), along with the effect that an early interruption has on the output.

View File

@ -25,7 +25,7 @@ typedef CGAL::Sequential_tag Concurrency_tag;
#endif
// instance of CGAL::cpp11::function<bool(double)>
// instance of std::function<bool(double)>
struct Progress_to_std_cerr_callback
{
mutable std::size_t nb;

View File

@ -31,7 +31,7 @@
#include <CGAL/point_set_processing_assertions.h>
#include <CGAL/Point_with_normal_3.h>
#include <CGAL/squared_distance_3.h>
#include <CGAL/function.h>
#include <functional>
#include <CGAL/boost/graph/named_function_params.h>
#include <CGAL/boost/graph/named_params_helper.h>
@ -424,7 +424,7 @@ public:
`geom_traits::Vector_3`.\cgalParamEnd
\cgalParamBegin{sharpness_angle} controls the sharpness of the result.\cgalParamEnd
\cgalParamBegin{callback} an instance of
`cpp11::function<bool(double)>`. It is called regularly when the
`std::function<bool(double)>`. It is called regularly when the
algorithm is running: the current advancement (between 0. and
1.) is passed as parameter. If it returns `true`, then the
algorithm continues its execution normally; if it returns
@ -462,8 +462,8 @@ bilateral_smooth_point_set(
typedef typename Kernel::FT FT;
double sharpness_angle = choose_param(get_param(np, internal_np::sharpness_angle), 30.);
const cpp11::function<bool(double)>& callback = choose_param(get_param(np, internal_np::callback),
cpp11::function<bool(double)>());
const std::function<bool(double)>& callback = choose_param(get_param(np, internal_np::callback),
std::function<bool(double)>());
CGAL_point_set_processing_precondition(points.begin() != points.end());
CGAL_point_set_processing_precondition(k > 1);

View File

@ -31,7 +31,7 @@
#include <CGAL/property_map.h>
#include <CGAL/point_set_processing_assertions.h>
#include <CGAL/assertions.h>
#include <CGAL/function.h>
#include <functional>
#include <CGAL/boost/graph/named_function_params.h>
#include <CGAL/boost/graph/named_params_helper.h>
@ -168,7 +168,7 @@ compute_average_spacing(const typename Kernel::Point_3& query, ///< 3D point who
\cgalParamBegin{point_map} a model of `ReadablePropertyMap` with value type `geom_traits::Point_3`.
If this parameter is omitted, `CGAL::Identity_property_map<geom_traits::Point_3>` is used.\cgalParamEnd
\cgalParamBegin{callback} an instance of
`cpp11::function<bool(double)>`. It is called regularly when the
`std::function<bool(double)>`. It is called regularly when the
algorithm is running: the current advancement (between 0. and
1.) is passed as parameter. If it returns `true`, then the
algorithm continues its execution normally; if it returns
@ -205,8 +205,8 @@ compute_average_spacing(
typedef typename Kernel::Point_3 Point;
PointMap point_map = choose_param(get_param(np, internal_np::point_map), PointMap());
const cpp11::function<bool(double)>& callback = choose_param(get_param(np, internal_np::callback),
cpp11::function<bool(double)>());
const std::function<bool(double)>& callback = choose_param(get_param(np, internal_np::callback),
std::function<bool(double)>());
// types for K nearest neighbors search structure
typedef typename Kernel::FT FT;

View File

@ -30,7 +30,7 @@
#include <CGAL/point_set_processing_assertions.h>
#include <CGAL/unordered.h>
#include <CGAL/Iterator_range.h>
#include <CGAL/function.h>
#include <functional>
#include <boost/functional/hash.hpp>
#include <CGAL/boost/graph/named_function_params.h>
@ -190,7 +190,7 @@ public:
\cgalParamBegin{point_map} a model of `ReadWritePropertyMap` with value type `geom_traits::Point_3`.
If this parameter is omitted, `CGAL::Identity_property_map<geom_traits::Point_3>` is used.\cgalParamEnd
\cgalParamBegin{callback} an instance of
`cpp11::function<bool(double)>`. It is called regularly when the
`std::function<bool(double)>`. It is called regularly when the
algorithm is running: the current advancement (between 0. and
1.) is passed as parameter. If it returns `true`, then the
algorithm continues its execution normally; if it returns
@ -212,8 +212,8 @@ grid_simplify_point_set(
typedef typename Point_set_processing_3::GetPointMap<PointRange, NamedParameters>::const_type PointMap;
PointMap point_map = choose_param(get_param(np, internal_np::point_map), PointMap());
const cpp11::function<bool(double)>& callback = choose_param(get_param(np, internal_np::callback),
cpp11::function<bool(double)>());
const std::function<bool(double)>& callback = choose_param(get_param(np, internal_np::callback),
std::function<bool(double)>());
// actual type of input points
typedef typename std::iterator_traits<typename PointRange::iterator>::value_type Enriched_point;

View File

@ -39,7 +39,7 @@
#include <CGAL/PCA_util.h>
#include <CGAL/squared_distance_3.h>
#include <CGAL/Iterator_range.h>
#include <CGAL/function.h>
#include <functional>
#include <CGAL/boost/graph/named_function_params.h>
#include <CGAL/boost/graph/named_params_helper.h>
@ -144,7 +144,7 @@ namespace CGAL {
using `Eigen_diagonalize_traits` is provided. Otherwise, the internal implementation
`CGAL::Diagonalize_traits` is used.\cgalParamEnd
\cgalParamBegin{callback} an instance of
`cpp11::function<bool(double)>`. It is called regularly when the
`std::function<bool(double)>`. It is called regularly when the
algorithm is running: the current advancement (between 0. and
1.) is passed as parameter. If it returns `true`, then the
algorithm continues its execution normally; if it returns
@ -175,8 +175,8 @@ namespace CGAL {
PointMap point_map = choose_param(get_param(np, internal_np::point_map), PointMap());
unsigned int size = choose_param(get_param(np, internal_np::size), 10);
double var_max = choose_param(get_param(np, internal_np::maximum_variation), 1./3.);
const cpp11::function<bool(double)>& callback = choose_param(get_param(np, internal_np::callback),
cpp11::function<bool(double)>());
const std::function<bool(double)>& callback = choose_param(get_param(np, internal_np::callback),
std::function<bool(double)>());
typedef typename std::iterator_traits<typename PointRange::iterator>::value_type Input_type;

View File

@ -23,7 +23,7 @@
#include <CGAL/license/Point_set_processing_3.h>
#include <CGAL/function.h>
#include <functional>
#include <CGAL/thread.h>
@ -33,7 +33,7 @@ namespace Point_set_processing_3 {
class Parallel_callback
{
const cpp11::function<bool(double)>& m_callback;
const std::function<bool(double)>& m_callback;
cpp11::atomic<std::size_t>* m_advancement;
cpp11::atomic<bool>* m_interrupted;
std::size_t m_size;
@ -47,7 +47,7 @@ class Parallel_callback
}
public:
Parallel_callback (const cpp11::function<bool(double)>& callback,
Parallel_callback (const std::function<bool(double)>& callback,
std::size_t size,
std::size_t advancement = 0,
bool interrupted = false)

View File

@ -32,7 +32,7 @@
#include <CGAL/property_map.h>
#include <CGAL/point_set_processing_assertions.h>
#include <CGAL/Memory_sizer.h>
#include <CGAL/function.h>
#include <functional>
#include <CGAL/boost/graph/named_function_params.h>
#include <CGAL/boost/graph/named_params_helper.h>
@ -193,7 +193,7 @@ jet_estimate_normal(const typename Kernel::Point_3& query, ///< point to compute
\ref thirdpartyEigen "Eigen" 3.2 (or greater) is available and `CGAL_EIGEN3_ENABLED` is defined,
then `CGAL::Eigen_svd` is used.\cgalParamEnd
\cgalParamBegin{callback} an instance of
`cpp11::function<bool(double)>`. It is called regularly when the
`std::function<bool(double)>`. It is called regularly when the
algorithm is running: the current advancement (between 0. and
1.) is passed as parameter. If it returns `true`, then the
algorithm continues its execution normally; if it returns
@ -232,8 +232,8 @@ jet_estimate_normals(
PointMap point_map = choose_param(get_param(np, internal_np::point_map), PointMap());
NormalMap normal_map = choose_param(get_param(np, internal_np::normal_map), NormalMap());
unsigned int degree_fitting = choose_param(get_param(np, internal_np::degree_fitting), 2);
const cpp11::function<bool(double)>& callback = choose_param(get_param(np, internal_np::callback),
cpp11::function<bool(double)>());
const std::function<bool(double)>& callback = choose_param(get_param(np, internal_np::callback),
std::function<bool(double)>());
typedef typename Kernel::Point_3 Point;

View File

@ -31,7 +31,7 @@
#include <CGAL/Monge_via_jet_fitting.h>
#include <CGAL/property_map.h>
#include <CGAL/point_set_processing_assertions.h>
#include <CGAL/function.h>
#include <functional>
#include <CGAL/boost/graph/named_function_params.h>
#include <CGAL/boost/graph/named_params_helper.h>
@ -196,7 +196,7 @@ jet_smooth_point(
\ref thirdpartyEigen "Eigen" 3.2 (or greater) is available and `CGAL_EIGEN3_ENABLED` is defined,
then `CGAL::Eigen_svd` is used.\cgalParamEnd
\cgalParamBegin{callback} an instance of
`cpp11::function<bool(double)>`. It is called regularly when the
`std::function<bool(double)>`. It is called regularly when the
algorithm is running: the current advancement (between 0. and
1.) is passed as parameter. If it returns `true`, then the
algorithm continues its execution normally; if it returns
@ -230,8 +230,8 @@ jet_smooth_point_set(
PointMap point_map = choose_param(get_param(np, internal_np::point_map), PointMap());
unsigned int degree_fitting = choose_param(get_param(np, internal_np::degree_fitting), 2);
unsigned int degree_monge = choose_param(get_param(np, internal_np::degree_monge), 2);
const cpp11::function<bool(double)>& callback = choose_param(get_param(np, internal_np::callback),
cpp11::function<bool(double)>());
const std::function<bool(double)>& callback = choose_param(get_param(np, internal_np::callback),
std::function<bool(double)>());
typedef typename Kernel::Point_3 Point;

View File

@ -33,7 +33,7 @@
#include <CGAL/property_map.h>
#include <CGAL/point_set_processing_assertions.h>
#include <CGAL/Memory_sizer.h>
#include <CGAL/function.h>
#include <functional>
#include <CGAL/boost/graph/named_function_params.h>
#include <CGAL/boost/graph/named_params_helper.h>
@ -180,7 +180,7 @@ pca_estimate_normal(const typename Kernel::Point_3& query, ///< point to compute
\cgalParamBegin{normal_map} a model of `WritablePropertyMap` with value type
`geom_traits::Vector_3`.\cgalParamEnd
\cgalParamBegin{callback} an instance of
`cpp11::function<bool(double)>`. It is called regularly when the
`std::function<bool(double)>`. It is called regularly when the
algorithm is running: the current advancement (between 0. and
1.) is passed as parameter. If it returns `true`, then the
algorithm continues its execution normally; if it returns
@ -213,8 +213,8 @@ pca_estimate_normals(
PointMap point_map = choose_param(get_param(np, internal_np::point_map), PointMap());
NormalMap normal_map = choose_param(get_param(np, internal_np::normal_map), NormalMap());
const cpp11::function<bool(double)>& callback = choose_param(get_param(np, internal_np::callback),
cpp11::function<bool(double)>());
const std::function<bool(double)>& callback = choose_param(get_param(np, internal_np::callback),
std::function<bool(double)>());
typedef typename Kernel::Point_3 Point;

View File

@ -29,7 +29,7 @@
#include <CGAL/Orthogonal_k_neighbor_search.h>
#include <CGAL/property_map.h>
#include <CGAL/point_set_processing_assertions.h>
#include <CGAL/function.h>
#include <functional>
#include <CGAL/boost/graph/named_function_params.h>
#include <CGAL/boost/graph/named_params_helper.h>
@ -134,7 +134,7 @@ compute_avg_knn_sq_distance_3(
\cgalParamBegin{threshold_distance} minimum distance for a point to be considered as outlier
(distance here is the square root of the average squared distance to K nearest neighbors).\cgalParamEnd
\cgalParamBegin{callback} an instance of
`cpp11::function<bool(double)>`. It is called regularly when the
`std::function<bool(double)>`. It is called regularly when the
algorithm is running: the current advancement (between 0. and
1.) is passed as parameter. If it returns `true`, then the
algorithm continues its execution normally; if it returns
@ -171,8 +171,8 @@ remove_outliers(
PointMap point_map = choose_param(get_param(np, internal_np::point_map), PointMap());
double threshold_percent = choose_param(get_param(np, internal_np::threshold_percent), 10.);
double threshold_distance = choose_param(get_param(np, internal_np::threshold_distance), 0.);
const cpp11::function<bool(double)>& callback = choose_param(get_param(np, internal_np::callback),
cpp11::function<bool(double)>());
const std::function<bool(double)>& callback = choose_param(get_param(np, internal_np::callback),
std::function<bool(double)>());
typedef typename Kernel::FT FT;

View File

@ -449,7 +449,7 @@ public:
\cgalParamBegin{require_uniform_sampling} an optional preprocessing, which will give better result if the
distribution of the input points is highly non-uniform. The default value is `false`. \cgalParamEnd
\cgalParamBegin{callback} an instance of
`cpp11::function<bool(double)>`. It is called regularly when the
`std::function<bool(double)>`. It is called regularly when the
algorithm is running: the current advancement (between 0. and
1.) is passed as parameter. If it returns `true`, then the
algorithm continues its execution normally; if it returns
@ -481,8 +481,8 @@ wlop_simplify_and_regularize_point_set(
double radius = choose_param(get_param(np, internal_np::neighbor_radius), -1);
unsigned int iter_number = choose_param(get_param(np, internal_np::number_of_iterations), 35);
bool require_uniform_sampling = choose_param(get_param(np, internal_np::require_uniform_sampling), false);
const cpp11::function<bool(double)>& callback = choose_param(get_param(np, internal_np::callback),
cpp11::function<bool(double)>());
const std::function<bool(double)>& callback = choose_param(get_param(np, internal_np::callback),
std::function<bool(double)>());
typedef typename Kernel::Point_3 Point;
typedef typename Kernel::FT FT;

View File

@ -30,7 +30,7 @@
#include <CGAL/Shape_detection_3/Shape_base.h>
#include <CGAL/Shape_detection_3/Plane.h>
#include <CGAL/Random.h>
#include <CGAL/function.h>
#include <functional>
//for octree ------------------------------
#include <boost/iterator/filter_iterator.hpp>
@ -446,8 +446,8 @@ shape. The implementation follows \cgalCite{schnabel2007efficient}.
input data has been set. Otherwise, `false` is returned.
*/
bool detect(const Parameters &options = Parameters(),
const cpp11::function<bool(double)>& callback
= cpp11::function<bool(double)>())
const std::function<bool(double)>& callback
= std::function<bool(double)>())
{
m_options = options;

View File

@ -32,7 +32,7 @@
#include <CGAL/Search_traits_adapter.h>
#include <CGAL/linear_least_squares_fitting_3.h>
#include <CGAL/squared_distance_3.h>
#include <CGAL/function.h>
#include <functional>
#include <CGAL/boost/iterator/counting_iterator.hpp>
#include <CGAL/boost/iterator/transform_iterator.hpp>
@ -477,8 +477,8 @@ shape. The implementation follows \cgalCite{cgal:lm-clscm-12}.
input data has been set. Otherwise, `false` is returned.
*/
bool detect(const Parameters &options = Parameters(),
const cpp11::function<bool(double)>& callback
= cpp11::function<bool(double)>())
const std::function<bool(double)>& callback
= std::function<bool(double)>())
{
// No shape types for detection or no points provided, exit
if (m_shape_factories.size() == 0 ||

View File

@ -1,30 +0,0 @@
namespace CGAL {
namespace cpp11 {
/*!
\ingroup PkgSTLExtensionRef
An object of the class `cpp11::function` is a general-purpose polymorphic function wrapper.
There is actually no class in namespace `CGAL::cpp11` with this name, but a using declaration which
imports a class from another namespace. By order of priority: the one in namespace
`std` is used (provided by C++0x), if not found, then the one in namespace
`boost` is used.
Please refer to the [C++ manual](http://en.cppreference.com/w/cpp/utility/functional/function) for the documentation of this class.
\cgalHeading{Parameters}
The parameter `R` is the return type. The parameters `Args` are the
parameters of the function.
*/
template< typename R, typename... Args >
class function {
}; /* end cpp11::function */
} /* end namespace cpp11 */
} /* end namespace CGAL */

View File

@ -1,45 +0,0 @@
// Copyright (c) 2017 GeometryFactory Sarl (France).
// All rights reserved.
//
// This file is part of CGAL (www.cgal.org); you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 3 of the License,
// or (at your option) any later version.
//
// Licensees holding a valid commercial license may use this file in
// accordance with the commercial license agreement provided with the software.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
//
// $URL$
// $Id$
// SPDX-License-Identifier: LGPL-3.0+
//
// Author(s) : Simon Giraudot
#ifndef CGAL_FUNCTION_H
#define CGAL_FUNCTION_H
#include <CGAL/config.h>
#ifndef CGAL_CFG_NO_STD_FUNCTION
# include <functional>
#else
# include <boost/function.hpp>
#endif
namespace CGAL {
namespace cpp11 {
#ifndef CGAL_CFG_NO_STD_FUNCTION
using std::function;
#else
using boost::function;
#endif
} // cpp11
} //namespace CGAL
#endif // CGAL_FUNCTION_H

View File

@ -29,13 +29,13 @@
#include <CGAL/Surface_mesher/Implicit_surface_oracle_3.h>
#include <functional>
#include <CGAL/function.h>
#include <functional>
namespace CGAL {
template<
typename GT,
typename Function_ = cpp11::function<typename GT::FT(typename GT::Point_3)>
typename Function_ = std::function<typename GT::FT(typename GT::Point_3)>
// The type of the argument `Function` will be ignored anyway.
// The parameter is here only for backward-compatibility.
>
@ -46,7 +46,7 @@ namespace CGAL {
typedef typename Geom_traits::Sphere_3 Sphere_3;
typedef typename Geom_traits::FT FT;
typedef typename Geom_traits::Point_3 Point;
typedef cpp11::function<FT(Point)> Function;
typedef std::function<FT(Point)> Function;
typedef Implicit_surface_3<Geom_traits, Function_> Self;
Function& function() { return func; }