topameng's profileQuake3 启示录PhotosBlogListsMore Tools Help

Blog


    April 21

    is_integral 宏展开


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

    template< bool C_ > struct bool_
    {
        static const bool value = C_;
        typedef integral_c_tag tag;
        typedef bool_ type;
        typedef bool value_type;
        operator bool() const
        {
            return this->value;
        }
    };
    typedef bool_<true> true_;
    typedef bool_<false> false_;
    template< typename T, T N > struct integral_c;

    template <class T, T val>
    struct integral_constant: public integral_c<T, val>
    {
        typedef integral_constant<T,val> type;
    };
    template<> struct integral_constant<bool,false>: false_
    {
       typedef integral_constant<bool,false> type;
    };
    template<> struct integral_constant<bool,true>: true_
    {
        typedef integral_constant<bool,true> type;
    };

    template< typename T > struct is_integral : integral_constant<bool,false>   
    {
    };
    template<> struct is_integral<unsigned char> : integral_constant<bool,true>
    {
        /*BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(true) \
        BOOST_MPL_AUX_LAMBDA_SUPPORT_SPEC(1,is_integral,(unsigned char))
        */
    };
    BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_integral,unsigned char const,true)
    BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_integral,unsigned char volatile,true)
    BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_integral,unsigned char const volatile,true)