Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2002-10-27 03:44:24


Rani Sharoni wrote:
> > Seems well-formed to me, and works with Intel C++ 6.0 and one other
> > compiler.
>
> VC7.1/7/6 also compiled the code but Comead 4.3.0.1 (EDG
> based) rejected the code. I suspect that Comeau's EDG, unlike
> the Intel's EDG, is correct because you are actually injecting
> names into the namespace and C++ doesn't allow that.

It might turn out that Comeau is correct after all (I am going to clarify
that on comp.std.c++), but for sure it won't be for the reason you cited
above :). Friend functions declared inside class definitions are found
through the Koenig lookup:

    template< typename T > struct her
    {
        friend void foo(her<T> const&);
    };

    int main()
    {
        her<int> h;
        foo(h); // prefectly OK
    }

See 7.3.1.2 [namespace.memdef] para 3 for the details.

Aleksey


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