ES.55: Avoid the need for range checking
ES.55: 尽量不造成范围检查需求
Reason(原因)
Constructs that cannot overflow do not overflow (and usually run faster):
无法溢出的结构不会溢出(而且通常会运行的更快)
Example(示例)
代码语言:javascript复制for (auto& x : v) // print all elements of v
cout << x << 'n';
auto p = find(v, x); // find x in v
Enforcement(实施建议)
Look for explicit range checks and heuristically suggest alternatives.
寻找显式范围检查并且启发式建议其他选项。
原文链接
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es55-avoid-the-need-for-range-checking