Columbo
Columbo

Reputation: 60999

Inconsistent specialization of tuple_size

When explicitly specializing both tuple_size and tuple_element for some template, I realized that §14.5.1/4, which reads

In a redeclaration, partial specialization, explicit specialization or explicit instantiation of a class template, the class-key shall agree in kind with the original class template declaration (7.1.6.3).

is seemingly violated by the standard itself:

enter image description here

Am I missing something here (e.g. the standard specifies that class-keys are "exposition only" and shall agree within the actual implementation)?

Upvotes: 4

Views: 142

Answers (2)

T.C.
T.C.

Reputation: 137315

Bo Persson's now-deleted answer got it right. The paragraph ([temp.class]/p4) you cite refers to §7.1.6.3 [dcl.type.elab] for the definition of "agree in kind", which in turn says (p3, emphasis mine)

The class-key or enum keyword present in the elaborated-type-specifier shall agree in kind with the declaration to which the name in the elaborated-type-specifier refers. This rule also applies to the form of elaborated-type-specifier that declares a class-name or friend class since it can be construed as referring to the definition of the class. Thus, in any elaborated-type-specifier, the enum keyword shall be used to refer to an enumeration (7.2), the union class-key shall be used to refer to a union (Clause 9), and either the class or struct class-key shall be used to refer to a class (Clause 9) declared using the class or struct class-key.

The code is valid, if inconsistent.

Upvotes: 4

Howard Hinnant
Howard Hinnant

Reputation: 218860

This looks like an editorial defect to me. Try opening an issue here:

https://github.com/cplusplus/draft/issues

If you're adventurous, try resolving it with a pull request. :-)

Upvotes: 1

Related Questions