gpt4 book ai didi

c++ - tuple_size 的特化不一致

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:43:56 24 4
gpt4 key购买 nike

当为某个模板显式特化 tuple_sizetuple_element 时,我意识到 §14.5.1/4,它是这样写的

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).

似乎违反了标准本身:

enter image description here

我是否遗漏了什么(例如,标准规定class-key“仅供说明”并且应在实际实现中达成一致)?

最佳答案

Bo Persson 现已删除的答案是正确的。您引用的段落 ([temp.class]/p4) 是指 §7.1.6.3 [dcl.type.elab] 中关于“以实物形式同意”的定义,它反过来说(p3,强调我的)

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.

如果不一致,代码是有效的。

关于c++ - tuple_size 的特化不一致,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32159000/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com