title: Cycles in c++ like in python (range-based for)
body: <p>What is the easiest way to do cycles in c ++ like in python?</p>
  
  <pre><code>for i in range(10): #or range(4, 10, 2) etc
      foo(i)
  </code></pre>
  
  <p>I mean something simple and one-line like this</p>
  
  <pre><code>for(auto i: range(10)) //or range(4, 10, 2) or range(0.5, 1.0, 0.1) etc
      foo(i);
  </code></pre>
  
  <p>but not like this:</p>
  
  <pre><code>std::vector&lt;int&gt; v(10);
  std::iota(begin(v), end(v), 0);
  for(auto i: v) {
      foo(i);
  }
  </code></pre>
  
  <p>Or this</p>
  
  <pre><code>for(auto i: []{vector&lt;size_t&gt; v(10); return iota(begin(v), end(v), 0), v;}() ) {
      foo(i);         
  }
  </code></pre>
  
  <p>Of course, it is not difficult to use these examples or just <code>for(;;)</code> but I hope there is a way to do it briefly and succinctly in python.</p>