boost代码分析:is_const,is_reference

template <typename T> struct cv_traits_imp {};

template <typename T>
struct cv_traits_imp<T>
{
    static const bool is_const = false;
    static const bool is_volatile = false;
    typedef T unqualified_type;
};

template <typename T>
struct cv_traits_imp<const T
>
{
    static const bool is_const = true;
    static const bool is_volatile = false;
    typedef T unqualified_type;
};

template <typename T>
struct cv_traits_imp<volatile T>
{
    static const bool is_const = false;
    static const bool is_volatile = true;
    typedef T unqualified_type;
};

template <typename T>
struct cv_traits_imp<const volatile T
>
{
    static const bool is_const = true;
    static const bool is_volatile = true;
    typedef T unqualifiedtype;
};

template< int N > struct int
;

struct integral_ctag { static const int value = 0; };

template< int N >
struct int

{
    static const int value = N;

    typedef int_ type;

    typedef int value_type;
    typedef integral_ctag tag;

    typedef mpl
::int_< staticcast<int>((value + 1)) > next;
    typedef mpl
::int_< static_cast<int>((value - 1)) > prior;

    operator int() const { return staticcast<int>(this->value); }
};

template< int N >
int const mpl
::int< N >::value;

template< bool C
> struct bool;


typedef bool
<true> true;
typedef bool
<false> false;

template< bool C
> struct bool
{
    static const bool value = C
;
    typedef integral_ctag tag;
    typedef bool
type;
    typedef bool valuetype;
    operator bool() const { return this->value; }
};


template< bool C
>
bool const bool<C>::value;

template< typename T, T N > struct integral_c;

template< typename T, T N >
struct integral_c
{
    static const T value = N;

    typedef integral_c type;

    typedef T value_type;
    typedef integral_c_tag tag;

    typedef integral_c< T, static_cast<T>((value + 1)) > next;
    typedef integral_c< T, static_cast<T>((value - 1)) > prior;

    operator T() const { return static_cast<T>(this->value); }
};


template< typename T, T N >
T const integral_c< T, N >::value;

template< bool C >
struct integral_c<bool, C>
{
    static const bool value = C;
    typedef integral_c_tag tag;
    typedef integral_c type;
    typedef bool value_type;
    operator bool() const { return this->value; }
};

template <class T, T val>

struct integral_constant : public mpl::integral_c<T, val>
{
   typedef integral_constant<T,val> type;
};

template<> struct integralconstant<bool,true> : public mpl::true
{
   typedef integral_constant<bool,true> type;
};
template<> struct integralconstant<bool,false> : public mpl::false
{
   typedef integral_constant<bool,false> type;
};

typedef integral_constant<bool,true> true_type;
typedef integral_constant<bool,false> false_type;

template< typename T > struct is_reference : ::boost::integral_constant<bool,false> { };
template< typename T > struct is_reference< T& > : ::boost::integral_constant<bool,true> { };

   template< typename T > struct is_const : ::boost::integral_constant<bool,::boost::detail::cv_traits_imp<T*>::is_const> { };

template< typename T > struct is_const< T& > : ::boost::integral_constant<bool,false> { };