|
Boost : |
From: David Abrahams (abrahams_at_[hidden])
Date: 2001-05-21 21:05:34
----- Original Message -----
From: "John Max Skaller" <skaller_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Monday, May 21, 2001 5:16 PM
Subject: Re: [boost] Re: Question about interpretation of ISO C++ standard
> David Abrahams wrote:
>
> > You're partly right. They changed the rules which broke the B&N trick at
one
> > point during drafting, but (as Andy Koenig explained to me in Nashua at
my
> > first meeting), later made additional modifications so that the B&N
trick
> > would continue to be a legitimate technique.
>
> That's roughly my understanding too. But now note that
> the original trick relied on injection: inserting the declaration
> of a function first declared as a friend inside a class
> just before the class definition: I don't believe that happens
> any more. Instead, Koenig lookup is used. That means that
> the friend needs to have an argument of the class type
> to be found outside the class.
No, just an argument from the same namespace as the class type.
struct Y;
> class X {
> friend void f(X) {}
friend void f(Y) {}
> friend void nf() {}
> void method() {}
> };
>
> X x;
> f(x); /// found
f(Y()); /// found
> nf(); // not found
>
> void X::method() { nf(); } // found
>
> Again, note that I'm _not_ at all sure. Note there
> are no templates in the example.
>
> When you start using templates all hell breaks loose.
> [The lookup rules appear to be imprecise, incomplete,
> and/or inadequate; but it is hard to tell]
They're well-defined. No need for FUD here.
-Dave
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk