This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: A simple sample code involving templates, friends and lookup


On 17 Jan 2008 11:46:52 -0800, Ian Lance Taylor <iant@google.com> wrote:
>
> "Richard Guenther" <richard.guenther@gmail.com> writes:
> >
> > Well, first I think you'd need friend-injection or otherwise a global
> > decl of the function.
>
> ADL works without friend injection.  Look at 3.4.2
> [basic.lookup.koenig] in C++98.

I did.  It says "other _namespaces_ not considered...".

> > Second I thought argument dependent
> > name-lookup only applies to namespaces, not classes.
>
> No.
>
> > EDG rejects this consistently btw.
>
> Well, I'm probably misinterpreting the example.  Adding the templates
> must change it somehow.

Well, the actual call to func is not dependent, so it should not affect
name-resolution.

> For example, this works fine, even without -ffriend-injection:
>
> class x { friend x operator+(const x& x1, const x& x2); };
> x foo(x x1, x x2) { return x1 + x2; }

It does, even with EDG.

Well, a language lawyer can probably clear things up.  From a look
at the std it looks like w/o a previous declaration the above should
be invalid.  And at a different point it suggests the decl becomes
available.

Bah.

Richard.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]