Does T have to be a complete type to be used in `std::declval<T>`?
问题 Consider this example (coming from here): #include <type_traits> #include <iostream> template <typename U> struct A { }; struct B { template <typename F = int> A<F> f() { return A<F>{}; } using default_return_type = decltype(std::declval<B>().f()); }; int main() { B::default_return_type x{}; std::cout << std::is_same< B::default_return_type, A<int>>::value; } It compiles with no errors on gcc9.2 but gcc7.2 and clang 10.0.0 complain about B not being complete. Clangs error is: prog.cc:11:58: