is_member_pointer<T>来判断类型是否是类成员指针,具体参见boost代码

BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_member_pointer,T,::boost::is_member_function_pointer<T>::value)
BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,typename U,is_member_pointer,U T::*,true)
BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,typename U,is_member_pointer,U T::*const,true)
BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,typename U,is_member_pointer,U T::*volatile,true)
BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,typename U,is_member_pointer,U T::*const volatile,true)

宏张开后
--------------------------------------------------------------------------
//BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_member_pointer,T,::boost::is_member_function_pointer<T>::value)
//1.
template< typename T > struct is_member_pointer
BOOST_TT_AUX_BOOL_C_BASE(::boost::is_member_function_pointer<T>::value)
{
public:
BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(::boost::is_member_function_pointer<T>::value)
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_member_pointer,(T))
};

BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1,is_member_pointer)

--------------------------------------------------------------------------
//#define BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(param1,param2,trait,sp,C)
//2.
template< typename T, typename U> struct is_member_pointer<U T::*>
BOOST_TT_AUX_BOOL_C_BASE(true)
{
public:
BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(true)
};
-------------------------------------------------------------------------
//BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,typename U,is_member_pointer,U T::*const,true)
//3.
template< typename T, typename U> struct is_member_pointer<U T::*const>
BOOST_TT_AUX_BOOL_C_BASE(true)
{
public:
BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(true)
};
-------------------------------------------------------------------------
//BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,typename U,is_member_pointer,U T::*volatile,true)
//4.
template< typename T, typename U> struct is_member_pointer<U T::*volatile>
BOOST_TT_AUX_BOOL_C_BASE(true)
{
public:
BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(true)
};
---------------------------------------------------------------------------
//BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(typename T,typename U,is_member_pointer,U T::*const volatile,true)
//5.
template< typename T, typename U> struct is_member_pointerU T::*const volatile>
BOOST_TT_AUX_BOOL_C_BASE(true)
{
public:
BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(true)
};
---------------------------------------------------------------------------
先来分析2-5,它们是1的特化版本,分别针对U T::*, U T::*const, U T::*volatile, U T::*const volatile,T表示类U的函数
指针(const,volatile, const volatile),因为这些指针都是成员函数指针,所以is_member_pointer::value总是为一的,
其中BOOST_TT_AUX_BOOL_C_BASE展开为
public ::boost::integral_constant<bool,C>
BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL展开为
#ifndef BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL
# define BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C)
#endif
则2,展开为
template< typename T, typename U> struct is_member_pointer<U T::*>
public ::boost::integral_constant<bool,true>
{
public:
};
其中::boost::integral_constant<bool,true>定义
template <class T, T val>
struct integral_constant : public mpl::integral_c<T, val>
{
typedef integral_constant<T,val> type;
};
template< typename T, T N > struct integral_c;

template<> struct integral_constant<bool,true> : public mpl::true_
{
typedef integral_constant<bool,true> type;
};
template<> struct integral_constant<bool,false> : public mpl::false_
{
typedef integral_constant<bool,false> type;
};
mpl::true_, mpl::false_如下
template< bool C_ > struct bool_;
// shorcuts
typedef bool_<true> true_;
typedef bool_<false> false_;
//mpl/bool.hpp
template< bool C_ > struct bool_
{
BOOST_STATIC_CONSTANT(bool, value = C_);
typedef integral_c_tag tag;
typedef bool_ type;
typedef bool value_type;
operator bool() const { return this->value; }
};

template< bool C_ >
bool const bool_<C_>::value;
============================================================================
看看范型is_member_function_pointer的实现 (1),BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL
忽略, BOOST_MPL_AUX_LAMBDA_SUPPORT也没有意义,展开宏BOOST_TT_AUX_BOOL_C_BASE得
template< typename T > struct is_member_pointer :
public ::boost::integral_constant<bool,::boost::is_member_function_pointer<T>::value>
{
public:
};
回忆之前integral_constant<bool,C>的分析,那这里的关键就剩下::boost::is_member_function_pointer<T>::value,
如果该值为true,那is_member_pointer::value就为true,否则,就为false
)
BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_member_function_pointer,T,::boost::detail::is_member_function_pointer_impl<T>::value)
展开
template< typename T > struct is_member_function_pointer
BOOST_TT_AUX_BOOL_C_BASE(::boost::detail::is_member_function_pointer_impl<T>::value)
{
public:
BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(::boost::detail::is_member_function_pointer_impl<T>::value)
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_member_function_pointer,(T))
};
BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1,is_member_function_pointer)
-------------------------------------------------------------
BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(1,is_member_function_pointer) 忽略,
BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_member_function_pointer,(T)) 忽略
BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(::boost::detail::is_member_function_pointer_impl<T>::value)忽略
展开BOOST_TT_AUX_BOOL_C_BASE(::boost::detail::is_member_function_pointer_impl<T>::value)
template< typename T > struct is_member_function_pointer
: public ::boost::integral_constant<bool, ::boost::detail::is_member_function_pointer_impl<T>::value>
{
public:
};
-------------------------------------------------------------
又是::boost::integral_constant<bool,xxx::value>继续分析::boost::detail::is_member_function_pointer_impl<T>::value,
先来看看这几个宏,这是针对void,void const系列的is_member_function_pointer_impl特化版本
BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_member_function_pointer,void,false)
BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_member_function_pointer,void const,false)
BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_member_function_pointer,void volatile,false)
BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_member_function_pointer,void const volatile,false
//BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_member_function_pointer,void,false)
//1.
template<> struct is_member_function_pointer_impl< void >
{
public:
BOOST_STATIC_CONSTANT(bool, value = (false));
};
//BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_member_function_pointer,void const,false)
//2.
template<> struct is_member_function_pointer_impl< void const >
{
public:
BOOST_STATIC_CONSTANT(bool, value = (false));
};
//BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_member_function_pointer,void volatile,false)
//3.
template<> struct is_member_function_pointer_impl< void volatile >
{
public:
BOOST_STATIC_CONSTANT(bool, value = (false));
};
//BOOST_TT_AUX_BOOL_TRAIT_IMPL_SPEC1(is_member_function_pointer,void const volatile,false)
//4.
template<> struct is_member_function_pointer_impl< void const volatile >
{
public:
BOOST_STATIC_CONSTANT(bool, value = (false));
};
接下来,继续看看is_member_function_pointer_impl的范型版本
template <typename T>
struct is_member_function_pointer_impl
: public is_mem_fun_pointer_select<
::boost::type_traits::ice_or<
::boost::is_reference<T>::value
, ::boost::is_array<T>::value
>::value
>::template result_<T>
{
};
----------------------------------------------------------------------------------------------
如果T为reference或array,则boost::type_traits::ice_or<>::value=true, 否则为false,
template <bool b1, bool b2, bool b3 = false, bool b4 = false, bool b5 = false, bool b6 = false, bool b7 = false>
struct ice_or;
template <bool b1, bool b2, bool b3, bool b4, bool b5, bool b6, bool b7>
struct ice_or
{
BOOST_STATIC_CONSTANT(bool, value = true);
};

template <>
struct ice_or<false, false, false, false, false, false, false>
{
BOOST_STATIC_CONSTANT(bool, value = false);
};

----------------------------------------------------------------------------------------------
如果ice_or<>::value为true,则is_mem_fun_pointer_select<>::template result_<T>为false_result::result_,
这时is_member_function_pointer_impl<>::value 也为false
struct is_mem_fun_pointer_select
: public ::boost::type_traits::false_result
{
};
struct false_result
{
template <typename T> struct result_
{
BOOST_STATIC_CONSTANT(bool, value = false);
};
};

------------------------------------------------------------------------------------------------
否则,ice_or<>::value为false,is_mem_fun_pointer_select<>::template result_<T>为is_mem_fun_pointer_select<>::result_,
template <>
struct is_mem_fun_pointer_select<false>
{
template <typename T> struct result_
{
static T* make_t;
typedef result_<T> self_type;

BOOST_STATIC_CONSTANT(
bool, value = (
1 == sizeof(::boost::type_traits::is_mem_fun_pointer_tester(self_type::make_t))
));
};
};
::boost::type_traits::is_mem_fun_pointer_tester::value就由is_member_function_pointer_impl<>::value
来表达
至于::boost::type_traits::is_mem_fun_pointer_tester的实现,则是由一系列is_mem_fun_pointer_tester.hpp
里的模板函数的返回值(yes_type)来完成的