I was surprised to find that for some T
, decltype(std::declval<T>())
is not legal:
#include <utility>
template<typename T>
using Alias = decltype(std::declval<T>());
// as expected
using A1 = Alias<int>;
using A2 = Alias<int(int)>;
// error: no matching function for call to 'declval<...>()'
using A3 = Alias<int(int) const>;
using A4 = Alias<int(int) volatile>;
using A5 = Alias<int(int) &>;
using A6 = Alias<int(int) &&>;
// and all combinations of the above
cppreference doesn't seem to indicate that this error is expected.
Are there any other types for which declval<T>
cannot be used? Where does the spec define these?