[英]Where in the Standard does it say that calling B::foo() below is legal?
[英]Where in the standard does it say that the typedef below is valid?
g++
和clang++
都编译这个片段:
typedef int int3[];
int3 i { 0, 1, 2 };
但是标准中哪里说上面的数组typedef
声明是有效的?
您如何推断int3[]
是int[]
的“同义词”?
但是标准中哪里说上面的 typedef 声明是有效的?
这是有效的。 按照标准:
1 - 包含 decl 说明符 typedef 的声明声明了以后可用于命名基本 (6.8.2) 或复合 (6.8.3) 类型的标识符。 [...]
在哪里:
1 - 可以通过以下方式构造复合类型:
— (1.1) arrays 给定类型的对象,9.3.4.5;
[...]
您如何推断
int3[]
是int[]
的“同义词”?
声明定义明确,包括具有未知边界的 arrays:
[...]
5 - 任何形式的“cv-qualifier-seq array of NU”都被调整为“array of N cv-qualifier-seq U”,同样适用于“array of unknown bound of U”。
[...]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.