forked from boostorg/function
function_base.hpp:
- Switch over to using is_reference_wrapper instead of homegrown is_ref - Identify stateless function objects function_template.hpp: - Optimize away construction/allocator for stateless function objects. [SVN r12559]
This commit is contained in:
@ -77,37 +77,6 @@ namespace boost {
|
||||
typedef typename select::template Result<Then,Else>::type type;
|
||||
};
|
||||
|
||||
// Determine if the incoming argument is a reference_wrapper
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
template<typename T>
|
||||
struct is_ref
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = false);
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
struct is_ref<reference_wrapper<T> >
|
||||
{
|
||||
BOOST_STATIC_CONSTANT(bool, value = true);
|
||||
};
|
||||
#else // no partial specialization
|
||||
typedef char yes_type;
|
||||
typedef double no_type;
|
||||
|
||||
no_type is_ref_tester(...);
|
||||
|
||||
template<typename T>
|
||||
yes_type is_ref_tester(reference_wrapper<T>*);
|
||||
|
||||
template<typename T>
|
||||
struct is_ref
|
||||
{
|
||||
static T* t;
|
||||
BOOST_STATIC_CONSTANT(bool,
|
||||
value = (sizeof(is_ref_tester(t)) == sizeof(yes_type)));
|
||||
};
|
||||
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
|
||||
/**
|
||||
* A union of a function pointer and a void pointer. This is necessary
|
||||
* because 5.2.10/6 allows reinterpret_cast<> to safely cast between
|
||||
@ -161,6 +130,7 @@ namespace boost {
|
||||
struct function_obj_tag {};
|
||||
struct member_ptr_tag {};
|
||||
struct function_obj_ref_tag {};
|
||||
struct stateless_function_obj_tag {};
|
||||
|
||||
template<typename F>
|
||||
class get_function_tag
|
||||
@ -172,10 +142,15 @@ namespace boost {
|
||||
typedef typename IF<(is_member_pointer<F>::value),
|
||||
member_ptr_tag,
|
||||
ptr_or_obj_tag>::type ptr_or_obj_or_mem_tag;
|
||||
public:
|
||||
typedef typename IF<(is_ref<F>::value),
|
||||
|
||||
typedef typename IF<(is_reference_wrapper<F>::value),
|
||||
function_obj_ref_tag,
|
||||
ptr_or_obj_or_mem_tag>::type type;
|
||||
ptr_or_obj_or_mem_tag>::type or_ref_tag;
|
||||
|
||||
public:
|
||||
typedef typename IF<(is_stateless<F>::value),
|
||||
stateless_function_obj_tag,
|
||||
or_ref_tag>::type type;
|
||||
};
|
||||
|
||||
// The trivial manager does nothing but return the same pointer (if we
|
||||
|
Reference in New Issue
Block a user