C++核心准则ES.85:让空语句可见

2020-06-09 15:09:03 浏览数 (2)

ES.85: Make empty statements visible

ES.85:让空语句可见

Reason(原因)

Readability.

可读性

Example(示例)

代码语言:javascript复制
for (i = 0; i < max;   i);   // BAD: the empty statement is easily overlooked
v[i] = f(v[i]);

for (auto x : v) {           // better
    // nothing
}
v[i] = f(v[i]);
Enforcement(实施建议)
Flag empty statements that are not blocks and don't contain comments. 标记没有封闭和不含注释的空语句。

原文链接

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es85-make-empty-statements-visible

0 人点赞