It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center




7年前关闭。




我阅读了有关if语句的问题
哪个代码更快/相同?

在这种情况下,速度或编译器真的有区别吗?
先感谢您。

最佳答案

关于运行时速度,它们与完全相同。

C++ 11标准将第一种形式定义为第二种形式的隐式变体。实际上,根据第6.4 / 1段:



解析额外花括号所需的额外编译时间非常短,可以安全地忽略它。 选择一种形式,以便您更轻松地阅读或维护代码

关于c++ - 如果带有和不带有大括号,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15588041/

10-13 06:30