5.4.3. Range for
Statement
The new standard introduced a simpler for
statement that can be used to iterate through the elements of a container or other sequence. The syntactic form of the range for
statement is:
for (declaration : expression) statement
expression must represent a sequence, such as a braced initializer list (§ 3.3.1, p. 98), an array (§ 3.5, p. 113), or an object of a type such as vector
or string
that has begin
and end
members that return iterators (§ 3.4, p. 106).
declaration defines a variable. It must be possible to convert ...
Get C++ Primer, Fifth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.