【发布时间】:2015-06-12 15:30:09
【问题描述】:
考虑代码:
int const x = 50;
int const& y = x;
cout << std::is_const<decltype(x)>::value << endl; // 1
cout << std::is_const<decltype(y)>::value << endl; // 0
这是有道理的,因为y 不是const 引用,而是对const 的引用。
是否存在foo 使得std::foo<decltype(y)>::value 为1?如果不是,如何定义我自己的?
【问题讨论】:
-
std::remove_reference有帮助吗? -
你的意思是
std::is_const<decltype(x)>::value?而std::is_const<std::remove_reference<decltype(y)>::type>::value会产生您正在寻找的价值。