[英]Where in the standard does it say that the typedef below is valid?
Both g++
and clang++
compile this snippet: g++
和clang++
都编译这个片段:
typedef int int3[];
int3 i { 0, 1, 2 };
But where in the standard does it say that the array typedef
declaration above is valid?但是标准中哪里说上面的数组typedef
声明是有效的?
How do you infer that int3[]
is a "synonym" for int[]
?您如何推断int3[]
是int[]
的“同义词”?
But where in the standard does it say that the typedef declaration above is valid?但是标准中哪里说上面的 typedef 声明是有效的?
It's valid.这是有效的。 As per the standard:按照标准:
1 - Declarations containing the decl-specifier typedef declare identifiers that can be used later for naming fundamental (6.8.2) or compound (6.8.3) types. 1 - 包含 decl 说明符 typedef 的声明声明了以后可用于命名基本 (6.8.2) 或复合 (6.8.3) 类型的标识符。 [...] [...]
Where:在哪里:
1 - Compound types can be constructed in the following ways: 1 - 可以通过以下方式构造复合类型:
— (1.1) arrays of objects of a given type, 9.3.4.5; — (1.1) arrays 给定类型的对象,9.3.4.5;
[...] [...]
How do you infer that
int3[]
is a "synonym" forint[]
?您如何推断int3[]
是int[]
的“同义词”?
The declaration is well defined, including for arrays with unknown bounds:声明定义明确,包括具有未知边界的 arrays:
[...] [...]
5 - Any type of the form “cv-qualifier-seq array of NU” is adjusted to “array of N cv-qualifier-seq U”, and similarly for “array of unknown bound of U”. 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.