forked from boostorg/function
Drop dependency on MPL
This commit is contained in:
@ -26,13 +26,13 @@
|
|||||||
#include <boost/type_traits/is_volatile.hpp>
|
#include <boost/type_traits/is_volatile.hpp>
|
||||||
#include <boost/type_traits/composite_traits.hpp>
|
#include <boost/type_traits/composite_traits.hpp>
|
||||||
#include <boost/ref.hpp>
|
#include <boost/ref.hpp>
|
||||||
#include <boost/mpl/if.hpp>
|
#include <boost/type_traits/conditional.hpp>
|
||||||
#include <boost/config/workaround.hpp>
|
#include <boost/config/workaround.hpp>
|
||||||
#include <boost/type_traits/alignment_of.hpp>
|
#include <boost/type_traits/alignment_of.hpp>
|
||||||
#ifndef BOOST_NO_SFINAE
|
#ifndef BOOST_NO_SFINAE
|
||||||
#include <boost/type_traits/enable_if.hpp>
|
#include <boost/type_traits/enable_if.hpp>
|
||||||
#else
|
#else
|
||||||
# include "boost/mpl/bool.hpp"
|
#include <boost/type_traits/integral_constant.hpp>
|
||||||
#endif
|
#endif
|
||||||
#include <boost/function_equal.hpp>
|
#include <boost/function_equal.hpp>
|
||||||
#include <boost/function/function_fwd.hpp>
|
#include <boost/function/function_fwd.hpp>
|
||||||
@ -152,15 +152,15 @@ namespace boost {
|
|||||||
template<typename F>
|
template<typename F>
|
||||||
class get_function_tag
|
class get_function_tag
|
||||||
{
|
{
|
||||||
typedef typename mpl::if_c<(is_pointer<F>::value),
|
typedef typename conditional<(is_pointer<F>::value),
|
||||||
function_ptr_tag,
|
function_ptr_tag,
|
||||||
function_obj_tag>::type ptr_or_obj_tag;
|
function_obj_tag>::type ptr_or_obj_tag;
|
||||||
|
|
||||||
typedef typename mpl::if_c<(is_member_pointer<F>::value),
|
typedef typename conditional<(is_member_pointer<F>::value),
|
||||||
member_ptr_tag,
|
member_ptr_tag,
|
||||||
ptr_or_obj_tag>::type ptr_or_obj_or_mem_tag;
|
ptr_or_obj_tag>::type ptr_or_obj_or_mem_tag;
|
||||||
|
|
||||||
typedef typename mpl::if_c<(is_reference_wrapper<F>::value),
|
typedef typename conditional<(is_reference_wrapper<F>::value),
|
||||||
function_obj_ref_tag,
|
function_obj_ref_tag,
|
||||||
ptr_or_obj_or_mem_tag>::type or_ref_tag;
|
ptr_or_obj_or_mem_tag>::type or_ref_tag;
|
||||||
|
|
||||||
@ -328,7 +328,7 @@ namespace boost {
|
|||||||
// Function objects that fit in the small-object buffer.
|
// Function objects that fit in the small-object buffer.
|
||||||
static inline void
|
static inline void
|
||||||
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
|
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
|
||||||
functor_manager_operation_type op, mpl::true_)
|
functor_manager_operation_type op, true_type)
|
||||||
{
|
{
|
||||||
functor_manager_common<Functor>::manage_small(in_buffer,out_buffer,op);
|
functor_manager_common<Functor>::manage_small(in_buffer,out_buffer,op);
|
||||||
}
|
}
|
||||||
@ -336,7 +336,7 @@ namespace boost {
|
|||||||
// Function objects that require heap allocation
|
// Function objects that require heap allocation
|
||||||
static inline void
|
static inline void
|
||||||
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
|
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
|
||||||
functor_manager_operation_type op, mpl::false_)
|
functor_manager_operation_type op, false_type)
|
||||||
{
|
{
|
||||||
if (op == clone_functor_tag) {
|
if (op == clone_functor_tag) {
|
||||||
// Clone the functor
|
// Clone the functor
|
||||||
@ -377,7 +377,7 @@ namespace boost {
|
|||||||
functor_manager_operation_type op, function_obj_tag)
|
functor_manager_operation_type op, function_obj_tag)
|
||||||
{
|
{
|
||||||
manager(in_buffer, out_buffer, op,
|
manager(in_buffer, out_buffer, op,
|
||||||
mpl::bool_<(function_allows_small_object_optimization<functor_type>::value)>());
|
integral_constant<bool, (function_allows_small_object_optimization<functor_type>::value)>());
|
||||||
}
|
}
|
||||||
|
|
||||||
// For member pointers, we use the small-object optimization buffer.
|
// For member pointers, we use the small-object optimization buffer.
|
||||||
@ -385,7 +385,7 @@ namespace boost {
|
|||||||
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
|
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
|
||||||
functor_manager_operation_type op, member_ptr_tag)
|
functor_manager_operation_type op, member_ptr_tag)
|
||||||
{
|
{
|
||||||
manager(in_buffer, out_buffer, op, mpl::true_());
|
manager(in_buffer, out_buffer, op, true_type());
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -427,7 +427,7 @@ namespace boost {
|
|||||||
// Function objects that fit in the small-object buffer.
|
// Function objects that fit in the small-object buffer.
|
||||||
static inline void
|
static inline void
|
||||||
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
|
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
|
||||||
functor_manager_operation_type op, mpl::true_)
|
functor_manager_operation_type op, true_type)
|
||||||
{
|
{
|
||||||
functor_manager_common<Functor>::manage_small(in_buffer,out_buffer,op);
|
functor_manager_common<Functor>::manage_small(in_buffer,out_buffer,op);
|
||||||
}
|
}
|
||||||
@ -435,7 +435,7 @@ namespace boost {
|
|||||||
// Function objects that require heap allocation
|
// Function objects that require heap allocation
|
||||||
static inline void
|
static inline void
|
||||||
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
|
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
|
||||||
functor_manager_operation_type op, mpl::false_)
|
functor_manager_operation_type op, false_type)
|
||||||
{
|
{
|
||||||
typedef functor_wrapper<Functor,Allocator> functor_wrapper_type;
|
typedef functor_wrapper<Functor,Allocator> functor_wrapper_type;
|
||||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
@ -499,7 +499,7 @@ namespace boost {
|
|||||||
functor_manager_operation_type op, function_obj_tag)
|
functor_manager_operation_type op, function_obj_tag)
|
||||||
{
|
{
|
||||||
manager(in_buffer, out_buffer, op,
|
manager(in_buffer, out_buffer, op,
|
||||||
mpl::bool_<(function_allows_small_object_optimization<functor_type>::value)>());
|
integral_constant<bool, (function_allows_small_object_optimization<functor_type>::value)>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -530,24 +530,24 @@ namespace boost {
|
|||||||
#ifdef BOOST_NO_SFINAE
|
#ifdef BOOST_NO_SFINAE
|
||||||
// These routines perform comparisons between a Boost.Function
|
// These routines perform comparisons between a Boost.Function
|
||||||
// object and an arbitrary function object (when the last
|
// object and an arbitrary function object (when the last
|
||||||
// parameter is mpl::bool_<false>) or against zero (when the
|
// parameter is false_type) or against zero (when the
|
||||||
// last parameter is mpl::bool_<true>). They are only necessary
|
// last parameter is true_type). They are only necessary
|
||||||
// for compilers that don't support SFINAE.
|
// for compilers that don't support SFINAE.
|
||||||
template<typename Function, typename Functor>
|
template<typename Function, typename Functor>
|
||||||
bool
|
bool
|
||||||
compare_equal(const Function& f, const Functor&, int, mpl::bool_<true>)
|
compare_equal(const Function& f, const Functor&, int, true_type)
|
||||||
{ return f.empty(); }
|
{ return f.empty(); }
|
||||||
|
|
||||||
template<typename Function, typename Functor>
|
template<typename Function, typename Functor>
|
||||||
bool
|
bool
|
||||||
compare_not_equal(const Function& f, const Functor&, int,
|
compare_not_equal(const Function& f, const Functor&, int,
|
||||||
mpl::bool_<true>)
|
true_type)
|
||||||
{ return !f.empty(); }
|
{ return !f.empty(); }
|
||||||
|
|
||||||
template<typename Function, typename Functor>
|
template<typename Function, typename Functor>
|
||||||
bool
|
bool
|
||||||
compare_equal(const Function& f, const Functor& g, long,
|
compare_equal(const Function& f, const Functor& g, long,
|
||||||
mpl::bool_<false>)
|
false_type)
|
||||||
{
|
{
|
||||||
if (const Functor* fp = f.template target<Functor>())
|
if (const Functor* fp = f.template target<Functor>())
|
||||||
return function_equal(*fp, g);
|
return function_equal(*fp, g);
|
||||||
@ -557,7 +557,7 @@ namespace boost {
|
|||||||
template<typename Function, typename Functor>
|
template<typename Function, typename Functor>
|
||||||
bool
|
bool
|
||||||
compare_equal(const Function& f, const reference_wrapper<Functor>& g,
|
compare_equal(const Function& f, const reference_wrapper<Functor>& g,
|
||||||
int, mpl::bool_<false>)
|
int, false_type)
|
||||||
{
|
{
|
||||||
if (const Functor* fp = f.template target<Functor>())
|
if (const Functor* fp = f.template target<Functor>())
|
||||||
return fp == g.get_pointer();
|
return fp == g.get_pointer();
|
||||||
@ -567,7 +567,7 @@ namespace boost {
|
|||||||
template<typename Function, typename Functor>
|
template<typename Function, typename Functor>
|
||||||
bool
|
bool
|
||||||
compare_not_equal(const Function& f, const Functor& g, long,
|
compare_not_equal(const Function& f, const Functor& g, long,
|
||||||
mpl::bool_<false>)
|
false_type)
|
||||||
{
|
{
|
||||||
if (const Functor* fp = f.template target<Functor>())
|
if (const Functor* fp = f.template target<Functor>())
|
||||||
return !function_equal(*fp, g);
|
return !function_equal(*fp, g);
|
||||||
@ -578,7 +578,7 @@ namespace boost {
|
|||||||
bool
|
bool
|
||||||
compare_not_equal(const Function& f,
|
compare_not_equal(const Function& f,
|
||||||
const reference_wrapper<Functor>& g, int,
|
const reference_wrapper<Functor>& g, int,
|
||||||
mpl::bool_<false>)
|
false_type)
|
||||||
{
|
{
|
||||||
if (const Functor* fp = f.template target<Functor>())
|
if (const Functor* fp = f.template target<Functor>())
|
||||||
return fp != g.get_pointer();
|
return fp != g.get_pointer();
|
||||||
@ -750,28 +750,28 @@ inline bool operator!=(detail::function::useless_clear_type*,
|
|||||||
template<typename Functor>
|
template<typename Functor>
|
||||||
inline bool operator==(const function_base& f, Functor g)
|
inline bool operator==(const function_base& f, Functor g)
|
||||||
{
|
{
|
||||||
typedef mpl::bool_<(is_integral<Functor>::value)> integral;
|
typedef integral_constant<bool, (is_integral<Functor>::value)> integral;
|
||||||
return detail::function::compare_equal(f, g, 0, integral());
|
return detail::function::compare_equal(f, g, 0, integral());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Functor>
|
template<typename Functor>
|
||||||
inline bool operator==(Functor g, const function_base& f)
|
inline bool operator==(Functor g, const function_base& f)
|
||||||
{
|
{
|
||||||
typedef mpl::bool_<(is_integral<Functor>::value)> integral;
|
typedef integral_constant<bool, (is_integral<Functor>::value)> integral;
|
||||||
return detail::function::compare_equal(f, g, 0, integral());
|
return detail::function::compare_equal(f, g, 0, integral());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Functor>
|
template<typename Functor>
|
||||||
inline bool operator!=(const function_base& f, Functor g)
|
inline bool operator!=(const function_base& f, Functor g)
|
||||||
{
|
{
|
||||||
typedef mpl::bool_<(is_integral<Functor>::value)> integral;
|
typedef integral_constant<bool, (is_integral<Functor>::value)> integral;
|
||||||
return detail::function::compare_not_equal(f, g, 0, integral());
|
return detail::function::compare_not_equal(f, g, 0, integral());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Functor>
|
template<typename Functor>
|
||||||
inline bool operator!=(Functor g, const function_base& f)
|
inline bool operator!=(Functor g, const function_base& f)
|
||||||
{
|
{
|
||||||
typedef mpl::bool_<(is_integral<Functor>::value)> integral;
|
typedef integral_constant<bool, (is_integral<Functor>::value)> integral;
|
||||||
return detail::function::compare_not_equal(f, g, 0, integral());
|
return detail::function::compare_not_equal(f, g, 0, integral());
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -240,7 +240,7 @@ namespace boost {
|
|||||||
>
|
>
|
||||||
struct BOOST_FUNCTION_GET_FUNCTION_INVOKER
|
struct BOOST_FUNCTION_GET_FUNCTION_INVOKER
|
||||||
{
|
{
|
||||||
typedef typename mpl::if_c<(is_void<R>::value),
|
typedef typename conditional<(is_void<R>::value),
|
||||||
BOOST_FUNCTION_VOID_FUNCTION_INVOKER<
|
BOOST_FUNCTION_VOID_FUNCTION_INVOKER<
|
||||||
FunctionPtr,
|
FunctionPtr,
|
||||||
R BOOST_FUNCTION_COMMA
|
R BOOST_FUNCTION_COMMA
|
||||||
@ -261,7 +261,7 @@ namespace boost {
|
|||||||
>
|
>
|
||||||
struct BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER
|
struct BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER
|
||||||
{
|
{
|
||||||
typedef typename mpl::if_c<(is_void<R>::value),
|
typedef typename conditional<(is_void<R>::value),
|
||||||
BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER<
|
BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER<
|
||||||
FunctionObj,
|
FunctionObj,
|
||||||
R BOOST_FUNCTION_COMMA
|
R BOOST_FUNCTION_COMMA
|
||||||
@ -282,7 +282,7 @@ namespace boost {
|
|||||||
>
|
>
|
||||||
struct BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER
|
struct BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER
|
||||||
{
|
{
|
||||||
typedef typename mpl::if_c<(is_void<R>::value),
|
typedef typename conditional<(is_void<R>::value),
|
||||||
BOOST_FUNCTION_VOID_FUNCTION_REF_INVOKER<
|
BOOST_FUNCTION_VOID_FUNCTION_REF_INVOKER<
|
||||||
FunctionObj,
|
FunctionObj,
|
||||||
R BOOST_FUNCTION_COMMA
|
R BOOST_FUNCTION_COMMA
|
||||||
@ -305,7 +305,7 @@ namespace boost {
|
|||||||
>
|
>
|
||||||
struct BOOST_FUNCTION_GET_MEMBER_INVOKER
|
struct BOOST_FUNCTION_GET_MEMBER_INVOKER
|
||||||
{
|
{
|
||||||
typedef typename mpl::if_c<(is_void<R>::value),
|
typedef typename conditional<(is_void<R>::value),
|
||||||
BOOST_FUNCTION_VOID_MEMBER_INVOKER<
|
BOOST_FUNCTION_VOID_MEMBER_INVOKER<
|
||||||
MemberPtr,
|
MemberPtr,
|
||||||
R BOOST_FUNCTION_COMMA
|
R BOOST_FUNCTION_COMMA
|
||||||
@ -567,27 +567,27 @@ namespace boost {
|
|||||||
// Assign to a function object using the small object optimization
|
// Assign to a function object using the small object optimization
|
||||||
template<typename FunctionObj>
|
template<typename FunctionObj>
|
||||||
void
|
void
|
||||||
assign_functor(FunctionObj f, function_buffer& functor, mpl::true_) const
|
assign_functor(FunctionObj f, function_buffer& functor, true_type) const
|
||||||
{
|
{
|
||||||
new (reinterpret_cast<void*>(functor.data)) FunctionObj(f);
|
new (reinterpret_cast<void*>(functor.data)) FunctionObj(f);
|
||||||
}
|
}
|
||||||
template<typename FunctionObj,typename Allocator>
|
template<typename FunctionObj,typename Allocator>
|
||||||
void
|
void
|
||||||
assign_functor_a(FunctionObj f, function_buffer& functor, Allocator, mpl::true_) const
|
assign_functor_a(FunctionObj f, function_buffer& functor, Allocator, true_type) const
|
||||||
{
|
{
|
||||||
assign_functor(f,functor,mpl::true_());
|
assign_functor(f,functor,true_type());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign to a function object allocated on the heap.
|
// Assign to a function object allocated on the heap.
|
||||||
template<typename FunctionObj>
|
template<typename FunctionObj>
|
||||||
void
|
void
|
||||||
assign_functor(FunctionObj f, function_buffer& functor, mpl::false_) const
|
assign_functor(FunctionObj f, function_buffer& functor, false_type) const
|
||||||
{
|
{
|
||||||
functor.members.obj_ptr = new FunctionObj(f);
|
functor.members.obj_ptr = new FunctionObj(f);
|
||||||
}
|
}
|
||||||
template<typename FunctionObj,typename Allocator>
|
template<typename FunctionObj,typename Allocator>
|
||||||
void
|
void
|
||||||
assign_functor_a(FunctionObj f, function_buffer& functor, Allocator a, mpl::false_) const
|
assign_functor_a(FunctionObj f, function_buffer& functor, Allocator a, false_type) const
|
||||||
{
|
{
|
||||||
typedef functor_wrapper<FunctionObj,Allocator> functor_wrapper_type;
|
typedef functor_wrapper<FunctionObj,Allocator> functor_wrapper_type;
|
||||||
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
#if defined(BOOST_NO_CXX11_ALLOCATOR)
|
||||||
@ -615,7 +615,7 @@ namespace boost {
|
|||||||
{
|
{
|
||||||
if (!boost::detail::function::has_empty_target(boost::addressof(f))) {
|
if (!boost::detail::function::has_empty_target(boost::addressof(f))) {
|
||||||
assign_functor(f, functor,
|
assign_functor(f, functor,
|
||||||
mpl::bool_<(function_allows_small_object_optimization<FunctionObj>::value)>());
|
integral_constant<bool, (function_allows_small_object_optimization<FunctionObj>::value)>());
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
@ -627,7 +627,7 @@ namespace boost {
|
|||||||
{
|
{
|
||||||
if (!boost::detail::function::has_empty_target(boost::addressof(f))) {
|
if (!boost::detail::function::has_empty_target(boost::addressof(f))) {
|
||||||
assign_functor_a(f, functor, a,
|
assign_functor_a(f, functor, a,
|
||||||
mpl::bool_<(function_allows_small_object_optimization<FunctionObj>::value)>());
|
integral_constant<bool, (function_allows_small_object_optimization<FunctionObj>::value)>());
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
Reference in New Issue
Block a user