最开始接触C#的时候,知道C#、lua这些语言是支持反射的语言,就是可以在编译时知道对象的类型。
今天看了模板特化和偏特化,知道在C++里面实际上又可以通过模板来实现类型在编译时的判断。
template < class T>
struct is_Int...{
static const bool value = false;
};
template<>
struct is_Int<int>...{
static const bool value = true;
};
template<class T>
void Is_int(T param)
...{
if(is_Int(param))
//do sth.
}
以前并不知道,原来C++的模板也是可以这样用的,学到了……orz
280





