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

2008-01-18 Thread Jonathan Wakely
On 18/01/2008, Dragan Milenkovic <[EMAIL PROTECTED]> wrote: > > Thanks for clarification and info. I believe issue #34 addresses exactly > what we're talking about. > > http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#34 Aha, yes ... but strangely that seems to have been closed as Not-A

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

2008-01-18 Thread Dragan Milenkovic
Jonathan Wakely wrote: 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

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

2008-01-17 Thread Jonathan Wakely
On 18/01/2008, Jonathan Wakely <[EMAIL PROTECTED]> wrote: > > Yes, at the point of instantiation of Foo the friend is declared, > and can then be found by ADL because Foo is an associated type. > The reference parameter 'x' doesn't cause an instantiation, only 'weird' does. Forgot the reference -

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

2008-01-17 Thread Jonathan Wakely
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

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

2008-01-17 Thread Richard Guenther
On 17 Jan 2008 11:46:52 -0800, Ian Lance Taylor <[EMAIL PROTECTED]> wrote: > > "Richard Guenther" <[EMAIL PROTECTED]> 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.looku

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

2008-01-17 Thread Ian Lance Taylor
"Richard Guenther" <[EMAIL PROTECTED]> writes: > > > On Jan 17, 2008 2:12 PM, Dragan Milenkovic <[EMAIL PROTECTED]> wrote: > > > > Richard Guenther wrote: > > > > [snip] > > > > >> template > > > > >> struct Foo > > > > >> { > > > > >> template > > > > >> friend void func(const Foo &);

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

2008-01-17 Thread Richard Guenther
On 17 Jan 2008 09:09:38 -0800, Ian Lance Taylor <[EMAIL PROTECTED]> wrote: > > "Richard Guenther" <[EMAIL PROTECTED]> writes: > > > On Jan 17, 2008 2:12 PM, Dragan Milenkovic <[EMAIL PROTECTED]> wrote: > > > Richard Guenther wrote: > > > [snip] > > > >> template > > > >> struct Foo > > > >> { > >

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

2008-01-17 Thread Ian Lance Taylor
"Richard Guenther" <[EMAIL PROTECTED]> writes: > On Jan 17, 2008 2:12 PM, Dragan Milenkovic <[EMAIL PROTECTED]> wrote: > > Richard Guenther wrote: > > [snip] > > >> template > > >> struct Foo > > >> { > > >> template > > >> friend void func(const Foo &); > > >> }; > > >> > > >> void ch

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

2008-01-17 Thread Richard Guenther
On Jan 17, 2008 2:12 PM, Dragan Milenkovic <[EMAIL PROTECTED]> wrote: > Richard Guenther wrote: > [snip] > >> template > >> struct Foo > >> { > >> template > >> friend void func(const Foo &); > >> }; > >> > >> void check(const Foo & x) > >> { > >> // Foo weird; // uncomment this l

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

2008-01-17 Thread Paolo Bonzini
template struct Foo { template friend void func(const Foo &); }; void check(const Foo & x) { // Foo weird; // uncomment this line and all works func(x);// <-- ERROR } Tested with gcc 4.0 - 4.3, and all behave the same: "error: 'func' was not declared in this scope

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

2008-01-17 Thread Dragan Milenkovic
Richard Guenther wrote: [snip] template struct Foo { template friend void func(const Foo &); }; void check(const Foo & x) { // Foo weird; // uncomment this line and all works func(x);// <-- ERROR } Tested with gcc 4.0 - 4.3, and all behave the same: "error: 'func'

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

2008-01-17 Thread Richard Guenther
On Jan 17, 2008 11:44 AM, Dragan Milenkovic <[EMAIL PROTECTED]> wrote: > Hello, > > I'm aware about these issues being around for quite a while now, but > there is still a chance this sample code can be helpful. I apologize > if someone gets annoyed :-P > > > template > struct Foo > { > templ

A simple sample code involving templates, friends and lookup

2008-01-17 Thread Dragan Milenkovic
Hello, I'm aware about these issues being around for quite a while now, but there is still a chance this sample code can be helpful. I apologize if someone gets annoyed :-P template struct Foo { template friend void func(const Foo &); }; void check(const Foo & x) { // Foo weird;