?????????????C++????????????????????????????????? ?????????д??????????е????к????? ??????Щ????????????????? ???????Щ???????????????????????????????????????????????????????£????????????????????????????Щ??????????????? ???????????????в???????????????

????????????????????

template<typename T?? unsigned B>
struct Base
{
    //other function
    //....
    void Func(){ cout << "primary function" << endl; }
};
void test1()
{
    Base<int?? 1> a;
    a.Func();
    Base<int?? 16> b;
    b.Func();
}
int main()
{
     test1();
}

??????е?B????16??? Func??????????????? ????????????????????????????????

????????????????Щ????????????

????????1??

template<typename T>
struct Base<T?? 16>
{
    //other function
    //....
    void Func(){ cout << "specialization function" << endl; }
};

??????????????????????????д???е???????????

????????2??

template<typename T?? unsigned B>
struct Base
{
    //other function
    //....
    void Func()
    {
        if(B == 16)
        {
            cout << "primary function" << endl;
        }
        else
        {
            cout << "specialization function" << endl;
        }
    }
};

???????????????????ж?????????????????Ч??

????????3??

template<typename T?? unsigned B>
struct Base
{
    //other function
    //....
    void Func()
    {
#if B!=16
            cout << "primary function" << endl;
#else
            cout << "specialization function" << endl;
#endif
    }
};

?????????????????????????????????????????????C++??????????????????飬???????????Σ???????????????????????????????