[basic.lookup.unqual]/8 For the members of a class X
, a name used ... in the definition of a class member outside of the definition of X
, following the member's declarator-id(24), shall be declared in one of the following ways:
...
(8.2) — shall be a member of class X
..., or
(8.3) — if X
is a nested class of class Y
(11.4.10), shall be a member of Y
,... or
...
(8.5) — if X
is a member of namespace N
, or is a nested class of a class that is a member of N
, ... before the use of the name, in namespace N
or in one of N
's enclosing namespaces.
Footnote 24) That is, an unqualified name that occurs, for instance, in a type in the parameter-declaration-clause or in the noexcept-specifier.
Here X
is decltype(ns::S::x)
, Y
is S
, N
is ns
. Therefore, A
is found via (8.5), B
via (8.3), C
via (8.2).