Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2001-05-18 13:31:36


This section of Stroustrup's book is highly confusing. If anyone can fill in
details from the standard to explain what's going on, I'd be indebted.

In the quoted example, what namespace does "void f(const X&)" get declared
in?

If it is not declared in X's namespace as claimed, how does
argument-dependent lookup find it as Stroustrup implies with his reference
to section 8.2.6 of his book (argument-dependent lookup looks in the
namespaces of the function's argument types)?

If it /is/ declared in X's namespace, then how does it differ from "void
f()"?

Are these friend functions "special" in that they are marked to not be found
through ordinary name lookup in the scope of their declarer, but only
through argument-dependent name lookup?

-Dave

----- Original Message -----
From: <rwgk_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Friday, May 18, 2001 1:32 PM
Subject: [boost] Re: Question about interpretation of ISO C++ standard

> Attached is another response from Compaq.
> What are the implications for Boost.Python?
> Ralf
>
>
> Date: Fri, 18 May 2001 12:29:16 -0400
> From: cxxc_bugs_at_[hidden]
> To: rwgk_at_c...
> Subject: Re: CPP#5241: Subj: cxx_bugreport: problem with friend
> functions
>
> ----------------------------------------------------------------------
> ----------
> Bjarne Stroustrup's "C++ Programming Language", third
> edition, section 11.5.1, explains the behaviour:
>
> "Like a member declaration, a friend declaration does
> not introduce a name into an enclosing scope.
> ...
> For large programs and classes, it is nice that
> a class doesn't "quietly" add names to its enclosing
> scope.
> ...
> A friend function can be explicitly declared just
> like the friend classes, or it can be found
> through its argument types as if it was declared
> in the non-class scope immediately enclosing its
> class.
>
> If follows that a friend function should either
> be explicitly declared in an enclosing scope
> or take an argument of its class. If not
> the friend cannot be called. For example:
>
> // no f() here
>
> void g(); // X's friend
>
> class X {
> friend void f(); // useless
> friend void g();
> friend void f(const X&); // can be found through its argument
> }
>
>
> Please send all Compaq C/C++ Support requests to
> cxxc_bugs_at_[hidden]
> Reply to this message for further correspondence regarding THIS
> support
> request. Thank you for choosing Compaq C/C++.
>
>
>
> To unsubscribe, send email to: <mailto:boost-unsubscribe_at_[hidden]>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>


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