title: Get index of current element in C++ range-based for-loop
body: <p>My code is as follows:</p>
  
  <pre><code>std::cin &gt;&gt; str;
  for ( char c : str )
      if ( c == 'b' ) vector.push_back(i) //while i is the index of c in str
  </code></pre>
  
  <p>Is this doable? Or I will have to go with the old-school for loop?</p>