Should name resolution work for A
, B
, C
in the following code in parameter list of f
definition?
namespace ns
{
struct A {};
struct S
{
struct B {};
struct
{
struct C {};
void f(A, B, C);
} x;
};
}
#include <type_traits>
void std::type_identity_t<decltype(ns::S::x)>::f(A, B, C) {}
int main()
{
}
Actually it works in latest clang
.
[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 ofX
, following the member's declarator-id (24), shall be declared in one of the following ways:
...
(8.2) — shall be a member of classX
..., or
(8.3) — ifX
is a nested class of classY
(11.4.10), shall be a member ofY
,... or
...
(8.5) — ifX
is a member of namespaceN
, or is a nested class of a class that is a member ofN
, ... before the use of the name, in namespaceN
or in one ofN
'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).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.