【发布时间】:2018-12-02 07:44:29
【问题描述】:
#include <iostream>
#include <type_traits>
using namespace std;
template<typename T>
void f(T&&)
{
cout << boolalpha << std::is_const_v<T> << endl;
cout << boolalpha << std::is_const_v<T&&> << endl;
}
int main()
{
const int n = 1;
f(n);
}
输出是:
false
false
这里,n 是一个明显的 const 变量,为什么 std::is_const_v 的行为不符合预期?
【问题讨论】:
标签: c++ c++11 constants standards typetraits