#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);
}
The output is:
false
false
Here, n
is an obvious const variable, why does std::is_const_v
not behave as expected?
Aucun commentaire:
Enregistrer un commentaire