TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
C++ Coding Standard

Rule:  CFL#018Checked automatically with code checker

Synopsis:Use range-based for loops if possible
Severity Level:4
Category:Control Flow


Most iterators and C-style index based for loops can be rewritten as range-based loops. Range-based for loops are less error prone, so if possible, use them.

Wrong Example:

std::vector<char> myString;
for (auto iter = myString.begin(); iter != myString.end(); iter++)

Correct Example:

std::vector<char> myString;
for (auto & value : myString)