title: Is there an equivalent to the range-based `enumerate` loop from python in modern C++?
body: <p>Is there an equivalent to the range-based <code>enumerate</code> loop from python in C++?
  I would imagine something like this.</p>
  
  <pre><code>enumerateLoop (auto counter, auto el, container) {
      charges.at(counter) = el[0];
      aa.at(counter) = el[1];
  }
  </code></pre>
  
  <p>Can this be done with templates or macros? </p>
  
  <p>I'm aware that I can just use an old school for-loop and iterate until I reach <code>container.size()</code>. But I'm interested how this would be solved using templates or macros.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I played a bit with boost iterators after the hint in the comments. I got another working solution using C++14.</p>
  
  <pre><code>template &lt;typename... T&gt;
  auto zip(const T &amp;... containers) -&gt; boost::iterator_range&lt;boost::zip_iterator&lt;
  decltype(boost::make_tuple(std::begin(containers)...))&gt;&gt; {
    auto zip_begin =
      boost::make_zip_iterator(boost::make_tuple(std::begin(containers)...));
    auto zip_end =
      boost::make_zip_iterator(boost::make_tuple(std::end(containers)...));
    return boost::make_iterator_range(zip_begin, zip_end);
  }
  
  template &lt;typename T&gt;
  auto enumerate(const T &amp;container) {
  return zip(boost::counting_range(0, static_cast&lt;int&gt;(container.size())),
  container);
  } 
  </code></pre>
  
  <p><a href="https://gist.github.com/kain88-de/fef962dc1c15437457a8" rel="nofollow">https://gist.github.com/kain88-de/fef962dc1c15437457a8</a></p>