在回答中这个问题问题是传统的C关键字的含义auto
(自动的,而不是static
or extern
存储)仍然有效C++11现在它意味着类型推导。
我记得旧的意思是auto
应该保留相关的内容,但其他人不同意。
auto char c = 42; // either compilation error or c = '*'
查看编译器,我看到了当前的划分。
- 旧含义的 auto 不再被允许
- 在相关的地方使用 auto 的旧含义
你知道哪种行为是正确的吗?
不它不是。事实上,§7.1.6.4/3 给出了以下示例:
auto x = 5; // OK: x has type int
const auto *v = &x, u = 6; // OK: v has type const int*, u has type const int
static auto y = 0.0; // OK: y has type double
auto int r; // error: auto is not a storage-class-specifier
如您所见,这会导致错误。 §7.1.6.5 几乎解决了以下问题:
在本节未明确允许的上下文中使用 auto 的程序是格式错误的。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)