I have the following code snippet.
template<typename T>
void test3(const T& x)
{
std::cout << std::is_const_v<T> << std::endl;
std::cout << std::is_reference_v<decltype(x)> << std::endl;
std::cout << std::is_const_v<decltype(x)> << std::endl;
std::cout << std::endl;
}
int main() {
int x = 5;
int& rx = x;
const int cx = 5;
const int& crx = 5;
std::cout << std::boolalpha;
{
test3(x);
test3(rx);
test3(cx);
test3(crx);
}
return 0;
}
The statement std::is_const_v<decltype(x)> yields false for all calls of the test3(const T& x) function. My understanding was since the const qualifier is specified as part of the function argument, this statement would yield true, but it prints false every time. Wanted to ask why this is the case and/or if I am missing something?