Created on 2025-04-12.00:00:00 last changed 1 month ago
(From submission #698.)
Consider:
namespace N {
inline namespace A {
constexpr int f(int *);
}
inline namespace B {
constexpr int f(long *);
}
} // namespace N
template <typename T> struct Q { using type = long; };
constexpr int N::f(Q<struct X *>::type *) { return 42; } // #1
namespace N {
inline namespace B {
struct X {};
}
} // namespace N
template <> struct Q<N::B::X *>; // explicit specialization after implicit instantiation
static_assert(N::B::f(0) == 42);
According to 6.4.6 [basic.scope.namespace] paragraph 1, the target scope of the declaration #1 is N::B. This is known only after establishing correspondence with the two earlier candidate declarations of f. However, a target scope for the elaborated-type-specifier struct X at #1 must be determined prior to establishing correspondence.
It would be reasonable to use N as the target scope for struct X, i.e. the scope named by the nested-name-specififer.
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2025-11-04 23:05:32 | admin | set | status: open -> drafting |
| 2025-04-12 00:00:00 | admin | create | |