相关疑难解决方法(0)

获取模板类型的基类型(删除const/reference/etc.)

是否有类型特征模板,它返回给定类型的基本类型.通过碱型我的意思是与所有值调节剂,const的,易失性类型等剥离.例如,使用假设特征函数:

base<int>::type == int
base<int const>::type == int
base<int&>::type == int
Run Code Online (Sandbox Code Playgroud)

我知道remove_const并且remove_reference目前正在组合使用它们.我想知道是否存在这样的特征,或许是否有一个正确的名称我所指的是什么?

c++ templates c++11

11
推荐指数
2
解决办法
4751
查看次数

typeid不返回正确的类型

cout << typeid(int&).name();  
Run Code Online (Sandbox Code Playgroud)

在我看来,这应该int&作为一种类型而不是一种类型返回int,而是在GCC 4.5.1和VS2010 SP1 beta上返回int.为什么是这样?

c++ typeid

5
推荐指数
3
解决办法
1796
查看次数

标签 统计

c++ ×2

c++11 ×1

templates ×1

typeid ×1