help-gplusplus
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with g++ 4.0.2 (templates, friends and inheritance)


From: Thomas Maeder
Subject: Re: Problems with g++ 4.0.2 (templates, friends and inheritance)
Date: Sat, 03 Dec 2005 11:03:02 +0100
User-agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Jumbo Shrimp, linux)

Emanuel Ziegler <eziegler@web.de> writes:

> On Fri, 02 Dec 2005 17:53:13 +0100 Maurizio Loreti wrote:
>
>> well, the diagnostic is clear; g++ needs a prototype in scope of the
>> function to be declared friend.
>
> Ok, that works. Thanks! But why does it apply to templates only?

The moral equivalent of the non-template code you haven't shown us would be:

template <class T>
class FriendClass
{
  template <typename U>
  friend U get_test (const FriendClass<U> &);
};

which gcc 4.x happily accepts; the template get_test is implicitly
declared in the namespace to which FriendClass belongs. But it
declares *all* specializations of get_test() to be friends of all
specialziations of FriendClass.


Your code attempts to use a specialization of a so far undeclared
template.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]