元编程学习: integral_constant
作者:互联网
用于定义整型常数变量的类,在<type_traits>中广泛应用,最直接的使用是定义了true_type和false_type, 其为对bool类型的特化
#include <iostream>
#include <type_traits>
using namespace std;
int main()
{
std::cout << "This Demo is that type_traits: integral_constant" << std::endl;
std::integral_constant<int, 10> int10;
std::cout << "The Const Value: " << int10.value << std::endl;
std::integral_constant<unsigned short int, 20> shortInt20;
std::cout << "The Const Value: " << shortInt20.value << std::endl;
std::cout << "Bool Integral_constent " << std::endl;
std::cout << "true : " << true_type::value << std::endl;
std::cout << "false: " << false_type::value << std::endl;
return 0;
}
标签:std,constant,cout,编程,integral,include,type,定义 来源: https://blog.csdn.net/hit1524468/article/details/122520382