??C++????????????????????????????
???????????? ???????[ 2013/4/24 10:02:45 ] ????????
????????4??
template<typename T?? unsigned B>
struct Base
{
//other function
//....
template<unsigned S>
struct FuncObj
{
void operator()()
{
cout<<"primary function"<<endl;
}
};
template<>
struct FuncObj<16>
{
void operator()()
{
cout<<"specialization function"<<endl;
}
};
FuncObj<B> Func;
};
???????????????????????????????????????????????????
????????5??
template<typename T?? unsigned B>
struct Base
{
//other function
//....
template<unsigned N>
void FuncImpl()
{
cout<<"primary function"<<endl;
}
template<>
void FuncImpl<16>()
{
cout<<"specialization function"<<endl;
}
void Func()
{
FuncImpl<B>();
}
};
???????????????????庯???????????
????????6??
template<typename T?? unsigned B>
struct Base
{
//other function
//....
template<unsigned N>
class Int2Type
{
enum { value = N };
};
template<unsigned V>
void FuncImpl(const Int2Type<V>)
{
cout<<"primary function"<<endl;
}
void FuncImpl(const Int2Type<16>)
{
cout<<"specialization function"<<endl;
}
void Func()
{
FuncImpl(Int2Type<B>());
}
};
???????????????int???????????????????????????????????????
??????

???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11