http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45942
--- Comment #9 from Michiel <MichieldeB at aim dot com> 2010-10-08 15:43:13 UTC --- (In reply to comment #6) > (In reply to comment #4) > > (In reply to comment #2) > > > This code is not valid, G++ is correct to reject it. > > > > Please explain why the code is invalid, and do not click "Resolved invalid" > > until ClassB is a friend of ClassA. > > You reported an invalid bug, so I rejected it. > It's not my job to teach you C++ but here you go: > > template <class T, int C> class A; > > template <class T, int C, A<T,C> &a> class B; > > template <class T, int C> class A > { > template <class X, int Y, A<X,Y>&> friend class B; > }; > > > That makes B<X,Y,A<X,Y>&> a friend of A > > Your original example is invalid for the reason the compiler gave, the syntax > you tried to use declares a partial specialization, which is not allowed in a > friend declaration. That's how C++ works, I don't make the rules. I really tried everything, but I have to admit I missed that one. Sorry. But you have to admit that it is a rather unnatural way to make friends. Furthermore, the third parameter Z is missing (I would prefer A<X,Y>&Z), but that does not seem to be a problem for the compiler. Thus it seems that the bug is that c++ is designed is such a way that it gives error messages which are incorrect. If you would have followed the title of my bug report immediately instead of saying that is was invalid, then the discussion would have been unnecessary. Now it is still odd that the first attempt gives an error so lately. The template precompiler counts three arguments and the template instantiator counts one, which is not very consistent.