C++ Logo

std-discussion

Advanced search

Template name resolution

From: Russell Shaw <rjshaw_at_[hidden]>
Date: Wed, 13 Mar 2024 13:56:48 +1100
Hi,

In 13.8.1.4 p402 General [temp.res.general] 14882:2020(E)

4
A qualified name used as the name in a class-or-decltype (11.7) or an
elaborated-type-specifier is implicitly assumed to name a type, without
the use of the typename keyword. In a nested-name-specifier that
immediately contains a nested-name-specifier that depends on a template
parameter, the identifier or simple-template-id is implicitly assumed to
name a type, without the use of the typename keyword.

[Note 1 : The typename keyword is not permitted by the syntax of these
constructs. — end note]


This implies the following is in error, yet it compiles ok in gnu g++:

struct S {
     struct U {
 static int a;
     };
};

S s;

template<class T> int f(T s) { return T::U::a; }

int x = f(s);


Confusing:

"In a nested-name-specifier that immediately contains a
nested-name-specifier that depends on a template parameter, the
identifier or simple-template-id is implicitly assumed to name a type,
without the use of the typename keyword."

Is it talking about within a class-or-decltype or
elaborated-type-specifier ?
If so, the second half of the paragraph is redundant ?

Received on 2024-03-13 02:56:53