In following code:
template<typename T>
struct TD;
decltype(auto) getMyConst() {
const int val = 10;
return (const int)val; // const int cast is not needed here actually
}
int main()
{
TD<decltype(getMyConst())> type_test;
}
produces error:
main.cpp:41:32: error: implicit instantiation of undefined template 'TD<int>'
TD<decltype(getMyConst())> type_test;
which indicates that deduced type is int, I would expect decltype rules to deduce const int. Why does clang compiler deduce 'int'?