incomplete class usage with auto in template class
问题 Is the following code well formed ? class B; template<class T> class A { B do_f() const; friend auto f(A const& a) {return a.do_f();} // #1 }; class B{}; template <class T> B A<T>::do_f() const { return B{};} int main() { A<double> a; f(a); } If I change auto in #1 by B , I got incomplete type error message. Compile with auto for gcc/clang Demo Fail with B Demo 回答1: [dcl.fct.def.general]/2: The type of a parameter or the return type for a function definition shall not be an incomplete or