mirror of
https://github.com/boostorg/function.git
synced 2025-06-30 06:21:03 +02:00
Compare commits
1 Commits
svn-branch
...
svn-branch
Author | SHA1 | Date | |
---|---|---|---|
98a207958d |
@ -1,22 +0,0 @@
|
||||
#----------------------------------------------------------------------------
|
||||
# This file was automatically generated from the original CMakeLists.txt file
|
||||
# Add a variable to hold the headers for the library
|
||||
set (lib_headers
|
||||
function.hpp
|
||||
function
|
||||
)
|
||||
|
||||
# Add a library target to the build system
|
||||
boost_library_project(
|
||||
function
|
||||
# SRCDIRS
|
||||
TESTDIRS test
|
||||
HEADERS ${lib_headers}
|
||||
DOCDIRS doc
|
||||
# DESCRIPTION
|
||||
MODULARIZED
|
||||
# AUTHORS
|
||||
# MAINTAINERS
|
||||
)
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
boost_add_documentation(function.xml
|
||||
faq.xml history.xml misc.xml reference.xml tests.xml tutorial.xml)
|
@ -6,10 +6,5 @@
|
||||
project boost/doc ;
|
||||
import boostbook : boostbook ;
|
||||
|
||||
boostbook function-doc
|
||||
:
|
||||
function.xml
|
||||
:
|
||||
<format>pdf:<xsl:param>boost.url.prefix=http://www.boost.org/doc/libs/release/doc/html
|
||||
;
|
||||
boostbook function-doc : function.xml ;
|
||||
|
||||
|
@ -18,9 +18,6 @@
|
||||
#include <typeinfo>
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/integer.hpp>
|
||||
#include <boost/type_traits/has_trivial_copy.hpp>
|
||||
#include <boost/type_traits/has_trivial_destructor.hpp>
|
||||
#include <boost/type_traits/is_const.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/type_traits/is_volatile.hpp>
|
||||
@ -45,7 +42,7 @@
|
||||
#endif
|
||||
|
||||
// Define BOOST_FUNCTION_STD_NS to the namespace that contains type_info.
|
||||
#ifdef BOOST_NO_STD_TYPEINFO
|
||||
#ifdef BOOST_NO_EXCEPTION_STD_NAMESPACE
|
||||
// Embedded VC++ does not have type_info in namespace std
|
||||
# define BOOST_FUNCTION_STD_NS
|
||||
#else
|
||||
@ -196,8 +193,8 @@ namespace boost {
|
||||
struct reference_manager
|
||||
{
|
||||
static inline void
|
||||
manage(const function_buffer& in_buffer, function_buffer& out_buffer,
|
||||
functor_manager_operation_type op)
|
||||
get(const function_buffer& in_buffer, function_buffer& out_buffer,
|
||||
functor_manager_operation_type op)
|
||||
{
|
||||
switch (op) {
|
||||
case clone_functor_tag:
|
||||
@ -399,14 +396,6 @@ namespace boost {
|
||||
mpl::bool_<(function_allows_small_object_optimization<functor_type>::value)>());
|
||||
}
|
||||
|
||||
// For member pointers, we use the small-object optimization buffer.
|
||||
static inline void
|
||||
manager(const function_buffer& in_buffer, function_buffer& out_buffer,
|
||||
functor_manager_operation_type op, member_ptr_tag)
|
||||
{
|
||||
manager(in_buffer, out_buffer, op, mpl::true_());
|
||||
}
|
||||
|
||||
public:
|
||||
/* Dispatch to an appropriate manager based on whether we have a
|
||||
function pointer or a function object pointer. */
|
||||
@ -600,6 +589,7 @@ namespace boost {
|
||||
*/
|
||||
struct vtable_base
|
||||
{
|
||||
vtable_base() : manager(0) { }
|
||||
void (*manager)(const function_buffer& in_buffer,
|
||||
function_buffer& out_buffer,
|
||||
functor_manager_operation_type op);
|
||||
@ -628,7 +618,7 @@ public:
|
||||
if (!vtable) return typeid(void);
|
||||
|
||||
detail::function::function_buffer type;
|
||||
get_vtable()->manager(functor, type, detail::function::get_functor_type_tag);
|
||||
vtable->manager(functor, type, detail::function::get_functor_type_tag);
|
||||
return *type.type.type;
|
||||
}
|
||||
|
||||
@ -641,7 +631,7 @@ public:
|
||||
type_result.type.type = &typeid(Functor);
|
||||
type_result.type.const_qualified = is_const<Functor>::value;
|
||||
type_result.type.volatile_qualified = is_volatile<Functor>::value;
|
||||
get_vtable()->manager(functor, type_result,
|
||||
vtable->manager(functor, type_result,
|
||||
detail::function::check_functor_type_tag);
|
||||
return static_cast<Functor*>(type_result.obj_ptr);
|
||||
}
|
||||
@ -659,7 +649,7 @@ public:
|
||||
type_result.type.type = &typeid(Functor);
|
||||
type_result.type.const_qualified = true;
|
||||
type_result.type.volatile_qualified = is_volatile<Functor>::value;
|
||||
get_vtable()->manager(functor, type_result,
|
||||
vtable->manager(functor, type_result,
|
||||
detail::function::check_functor_type_tag);
|
||||
// GCC 2.95.3 gets the CV qualifiers wrong here, so we
|
||||
// can't do the static_cast that we should do.
|
||||
@ -705,15 +695,6 @@ public:
|
||||
#endif
|
||||
|
||||
public: // should be protected, but GCC 2.95.3 will fail to allow access
|
||||
detail::function::vtable_base* get_vtable() const {
|
||||
return reinterpret_cast<detail::function::vtable_base*>(
|
||||
reinterpret_cast<std::size_t>(vtable) & ~(std::size_t)0x01);
|
||||
}
|
||||
|
||||
bool has_trivial_copy_and_destroy() const {
|
||||
return reinterpret_cast<std::size_t>(vtable) & 0x01;
|
||||
}
|
||||
|
||||
detail::function::vtable_base* vtable;
|
||||
mutable detail::function::function_buffer functor;
|
||||
};
|
||||
|
@ -21,7 +21,7 @@ namespace boost { namespace python { namespace objects {
|
||||
|
||||
#if defined (BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION) \
|
||||
|| defined(BOOST_BCB_PARTIAL_SPECIALIZATION_BUG) \
|
||||
|| !(defined(BOOST_STRICT_CONFIG) || !defined(__SUNPRO_CC) || __SUNPRO_CC > 0x540)
|
||||
|| !(BOOST_STRICT_CONFIG || !defined(__SUNPRO_CC) || __SUNPRO_CC > 0x540)
|
||||
# define BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX
|
||||
#endif
|
||||
|
||||
|
@ -53,20 +53,12 @@
|
||||
BOOST_JOIN(function_ref_invoker,BOOST_FUNCTION_NUM_ARGS)
|
||||
#define BOOST_FUNCTION_VOID_FUNCTION_REF_INVOKER \
|
||||
BOOST_JOIN(void_function_ref_invoker,BOOST_FUNCTION_NUM_ARGS)
|
||||
#define BOOST_FUNCTION_MEMBER_INVOKER \
|
||||
BOOST_JOIN(function_mem_invoker,BOOST_FUNCTION_NUM_ARGS)
|
||||
#define BOOST_FUNCTION_VOID_MEMBER_INVOKER \
|
||||
BOOST_JOIN(function_void_mem_invoker,BOOST_FUNCTION_NUM_ARGS)
|
||||
#define BOOST_FUNCTION_GET_FUNCTION_INVOKER \
|
||||
BOOST_JOIN(get_function_invoker,BOOST_FUNCTION_NUM_ARGS)
|
||||
#define BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER \
|
||||
BOOST_JOIN(get_function_obj_invoker,BOOST_FUNCTION_NUM_ARGS)
|
||||
#define BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER \
|
||||
BOOST_JOIN(get_function_ref_invoker,BOOST_FUNCTION_NUM_ARGS)
|
||||
#define BOOST_FUNCTION_GET_MEMBER_INVOKER \
|
||||
BOOST_JOIN(get_member_invoker,BOOST_FUNCTION_NUM_ARGS)
|
||||
#define BOOST_FUNCTION_GET_INVOKER \
|
||||
BOOST_JOIN(get_invoker,BOOST_FUNCTION_NUM_ARGS)
|
||||
#define BOOST_FUNCTION_VTABLE BOOST_JOIN(basic_vtable,BOOST_FUNCTION_NUM_ARGS)
|
||||
|
||||
#ifndef BOOST_NO_VOID_RETURNS
|
||||
@ -188,44 +180,6 @@ namespace boost {
|
||||
}
|
||||
};
|
||||
|
||||
#if BOOST_FUNCTION_NUM_ARGS > 0
|
||||
/* Handle invocation of member pointers. */
|
||||
template<
|
||||
typename MemberPtr,
|
||||
typename R BOOST_FUNCTION_COMMA
|
||||
BOOST_FUNCTION_TEMPLATE_PARMS
|
||||
>
|
||||
struct BOOST_FUNCTION_MEMBER_INVOKER
|
||||
{
|
||||
static R invoke(function_buffer& function_obj_ptr BOOST_FUNCTION_COMMA
|
||||
BOOST_FUNCTION_PARMS)
|
||||
|
||||
{
|
||||
MemberPtr* f =
|
||||
reinterpret_cast<MemberPtr*>(&function_obj_ptr.data);
|
||||
return boost::mem_fn(*f)(BOOST_FUNCTION_ARGS);
|
||||
}
|
||||
};
|
||||
|
||||
template<
|
||||
typename MemberPtr,
|
||||
typename R BOOST_FUNCTION_COMMA
|
||||
BOOST_FUNCTION_TEMPLATE_PARMS
|
||||
>
|
||||
struct BOOST_FUNCTION_VOID_MEMBER_INVOKER
|
||||
{
|
||||
static BOOST_FUNCTION_VOID_RETURN_TYPE
|
||||
invoke(function_buffer& function_obj_ptr BOOST_FUNCTION_COMMA
|
||||
BOOST_FUNCTION_PARMS)
|
||||
|
||||
{
|
||||
MemberPtr* f =
|
||||
reinterpret_cast<MemberPtr*>(&function_obj_ptr.data);
|
||||
BOOST_FUNCTION_RETURN(boost::mem_fn(*f)(BOOST_FUNCTION_ARGS));
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
template<
|
||||
typename FunctionPtr,
|
||||
typename R BOOST_FUNCTION_COMMA
|
||||
@ -289,190 +243,11 @@ namespace boost {
|
||||
>::type type;
|
||||
};
|
||||
|
||||
#if BOOST_FUNCTION_NUM_ARGS > 0
|
||||
/* Retrieve the appropriate invoker for a member pointer. */
|
||||
template<
|
||||
typename MemberPtr,
|
||||
typename R BOOST_FUNCTION_COMMA
|
||||
BOOST_FUNCTION_TEMPLATE_PARMS
|
||||
>
|
||||
struct BOOST_FUNCTION_GET_MEMBER_INVOKER
|
||||
{
|
||||
typedef typename mpl::if_c<(is_void<R>::value),
|
||||
BOOST_FUNCTION_VOID_MEMBER_INVOKER<
|
||||
MemberPtr,
|
||||
R BOOST_FUNCTION_COMMA
|
||||
BOOST_FUNCTION_TEMPLATE_ARGS
|
||||
>,
|
||||
BOOST_FUNCTION_MEMBER_INVOKER<
|
||||
MemberPtr,
|
||||
R BOOST_FUNCTION_COMMA
|
||||
BOOST_FUNCTION_TEMPLATE_ARGS
|
||||
>
|
||||
>::type type;
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Given the tag returned by get_function_tag, retrieve the
|
||||
actual invoker that will be used for the given function
|
||||
object.
|
||||
|
||||
Each specialization contains an "apply" nested class template
|
||||
that accepts the function object, return type, function
|
||||
argument types, and allocator. The resulting "apply" class
|
||||
contains two typedefs, "invoker_type" and "manager_type",
|
||||
which correspond to the invoker and manager types. */
|
||||
template<typename Tag>
|
||||
struct BOOST_FUNCTION_GET_INVOKER { };
|
||||
|
||||
/* Retrieve the invoker for a function pointer. */
|
||||
template<>
|
||||
struct BOOST_FUNCTION_GET_INVOKER<function_ptr_tag>
|
||||
{
|
||||
template<typename FunctionPtr,
|
||||
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
|
||||
struct apply
|
||||
{
|
||||
typedef typename BOOST_FUNCTION_GET_FUNCTION_INVOKER<
|
||||
FunctionPtr,
|
||||
R BOOST_FUNCTION_COMMA
|
||||
BOOST_FUNCTION_TEMPLATE_ARGS
|
||||
>::type
|
||||
invoker_type;
|
||||
|
||||
typedef functor_manager<FunctionPtr> manager_type;
|
||||
};
|
||||
|
||||
template<typename FunctionPtr,
|
||||
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
|
||||
typename Allocator>
|
||||
struct apply_a
|
||||
{
|
||||
typedef typename BOOST_FUNCTION_GET_FUNCTION_INVOKER<
|
||||
FunctionPtr,
|
||||
R BOOST_FUNCTION_COMMA
|
||||
BOOST_FUNCTION_TEMPLATE_ARGS
|
||||
>::type
|
||||
invoker_type;
|
||||
|
||||
typedef functor_manager<FunctionPtr> manager_type;
|
||||
};
|
||||
};
|
||||
|
||||
#if BOOST_FUNCTION_NUM_ARGS > 0
|
||||
/* Retrieve the invoker for a member pointer. */
|
||||
template<>
|
||||
struct BOOST_FUNCTION_GET_INVOKER<member_ptr_tag>
|
||||
{
|
||||
template<typename MemberPtr,
|
||||
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
|
||||
struct apply
|
||||
{
|
||||
typedef typename BOOST_FUNCTION_GET_MEMBER_INVOKER<
|
||||
MemberPtr,
|
||||
R BOOST_FUNCTION_COMMA
|
||||
BOOST_FUNCTION_TEMPLATE_ARGS
|
||||
>::type
|
||||
invoker_type;
|
||||
|
||||
typedef functor_manager<MemberPtr> manager_type;
|
||||
};
|
||||
|
||||
template<typename MemberPtr,
|
||||
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
|
||||
typename Allocator>
|
||||
struct apply_a
|
||||
{
|
||||
typedef typename BOOST_FUNCTION_GET_MEMBER_INVOKER<
|
||||
MemberPtr,
|
||||
R BOOST_FUNCTION_COMMA
|
||||
BOOST_FUNCTION_TEMPLATE_ARGS
|
||||
>::type
|
||||
invoker_type;
|
||||
|
||||
typedef functor_manager<MemberPtr> manager_type;
|
||||
};
|
||||
};
|
||||
#endif
|
||||
|
||||
/* Retrieve the invoker for a function object. */
|
||||
template<>
|
||||
struct BOOST_FUNCTION_GET_INVOKER<function_obj_tag>
|
||||
{
|
||||
template<typename FunctionObj,
|
||||
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
|
||||
struct apply
|
||||
{
|
||||
typedef typename BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER<
|
||||
FunctionObj,
|
||||
R BOOST_FUNCTION_COMMA
|
||||
BOOST_FUNCTION_TEMPLATE_ARGS
|
||||
>::type
|
||||
invoker_type;
|
||||
|
||||
typedef functor_manager<FunctionObj> manager_type;
|
||||
};
|
||||
|
||||
template<typename FunctionObj,
|
||||
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
|
||||
typename Allocator>
|
||||
struct apply_a
|
||||
{
|
||||
typedef typename BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER<
|
||||
FunctionObj,
|
||||
R BOOST_FUNCTION_COMMA
|
||||
BOOST_FUNCTION_TEMPLATE_ARGS
|
||||
>::type
|
||||
invoker_type;
|
||||
|
||||
typedef functor_manager_a<FunctionObj, Allocator> manager_type;
|
||||
};
|
||||
};
|
||||
|
||||
/* Retrieve the invoker for a reference to a function object. */
|
||||
template<>
|
||||
struct BOOST_FUNCTION_GET_INVOKER<function_obj_ref_tag>
|
||||
{
|
||||
template<typename RefWrapper,
|
||||
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
|
||||
struct apply
|
||||
{
|
||||
typedef typename BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER<
|
||||
typename RefWrapper::type,
|
||||
R BOOST_FUNCTION_COMMA
|
||||
BOOST_FUNCTION_TEMPLATE_ARGS
|
||||
>::type
|
||||
invoker_type;
|
||||
|
||||
typedef reference_manager<typename RefWrapper::type> manager_type;
|
||||
};
|
||||
|
||||
template<typename RefWrapper,
|
||||
typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS,
|
||||
typename Allocator>
|
||||
struct apply_a
|
||||
{
|
||||
typedef typename BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER<
|
||||
typename RefWrapper::type,
|
||||
R BOOST_FUNCTION_COMMA
|
||||
BOOST_FUNCTION_TEMPLATE_ARGS
|
||||
>::type
|
||||
invoker_type;
|
||||
|
||||
typedef reference_manager<typename RefWrapper::type> manager_type;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* vtable for a specific boost::function instance. This
|
||||
* structure must be an aggregate so that we can use static
|
||||
* initialization in boost::function's assign_to and assign_to_a
|
||||
* members. It therefore cannot have any constructors,
|
||||
* destructors, base classes, etc.
|
||||
* vtable for a specific boost::function instance.
|
||||
*/
|
||||
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
|
||||
struct BOOST_FUNCTION_VTABLE
|
||||
struct BOOST_FUNCTION_VTABLE : vtable_base
|
||||
{
|
||||
#ifndef BOOST_NO_VOID_RETURNS
|
||||
typedef R result_type;
|
||||
@ -484,6 +259,17 @@ namespace boost {
|
||||
BOOST_FUNCTION_COMMA
|
||||
BOOST_FUNCTION_TEMPLATE_ARGS);
|
||||
|
||||
template<typename F>
|
||||
BOOST_FUNCTION_VTABLE(F f) : vtable_base(), invoker(0)
|
||||
{
|
||||
init(f);
|
||||
}
|
||||
template<typename F,typename Allocator>
|
||||
BOOST_FUNCTION_VTABLE(F f, Allocator) : vtable_base(), invoker(0)
|
||||
{
|
||||
init_a<Allocator>(f);
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
bool assign_to(F f, function_buffer& functor)
|
||||
{
|
||||
@ -499,12 +285,52 @@ namespace boost {
|
||||
|
||||
void clear(function_buffer& functor)
|
||||
{
|
||||
if (base.manager)
|
||||
base.manager(functor, functor, destroy_functor_tag);
|
||||
if (manager)
|
||||
manager(functor, functor, destroy_functor_tag);
|
||||
}
|
||||
|
||||
private:
|
||||
template<typename F>
|
||||
void init(F f)
|
||||
{
|
||||
typedef typename get_function_tag<F>::type tag;
|
||||
init(f, tag());
|
||||
}
|
||||
template<typename Allocator,typename F>
|
||||
void init_a(F f)
|
||||
{
|
||||
typedef typename get_function_tag<F>::type tag;
|
||||
init_a<Allocator>(f, tag());
|
||||
}
|
||||
|
||||
// Function pointers
|
||||
template<typename FunctionPtr>
|
||||
void init(FunctionPtr /*f*/, function_ptr_tag)
|
||||
{
|
||||
typedef typename BOOST_FUNCTION_GET_FUNCTION_INVOKER<
|
||||
FunctionPtr,
|
||||
R BOOST_FUNCTION_COMMA
|
||||
BOOST_FUNCTION_TEMPLATE_ARGS
|
||||
>::type
|
||||
actual_invoker_type;
|
||||
|
||||
invoker = &actual_invoker_type::invoke;
|
||||
manager = &functor_manager<FunctionPtr>::manage;
|
||||
}
|
||||
template<typename Allocator,typename FunctionPtr>
|
||||
void init_a(FunctionPtr f, function_ptr_tag)
|
||||
{
|
||||
typedef typename BOOST_FUNCTION_GET_FUNCTION_INVOKER<
|
||||
FunctionPtr,
|
||||
R BOOST_FUNCTION_COMMA
|
||||
BOOST_FUNCTION_TEMPLATE_ARGS
|
||||
>::type
|
||||
actual_invoker_type;
|
||||
|
||||
invoker = &actual_invoker_type::invoke;
|
||||
manager = &functor_manager_a<FunctionPtr, Allocator>::manage;
|
||||
}
|
||||
|
||||
template<typename FunctionPtr>
|
||||
bool
|
||||
assign_to(FunctionPtr f, function_buffer& functor, function_ptr_tag)
|
||||
@ -528,6 +354,23 @@ namespace boost {
|
||||
|
||||
// Member pointers
|
||||
#if BOOST_FUNCTION_NUM_ARGS > 0
|
||||
template<typename MemberPtr>
|
||||
void init(MemberPtr f, member_ptr_tag)
|
||||
{
|
||||
// DPG TBD: Add explicit support for member function
|
||||
// objects, so we invoke through mem_fn() but we retain the
|
||||
// right target_type() values.
|
||||
this->init(mem_fn(f));
|
||||
}
|
||||
template<typename Allocator,typename MemberPtr>
|
||||
void init_a(MemberPtr f, member_ptr_tag)
|
||||
{
|
||||
// DPG TBD: Add explicit support for member function
|
||||
// objects, so we invoke through mem_fn() but we retain the
|
||||
// right target_type() values.
|
||||
this->init_a<Allocator>(mem_fn(f));
|
||||
}
|
||||
|
||||
template<typename MemberPtr>
|
||||
bool assign_to(MemberPtr f, function_buffer& functor, member_ptr_tag)
|
||||
{
|
||||
@ -557,6 +400,33 @@ namespace boost {
|
||||
#endif // BOOST_FUNCTION_NUM_ARGS > 0
|
||||
|
||||
// Function objects
|
||||
template<typename FunctionObj>
|
||||
void init(FunctionObj /*f*/, function_obj_tag)
|
||||
{
|
||||
typedef typename BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER<
|
||||
FunctionObj,
|
||||
R BOOST_FUNCTION_COMMA
|
||||
BOOST_FUNCTION_TEMPLATE_ARGS
|
||||
>::type
|
||||
actual_invoker_type;
|
||||
|
||||
invoker = &actual_invoker_type::invoke;
|
||||
manager = &functor_manager<FunctionObj>::manage;
|
||||
}
|
||||
template<typename Allocator,typename FunctionObj>
|
||||
void init_a(FunctionObj /*f*/, function_obj_tag)
|
||||
{
|
||||
typedef typename BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER<
|
||||
FunctionObj,
|
||||
R BOOST_FUNCTION_COMMA
|
||||
BOOST_FUNCTION_TEMPLATE_ARGS
|
||||
>::type
|
||||
actual_invoker_type;
|
||||
|
||||
invoker = &actual_invoker_type::invoke;
|
||||
manager = &functor_manager_a<FunctionObj, Allocator>::manage;
|
||||
}
|
||||
|
||||
// Assign to a function object using the small object optimization
|
||||
template<typename FunctionObj>
|
||||
void
|
||||
@ -619,6 +489,27 @@ namespace boost {
|
||||
}
|
||||
|
||||
// Reference to a function object
|
||||
template<typename FunctionObj>
|
||||
void
|
||||
init(const reference_wrapper<FunctionObj>& /*f*/, function_obj_ref_tag)
|
||||
{
|
||||
typedef typename BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER<
|
||||
FunctionObj,
|
||||
R BOOST_FUNCTION_COMMA
|
||||
BOOST_FUNCTION_TEMPLATE_ARGS
|
||||
>::type
|
||||
actual_invoker_type;
|
||||
|
||||
invoker = &actual_invoker_type::invoke;
|
||||
manager = &reference_manager<FunctionObj>::get;
|
||||
}
|
||||
template<typename Allocator,typename FunctionObj>
|
||||
void
|
||||
init_a(const reference_wrapper<FunctionObj>& f, function_obj_ref_tag)
|
||||
{
|
||||
init(f,function_obj_ref_tag());
|
||||
}
|
||||
|
||||
template<typename FunctionObj>
|
||||
bool
|
||||
assign_to(const reference_wrapper<FunctionObj>& f,
|
||||
@ -642,7 +533,6 @@ namespace boost {
|
||||
}
|
||||
|
||||
public:
|
||||
vtable_base base;
|
||||
invoker_type invoker;
|
||||
};
|
||||
} // end namespace function
|
||||
@ -678,11 +568,6 @@ namespace boost {
|
||||
R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_ARGS>
|
||||
vtable_type;
|
||||
|
||||
vtable_type* get_vtable() const {
|
||||
return reinterpret_cast<vtable_type*>(
|
||||
reinterpret_cast<std::size_t>(vtable) & ~(std::size_t)0x01);
|
||||
}
|
||||
|
||||
struct clear_type {};
|
||||
|
||||
public:
|
||||
@ -762,7 +647,7 @@ namespace boost {
|
||||
if (this->empty())
|
||||
boost::throw_exception(bad_function_call());
|
||||
|
||||
return get_vtable()->invoker
|
||||
return static_cast<vtable_type*>(vtable)->invoker
|
||||
(this->functor BOOST_FUNCTION_COMMA BOOST_FUNCTION_ARGS);
|
||||
}
|
||||
#else
|
||||
@ -852,8 +737,7 @@ namespace boost {
|
||||
void clear()
|
||||
{
|
||||
if (vtable) {
|
||||
if (!this->has_trivial_copy_and_destroy())
|
||||
get_vtable()->clear(this->functor);
|
||||
static_cast<vtable_type*>(vtable)->clear(this->functor);
|
||||
vtable = 0;
|
||||
}
|
||||
}
|
||||
@ -882,79 +766,24 @@ namespace boost {
|
||||
{
|
||||
if (!f.empty()) {
|
||||
this->vtable = f.vtable;
|
||||
if (this->has_trivial_copy_and_destroy())
|
||||
this->functor = f.functor;
|
||||
else
|
||||
get_vtable()->base.manager(f.functor, this->functor,
|
||||
boost::detail::function::clone_functor_tag);
|
||||
f.vtable->manager(f.functor, this->functor,
|
||||
boost::detail::function::clone_functor_tag);
|
||||
}
|
||||
}
|
||||
|
||||
template<typename Functor>
|
||||
void assign_to(Functor f)
|
||||
{
|
||||
using detail::function::vtable_base;
|
||||
|
||||
typedef typename detail::function::get_function_tag<Functor>::type tag;
|
||||
typedef detail::function::BOOST_FUNCTION_GET_INVOKER<tag> get_invoker;
|
||||
typedef typename get_invoker::
|
||||
template apply<Functor, R BOOST_FUNCTION_COMMA
|
||||
BOOST_FUNCTION_TEMPLATE_ARGS>
|
||||
handler_type;
|
||||
|
||||
typedef typename handler_type::invoker_type invoker_type;
|
||||
typedef typename handler_type::manager_type manager_type;
|
||||
|
||||
// Note: it is extremely important that this initialization use
|
||||
// static initialization. Otherwise, we will have a race
|
||||
// condition here in multi-threaded code. See
|
||||
// http://thread.gmane.org/gmane.comp.lib.boost.devel/164902/.
|
||||
static vtable_type stored_vtable =
|
||||
{ { &manager_type::manage }, &invoker_type::invoke };
|
||||
|
||||
if (stored_vtable.assign_to(f, functor)) {
|
||||
std::size_t value = reinterpret_cast<std::size_t>(&stored_vtable.base);
|
||||
if (boost::has_trivial_copy_constructor<Functor>::value &&
|
||||
boost::has_trivial_destructor<Functor>::value &&
|
||||
detail::function::function_allows_small_object_optimization<Functor>::value)
|
||||
value |= (std::size_t)0x01;
|
||||
vtable = reinterpret_cast<detail::function::vtable_base *>(value);
|
||||
} else
|
||||
vtable = 0;
|
||||
static vtable_type stored_vtable(f);
|
||||
if (stored_vtable.assign_to(f, functor)) vtable = &stored_vtable;
|
||||
else vtable = 0;
|
||||
}
|
||||
|
||||
template<typename Functor,typename Allocator>
|
||||
void assign_to_a(Functor f,Allocator a)
|
||||
{
|
||||
using detail::function::vtable_base;
|
||||
|
||||
typedef typename detail::function::get_function_tag<Functor>::type tag;
|
||||
typedef 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>
|
||||
handler_type;
|
||||
|
||||
typedef typename handler_type::invoker_type invoker_type;
|
||||
typedef typename handler_type::manager_type manager_type;
|
||||
|
||||
// Note: it is extremely important that this initialization use
|
||||
// static initialization. Otherwise, we will have a race
|
||||
// condition here in multi-threaded code. See
|
||||
// http://thread.gmane.org/gmane.comp.lib.boost.devel/164902/.
|
||||
static vtable_type stored_vtable =
|
||||
{ { &manager_type::manage }, &invoker_type::invoke };
|
||||
|
||||
if (stored_vtable.assign_to_a(f, functor, a)) {
|
||||
std::size_t value = reinterpret_cast<std::size_t>(&stored_vtable.base);
|
||||
if (boost::has_trivial_copy_constructor<Functor>::value &&
|
||||
boost::has_trivial_destructor<Functor>::value &&
|
||||
detail::function::function_allows_small_object_optimization<Functor>::value)
|
||||
value |= (std::size_t)0x01;
|
||||
vtable = reinterpret_cast<detail::function::vtable_base *>(value);
|
||||
} else
|
||||
vtable = 0;
|
||||
static vtable_type stored_vtable(f,a);
|
||||
if (stored_vtable.assign_to_a(f, functor, a)) vtable = &stored_vtable;
|
||||
else vtable = 0;
|
||||
}
|
||||
|
||||
// Moves the value from the specified argument to *this. If the argument
|
||||
@ -970,16 +799,13 @@ namespace boost {
|
||||
#endif
|
||||
if (!f.empty()) {
|
||||
this->vtable = f.vtable;
|
||||
if (this->has_trivial_copy_and_destroy())
|
||||
this->functor = f.functor;
|
||||
else
|
||||
get_vtable()->base.manager(f.functor, this->functor,
|
||||
boost::detail::function::move_functor_tag);
|
||||
f.vtable = 0;
|
||||
f.vtable->manager(f.functor, this->functor,
|
||||
boost::detail::function::move_functor_tag);
|
||||
f.vtable = 0;
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
} else {
|
||||
clear();
|
||||
}
|
||||
#if !defined(BOOST_NO_EXCEPTIONS)
|
||||
} catch (...) {
|
||||
vtable = 0;
|
||||
throw;
|
||||
@ -1005,14 +831,13 @@ namespace boost {
|
||||
template<typename R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_PARMS>
|
||||
typename BOOST_FUNCTION_FUNCTION<
|
||||
R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_ARGS>::result_type
|
||||
inline
|
||||
BOOST_FUNCTION_FUNCTION<R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_ARGS>
|
||||
BOOST_FUNCTION_FUNCTION<R BOOST_FUNCTION_COMMA BOOST_FUNCTION_TEMPLATE_ARGS>
|
||||
::operator()(BOOST_FUNCTION_PARMS) const
|
||||
{
|
||||
if (this->empty())
|
||||
boost::throw_exception(bad_function_call());
|
||||
|
||||
return get_vtable()->invoker
|
||||
return static_cast<vtable_type*>(vtable)->invoker
|
||||
(this->functor BOOST_FUNCTION_COMMA BOOST_FUNCTION_ARGS);
|
||||
}
|
||||
#endif
|
||||
@ -1139,13 +964,10 @@ public:
|
||||
#undef BOOST_FUNCTION_VOID_FUNCTION_OBJ_INVOKER
|
||||
#undef BOOST_FUNCTION_FUNCTION_REF_INVOKER
|
||||
#undef BOOST_FUNCTION_VOID_FUNCTION_REF_INVOKER
|
||||
#undef BOOST_FUNCTION_MEMBER_INVOKER
|
||||
#undef BOOST_FUNCTION_VOID_MEMBER_INVOKER
|
||||
#undef BOOST_FUNCTION_GET_FUNCTION_INVOKER
|
||||
#undef BOOST_FUNCTION_GET_FUNCTION_OBJ_INVOKER
|
||||
#undef BOOST_FUNCTION_GET_FUNCTION_REF_INVOKER
|
||||
#undef BOOST_FUNCTION_GET_MEM_FUNCTION_INVOKER
|
||||
#undef BOOST_FUNCTION_GET_INVOKER
|
||||
#undef BOOST_FUNCTION_TEMPLATE_PARMS
|
||||
#undef BOOST_FUNCTION_TEMPLATE_ARGS
|
||||
#undef BOOST_FUNCTION_PARMS
|
||||
|
@ -1 +0,0 @@
|
||||
boost_module(function DEPENDS detail preprocessor utility)
|
@ -1,23 +0,0 @@
|
||||
boost_additional_test_dependencies(function BOOST_DEPENDS test lambda)
|
||||
|
||||
|
||||
boost_test_run(lib_function_test function_test.cpp)
|
||||
boost_test_run(function_n_test)
|
||||
boost_test_run(allocator_test)
|
||||
boost_test_run(stateless_test)
|
||||
boost_test_run(lambda_test)
|
||||
boost_test_compile_fail(function_test_fail1)
|
||||
boost_test_compile_fail(function_test_fail2)
|
||||
boost_test_compile(function_30)
|
||||
boost_test_run(function_arith_cxx98)
|
||||
boost_test_run(function_arith_portable)
|
||||
boost_test_run(sum_avg_cxx98)
|
||||
boost_test_run(sum_avg_portable)
|
||||
boost_test_run(mem_fun_cxx98)
|
||||
boost_test_run(mem_fun_portable)
|
||||
boost_test_run(std_bind_cxx98)
|
||||
boost_test_run(std_bind_portable)
|
||||
boost_test_run(function_ref_cxx98)
|
||||
boost_test_run(function_ref_portable)
|
||||
boost_test_run(contains_test)
|
||||
boost_test_run(contains2_test)
|
Reference in New Issue
Block a user