一段int外覆器的代码测试
#include <iostream>using namespace std;template<int N>struct int_{static const int value = N;typedef int_<N> type;typedef int value_type;typedef int_<N...
·
#include <iostream>
using namespace std;
template<int N>
struct int_
{
static const int value = N;
typedef int_<N> type;
typedef int value_type;
typedef int_<N + 1> next;
typedef int_<N - 1> prior;
operator int() const
{
return N;
}
};
int main()
{
cout << typeid(int_<6>::type).name() << endl;
cout << typeid(int_<6>::value_type).name() << endl;
cout << int_<6>::value << endl;
cout << int_<6>() << endl;
cout << int_<6>::next::value << endl;
cout << int_<6>::prior::value << endl;
cout << typeid(int_<false>::type).name() << endl;
cout << int_<false>::value << endl;
cout << int_<false>::next::value << endl;
cout << int_<false>::prior::value << endl;
cout << typeid(int_<true>::type).name() << endl;
cout << int_<true>::value << endl;
cout << int_<true>::next::value << endl;
cout << int_<true>::prior::value << endl;
return 0;
}
结果:
更多推荐
已为社区贡献3条内容
所有评论(0)