[英]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.