Title
Definitions of friends and block-scope externs
Status
nad
Section
_N4868_.9.8.2.3 [namespace.memdef]
Submitter
Derek Inglis

Created on 1999-09-07.00:00:00 last changed 301 months ago

Messages

Date: 1999-10-15.00:00:00

Rationale (10/99): Entities whose names are "invisibly injected" into a namespace as a result of friend declarations are not "declared" in that namespace until an explicit declaration of the entity appears at namespace scope. Consequently, the definitions in the example are ill-formed.

(See also issues 95, 136, 138, 139, 143, and 166.)

Date: 2022-02-18.07:47:23

_N4868_.9.8.2.3 [namespace.memdef] paragraph 2 says,

Members of a named namespace can also be defined outside that namespace by explicit qualification (6.5.5.3 [namespace.qual] ) of the name being defined, provided that the entity being defined was already declared in the namespace...
It is not clear whether block-scope extern declarations and friend declarations are sufficient to permit the named entities to be defined outside their namespace. For example,
    namespace NS {
       struct A { friend struct B; };
       void foo() { extern void bar(); }
    }
    struct NS::B { };   // 1) legal?
    void NS::bar() { }  // 2) legal?

Rationale (10/99): Entities whose names are "invisibly injected" into a namespace as a result of friend declarations are not "declared" in that namespace until an explicit declaration of the entity appears at namespace scope. Consequently, the definitions in the example are ill-formed.

(See also issues 95, 136, 138, 139, 143, and 166.)

History
Date User Action Args
2000-02-23 00:00:00adminsetmessages: + msg282
2000-02-23 00:00:00adminsetstatus: open -> nad
1999-09-07 00:00:00admincreate