Program to implement the is_same_type type trait in c++
HI Could anyone give a sample program to implement the is_sa开发者_如何学JAVAme_type type trait in c++?
#include <iostream>
template< typename T1, typename T2 >
struct is_same_type { enum { result = false }; };
template< typename T>
struct is_same_type<T,T> { enum { result = true }; };
int main()
{
std::cout << is_same_type<int,float>::result << '\n'
<< is_same_type<char,char>::result << '\n';
return 0;
}
精彩评论