Boost logo

Boost :

From: John Max Skaller (skaller_at_[hidden])
Date: 2001-05-21 16:16:31


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.

        class X {
                friend void f(X) {}
                friend void nf() {}
                void method() {}
        };

        X x;
        f(x); /// 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]

-- 
John (Max) Skaller, mailto:skaller_at_[hidden]
10/1 Toxteth Rd Glebe NSW 2037 Australia voice: 61-2-9660-0850
checkout Vyper http://Vyper.sourceforge.net
download Interscript http://Interscript.sourceforge.net

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk