c++ type trait 之 useful trait
2017-05-18 17:34
253 查看
#include <iostream> #include <array> using namespace std; enum class color : char { yellow, red, bule }; int main() { //row Array的维度 cout << rank<int []>::value << endl; //extent<T,I = 0> 维度I的宽度 cout << extent<int[5][7],1>::value << endl; // remove_extent<int[5][3]>::type a = { 5,4,3 };//int[3] remove_all_extents<int[5][3]>::type b = 5;//int underlying_type<color>::type c = 'e'; // char //使const int& decay(衰退为int)by value decay<const int&>::type i = 5;// int //enable_if<B,T> 若B为真则产出type T 否则产出void enable_if<true, double>::type d = 3.11; // value //conditional<B,T,D>若B为真则产出type T,否则产出 type D conditional<true, string, double>::type s = "Marco";// string //common_type<T,D> 得到类型T和类型D的共通类型 cout << typeid(common_type<int, double>::type).name() << endl; //result_of<F,Args>见其他博文详细介绍 //alignment_of<T> alignment_storage<Len> //alignment_storage<Len,Align> //alignment_union<Len,Types...>见详细博文补充 system("pause"); return 0; }
相关文章推荐
- c++ type trait 之 类型修饰符(Type Modifier)改动类型
- c++ type trait 之 检验类型关系(Type Relation)
- C++模板:type_trait
- c++ type trait 之 class trait
- error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
- C++ type conversation
- C++ Type traits的简单用法
- C++泛型idioms之一: trait
- modern c++ design 笔记(如何列印一个TYPELIST)
- C++ Metaprogramming::Typelist::Definitions and basic implementations
- Type cast in C++
- 两个C++编译错误及解决办法--does not name a type和field `XX' has incomplete type
- linux下c++程序编译错误--理解typename
- C++ Templates笔记 8 技巧性基础知识关键字typename
- Advanced Run Time Type Identification in C++ Part II(Property Library An Implementation of RTTI in C++)
- missing type specifier - int assumed. Note: C++ does not support default-int,这是什么问题?如何解决呀?
- C++ Type traits
- C++ Type traits
- 我的C++实践(4):trait与policy模板技术
- C++ error:Debug Assertion Failed.Expression:_BLOCK_TYPE_IS_VALID(phead->nBlockUse)