This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: A simple sample code involving templates, friends and lookup
On 17/01/2008, Richard Guenther wrote:
>
> 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.
Yes, at the point of instantiation of Foo<int> the friend is declared,
and can then be found by ADL because Foo<int> is an associated type.
The reference parameter 'x' doesn't cause an instantiation, only 'weird' does.
However, see the discussion in section 9.2.2 of Vandevoorde and
Josuttis' C++ Templates book and the footnote saying the standard
isn't exactly clear.
I'm only guessing, but EDG's behaviour could be related to their
interpretation of DR329
http://www.open-std.org/jtc1/sc22/wg21//docs/cwg_defects.html#329
I'm not sure which interpretation is correct, but GCC's seems reasonable to me.
Jon