【发布时间】:2015-04-06 21:06:33
【问题描述】:
§8/5:
trailing-return-type 中的可选 attribute-specifier-seq 属于指定的返回类型。中的 type-id trailing-return-type 包括可能的最长序列 abstract-declarator。 [注意:这解决了数组和函数声明符的模糊绑定。 [ 例子:
auto f()->int(*)[4]; // function returning a pointer to array[4] of int // not function returning array[4] of pointer to int—结束示例]—结束注释]
trailing-return-type 中的“type-id”对我来说没有意义,仅仅是因为 trailing-return-type 不包含 type-id。
我也不明白数组和函数声明的“模糊绑定”。据我了解
auto f() -> int*[4]; // function returning an array of 4 pointers to int
auto f() -> int(*)[4]; // function returning a pointer to an array of 4 ints
【问题讨论】:
-
你能问个问题吗?
-
大概 type-id 指的是
->之后的整个事物,因为 trailing-type-specifier-seq 生成/是type-specifier-seq 的子集(查看 C++11 §7.1.6/1)。 -
@Cheersandhth.-Alf 我认为这是对的。不过写的比较草率。
-
尾随返回类型的语法中曾经有一个type-id。 N2927 更改了那部分语法,并将您引用的段落从 §8.3.5/3 移至 §8/5,但没有更改措辞(这可能是一个疏忽)。
标签: c++ language-lawyer c++14 trailing-return-type