C first declared in g , so [basic.scope.pdecl] / (7.2) applies
for the specified form specifier type
key class Identifier
if the specified type specifier is used in the qualifier-description-seq or parameter-declaration-sentence of the function defined in the namespace area, [...]; otherwise , except for declaring a friend, the identifier is declared in the smallest namespace or block area containing the declaration.
(The "otherwise ..." part only applies to declarations of the form friend class C; it uses "how" and not "inside")
Thus, as C declared as a member of N , its declarative scope is clearly N In fact, you can use C outside of B
And g is a member of N according to [namespace.memdef] / 3
If a friend declaration in a non-local class first declares [..] a function template, the friend is a member of the innermost namespace environment.
Thus, the declarative region g also the body of N
source share