Date: Wed, 13 Mar 2024 13:01:29 -0400
On Tue, Mar 12, 2024 at 10:56 PM Russell Shaw via Std-Discussion <
std-discussion_at_[hidden]> wrote:
> 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 ?
>
The second half of the paragraph describes a different situation from the
first half. The first half mentions that `typename` is not required in a
*class-or-decltype* or an *elaborated-type-specifier*. The second half
mentions that in a construct of the form `A::B::`, the `A::B` part is
implicitly assumed to be a type and `typename` is again not required.
(`A::B::` is a *nested-name-specifier*, and it contains `A::`, which is
also a *nested-name-specifier*.) This latter situation is the one
illustrated by the example above.
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>
std-discussion_at_[hidden]> wrote:
> 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 ?
>
The second half of the paragraph describes a different situation from the
first half. The first half mentions that `typename` is not required in a
*class-or-decltype* or an *elaborated-type-specifier*. The second half
mentions that in a construct of the form `A::B::`, the `A::B` part is
implicitly assumed to be a type and `typename` is again not required.
(`A::B::` is a *nested-name-specifier*, and it contains `A::`, which is
also a *nested-name-specifier*.) This latter situation is the one
illustrated by the example above.
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>
-- *Brian Bi*
Received on 2024-03-13 17:01:42