class R{}; class B{ friend class R; // ok. }; template <typename T> class A{ friend class T; // error??? };
when using g++(3.3.3 or 4.1) to compile above code, it reports: error: using template type parameter 'T' after 'class' error: friend declaration does not name a class or function Pls note that, SunCC works fine for above code. -- Summary: cannot declare friend class of the parameter type in a template class Product: gcc Version: 3.3.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: gzljg at hotmail dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30390