??????????????????????????????????????????????????????????????????е?????????????

template<typename T1?? typename T2>
struct Base
{
    //other function
    //....
    void Func(){ cout << "primary function" << endl; }
};
void test2()
{
    Base<int?? int> a;
    a.Func();
    Base<int?? string> b;
    b.Func();
}
int main()
{
    test2();
}

????????????????????T2 ??string?????????????Func??????д???????????????????????????????????

??????????????????????????飬???????????????????????

????????1??

template<typename T1?? typename T2>
struct Base
{
    //other function
    //....
    void Func()
    {
        if(typeid(std::string) == typeid(T2))
        {
            cout<<"specialization function"<<endl;
        }
        else
        {
            cout << "primary function" << endl;
        }
    }
};

?????????????????????????(RTTI)???????????????????????Ч??

????????2??

template<typename T1?? typename T2>
struct Base
{
    //other function
    //....
    template<typename T>
    void FuncImpl()
    {
        cout << "primary function" << endl;
    }
    template<>
    void FuncImpl<string>()
    {
        cout << "specialization function" << endl;
    }
    void Func()
    {
        FuncImpl<T2>();
    }
};

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

????????3??

template<typename T1?? typename T2>
struct Base
{
    //other function
    //....
    template<typename T>
    class Type2Type
    {
        typedef T type;
    };
    template<typename T>
    void FunImpl(const Type2Type<T>)
    {
        cout << "primary function" << endl;
    }
    template<typename T>
    void FunImpl(const Type2Type<string>)
    {
        cout << "specialization function" << endl;
    }
    void Func()
    {
        FunImpl<T2>(Type2Type<T2>());
    }
};