// Note: this header is a header template and must NOT have multiple-inclusion
// protection.
#include <boost/function/detail/prologue.hpp>
-#include <boost/detail/no_exceptions_support.hpp>
+#include <boost/core/no_exceptions_support.hpp>
#if defined(BOOST_MSVC)
# pragma warning( push )
#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES
# define BOOST_FUNCTION_ARGS BOOST_PP_ENUM_PARAMS(BOOST_FUNCTION_NUM_ARGS, a)
#else
-# include <boost/move/utility_core.hpp>
-# define BOOST_FUNCTION_ARG(J,I,D) ::boost::forward< BOOST_PP_CAT(T,I) >(BOOST_PP_CAT(a,I))
+# define BOOST_FUNCTION_ARG(J,I,D) static_cast<BOOST_PP_CAT(T,I)&&>(BOOST_PP_CAT(a,I))
# define BOOST_FUNCTION_ARGS BOOST_PP_ENUM(BOOST_FUNCTION_NUM_ARGS,BOOST_FUNCTION_ARG,BOOST_PP_EMPTY)
#endif
>
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<
FunctionPtr,
R BOOST_FUNCTION_COMMA
>
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<
FunctionObj,
R BOOST_FUNCTION_COMMA
>
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<
FunctionObj,
R BOOST_FUNCTION_COMMA
>
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<
MemberPtr,
R BOOST_FUNCTION_COMMA
typedef functor_manager<FunctionPtr> manager_type;
};
- template<typename FunctionPtr,
- typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
- typename Allocator>
+ template<typename FunctionPtr, typename Allocator,
+ typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
struct apply_a
{
typedef typename BOOST_FUNCTION_GET_FUNCTION_INVOKER<
typedef functor_manager<MemberPtr> manager_type;
};
- template<typename MemberPtr,
- typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
- typename Allocator>
+ template<typename MemberPtr, typename Allocator,
+ typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
struct apply_a
{
typedef typename BOOST_FUNCTION_GET_MEMBER_INVOKER<
typedef functor_manager<FunctionObj> manager_type;
};
- template<typename FunctionObj,
- typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
- typename Allocator>
+ template<typename FunctionObj, typename Allocator,
+ typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
struct apply_a
{
typedef typename BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER<
typedef reference_manager<typename RefWrapper::type> manager_type;
};
- template<typename RefWrapper,
- typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
- typename Allocator>
+ template<typename RefWrapper, typename Allocator,
+ typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
struct apply_a
{
typedef typename BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER<
// Assign to a function object using the small object optimization
template<typename FunctionObj>
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);
}
template<typename FunctionObj,typename Allocator>
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.
template<typename FunctionObj>
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);
}
template<typename FunctionObj,typename Allocator>
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;
#if defined(BOOST_NO_CXX11_ALLOCATOR)
{
if (!boost::detail::function::has_empty_target(boost::addressof(f))) {
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;
} else {
return false;
{
if (!boost::detail::function::has_empty_target(boost::addressof(f))) {
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;
} else {
return false;
typedef BOOST_FUNCTION_FUNCTION self_type;
- BOOST_FUNCTION_FUNCTION() : function_base() { }
+ BOOST_DEFAULTED_FUNCTION(BOOST_FUNCTION_FUNCTION(), : function_base() {})
// MSVC chokes if the following two constructors are collapsed into
// one with a default parameter.
template<typename Functor>
BOOST_FUNCTION_FUNCTION(Functor BOOST_FUNCTION_TARGET_FIX(const &) f
#ifndef BOOST_NO_SFINAE
- ,typename boost::enable_if_c<
+ ,typename boost::enable_if_<
!(is_integral<Functor>::value),
int>::type = 0
#endif // BOOST_NO_SFINAE
template<typename Functor,typename Allocator>
BOOST_FUNCTION_FUNCTION(Functor BOOST_FUNCTION_TARGET_FIX(const &) f, Allocator a
#ifndef BOOST_NO_SFINAE
- ,typename boost::enable_if_c<
+ ,typename boost::enable_if_<
!(is_integral<Functor>::value),
int>::type = 0
#endif // BOOST_NO_SFINAE
// construct.
template<typename Functor>
#ifndef BOOST_NO_SFINAE
- typename boost::enable_if_c<
+ typename boost::enable_if_<
!(is_integral<Functor>::value),
BOOST_FUNCTION_FUNCTION&>::type
#else
if (!f.empty()) {
this->vtable = f.vtable;
if (this->has_trivial_copy_and_destroy())
- this->functor = f.functor;
+ // Don't operate on storage directly since union type doesn't relax
+ // strict aliasing rules, despite of having member char type.
+ std::memcpy(this->functor.data, f.functor.data, sizeof(boost::detail::function::function_buffer));
else
get_vtable()->base.manager(f.functor, this->functor,
boost::detail::function::clone_functor_tag);
typedef typename boost::detail::function::get_function_tag<Functor>::type tag;
typedef boost::detail::function::BOOST_FUNCTION_GET_INVOKER<tag> get_invoker;
typedef typename get_invoker::
- template apply_a<Functor, R BOOST_FUNCTION_COMMA
- BOOST_FUNCTION_TEMPLATE_ARGS,
- Allocator>
+ template apply_a<Functor, Allocator, R BOOST_FUNCTION_COMMA
+ BOOST_FUNCTION_TEMPLATE_ARGS>
handler_type;
typedef typename handler_type::invoker_type invoker_type;
if (!f.empty()) {
this->vtable = f.vtable;
if (this->has_trivial_copy_and_destroy())
- this->functor = f.functor;
+ // Don't operate on storage directly since union type doesn't relax
+ // strict aliasing rules, despite of having member char type.
+ std::memcpy(this->functor.data, f.functor.data, sizeof(this->functor.data));
else
get_vtable()->base.manager(f.functor, this->functor,
boost::detail::function::move_functor_tag);
#if BOOST_FUNCTION_NUM_ARGS == 0
#define BOOST_FUNCTION_PARTIAL_SPEC R (void)
#else
-#define BOOST_FUNCTION_PARTIAL_SPEC R (BOOST_PP_ENUM_PARAMS(BOOST_FUNCTION_NUM_ARGS,T))
+#define BOOST_FUNCTION_PARTIAL_SPEC R (BOOST_FUNCTION_TEMPLATE_ARGS)
#endif
template<typename R BOOST_FUNCTION_COMMA
public:
- function() : base_type() {}
+ BOOST_DEFAULTED_FUNCTION(function(), : base_type() {})
template<typename Functor>
function(Functor f
#ifndef BOOST_NO_SFINAE
- ,typename boost::enable_if_c<
+ ,typename boost::enable_if_<
!(is_integral<Functor>::value),
int>::type = 0
#endif
template<typename Functor,typename Allocator>
function(Functor f, Allocator a
#ifndef BOOST_NO_SFINAE
- ,typename boost::enable_if_c<
+ ,typename boost::enable_if_<
!(is_integral<Functor>::value),
int>::type = 0
#endif
template<typename Functor>
#ifndef BOOST_NO_SFINAE
- typename boost::enable_if_c<
+ typename boost::enable_if_<
!(is_integral<Functor>::value),
self_type&>::type
#else