A timely article, as there has been an extensive flurry of discussion within the committee over the past weekend about defaults for the ranged for
:
Convenient Constructs For Stepping Through a Range of Values
by Mikhail Semenov
From the article:
In this article, the following loops are proposed:
for (auto x : step(start, count, step-width)) { ... } for (auto x : step(count)) {...} for (auto x : step_backward(count)) {...} for (auto x : step_to(start, finish, step-width)) {...} for (auto x : step_until(start, finish, step-width)) {...}They are based on the C++11 for-range loop. In order to write such loops, the appropriate functions
step
,step_backward
,step_to
andstep_until
have to be implemented. The article shows their implementation, discusses advantages of such loops and includes the benchmark results.
Add a Comment
Comments are closed.