为什么旧的使用(c ++ 03)auto不能在C ++ 11下编译? [英] Why old usage (c++03) of auto does not compile under C++11?
问题描述
我知道 auto
之前有一点用处,因为它是变量的默认值(与静态相反) - 参见问题
考虑到有效的C ++ 03代码,其中可能为了不言自明,使用此关键字: / p>
I know that auto
has a little usage before because it is the default for variables (opposite to static) - see question
Consider however valid C++03 code where, maybe for self-explanatory, this keyword was used:
auto int foo2 = 8;
它在C ++ 03下编译,不能在C ++ 11下编译。
有没有任何理由不回来与C ++ 03兼容?
标准委员会意见的来源是这个关键字没有被使用?有关于关键字使用的统计数据吗?
It compiles under C++03, and does not compile under C++11. Is there any reason for not being back-compatible with C++03? What was the source of standard committee opinion that this keyword was not used? Are there any statistics of keyword usage?
BTW我用gcc测试 - 也许这是一个编译器错误?
BTW i tested with gcc - maybe this is a compiler bug?
推荐答案
已知这会破坏兼容性,并在标准的附录C 2.3第7条中提及。考虑到如何使用无用的汽车,并且确实很容易修复成本被认为是可以接受的。
It was known that this breaks compatibility and is mentioned in Appendix C 2.3 Clause 7 of the standard. Given how useless auto has been and that it is really easy to fix the cost was deemed acceptable.
关于关键字统计:一些有巨大代码基础的公司
As for keyword statistics: Some companies with huge code-bases are on the committee, they probably know if it was acceptable, but I could not dig up any full statistics.
我做了一些标准考古学和最古老的论文,讨论 auto
似乎是N1478,它指的是一个反射器消息的第一次讨论的汽车(所有后来的文章不谈论打破兼容性或推理)。
I did some standards archeology and the oldest paper that talks about auto
seems to be N1478, which refers to a reflector message for the first discussing of auto (all later papers don't talk about breaking compatibility or reasoning).
这篇关于为什么旧的使用(c ++ 03)auto不能在C ++ 11下编译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!