Problems with binary member and friend operator in template class

Dima Sorkin
Tue Jan 31 09:42:00 GMT 2006

On 1/30/06, John Love-Jensen  wrote:
> Try this:
> template <typename T2> friend P<T2> operator+(T2, const P<T2>&); // line 15

1) Can a template be a friend ? I always thought that only concrete
of template can be declared as friend.

2) By the way, "friend" in c++.
I think (I currently have no access to compiler), that in gcc-4.0.2 :
class B{};
class A{
  typedef B BB;
  friend BB;
won't be accepted, although gcc-3.36 did accept this.
If true, why ?

Thank you.

More information about the Gcc-help mailing list