Consider
#include <iostream>
#include <type_traits>
template <class T, class ARG_T = T&>
T foo(ARG_T v){
return std::is_reference<decltype(v)>::value;
}
int main() {
int a = 1;
std::cout << foo<int>(a) << '\n';
std::cout << foo<int, int&>(a) << '\n';
}
I'd expect the output to be 1 in both cases. But in the first case it's 0: consistent with the default being class ARG_T = T
rather than class ARG_T = T&
.
What am I missing?