This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 114b. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-05-06


673. Injection of names from elaborated-type-specifiers in friend declarations

Section: _N4868_.9.8.2.3  [namespace.memdef]     Status: NAD     Submitter: Mike Miller     Date: 6 February, 2008

_N4868_.9.8.2.3 [namespace.memdef] paragraph 3 is intended to prevent injection of names from friend declarations into the containing namespace scope:

If a friend declaration in a non-local class first declares a class or function the friend class or function is a member of the innermost enclosing namespace. The name of the friend is not found by unqualified lookup (6.5.3 [basic.lookup.unqual]) or by qualified lookup (6.5.5 [basic.lookup.qual]) until a matching declaration is provided in that namespace scope (either before or after the class definition granting friendship).

However, this does not address names declared by elaborated-type-specifiers that are part of the friend declaration. Are these names intended to be visibly injected? For example, is the following well-formed?

    class A {
        friend class B* f();
    };
    B* bp;    // Is B visible here?

Implementations differ in their treatment of this example: EDG and MSVC++ 8.0 accept it, while g++ 4.1.1 rejects it.

Rationale (July, 2009):

The current specification does not restrict injection of names in elaborated-type-specifiers, and the consensus of the CWG was that no change is needed on this point.