Mot*_*tti 3 c++ standards-compliance c++11
在回答这个问题时,问题是关键字(自动存储)的传统C含义auto在C++ 0x中是否仍然有效,现在它意味着类型推导.
我记得,旧的含义auto应该保留在相关的地方,但其他人不同意.
auto char c = 42; // either compilation error or c = '*'
Run Code Online (Sandbox Code Playgroud)
看看编译器,我看到了当前的部门.
你知道哪个是正确的行为吗?
GMa*_*ckG 15
不它不是.实际上,§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
Run Code Online (Sandbox Code Playgroud)
如您所见,它会导致错误.§7.1.6.5相当于以下事项:
在本节未明确允许的上下文中使用auto的程序是不正确的.
| 归档时间: |
|
| 查看次数: |
631 次 |
| 最近记录: |