#include <iostream>
using namespace std;
int main()
{
int a = 5;
add_const<int *>::type b = &a;//int * const
//关于引用遵守引用折叠规则
add_lvalue_reference<int&&>::type c = a;// int &
add_rvalue_reference<int&>::type d = a; // int &
add_pointer<int>::type e = &a; //int*
//传入reference会导致不明确行为
make_signed<unsigned>::type f = -5; // int
make_unsigned<int>::type g = 5;//unsigned
//去除row const
remove_const<decltype(b)>::type m = &a;// int*
remove_reference<int&&>::type n = 5;//int
remove_pointer<int*>::type j = 6;//int
//去除row volatile
remove_volatile<int *volatile>::type i = &a; //int*
remove_cv<const int *volatile>::type k = &a; // const int*
add_volatile<int>::type w = 4;// volatile int
add_cv<int*>::type v = &a; // int*volatile const
system("pause");
return 0;
}
c++ type trait 之 类型修饰符(Type Modifier)改动类型
最新推荐文章于 2022-10-10 13:39:47 发布