Boost logo

Boost :

From: Jens Maurer (Jens.Maurer_at_[hidden])
Date: 2001-05-18 17:02:28


David Abrahams wrote:
>
> 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.

7.3.1.2p3 is, I believe, sufficiently clear. Please read that section
together with 3.4.2p1.

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

The innermost enclosing namespace, which is the namespace for class X.
However, the declaration there is hidden from normal lookup unless there
is a matching namespace-level declaration either before or after the
friend declaration.

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

Because argument-dependent lookup never looks into the namespace of
class X for f(), because f() has no arguments for whose types namespaces
could be considered for Koenig lookup.

> 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?

Exactly.

Jens Maurer


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