title: How do I iterate over a vector and also know the index of the element?
body: <p>I need to access each element in a vector and also know what index the element is in.</p>
  
  <p>So far I could come up with two ways</p>
  
  <pre><code> for (iterator it= aVector.begin(), int index= 0; it!= aVector.end(); ++it, ++index)
  </code></pre>
  
  <p>leaving the type signature. also it looks like i can't use auto</p>
  
  <pre><code> for (int index = 0; index &lt; aVector.size(); ++index)
  {
      // access using []
  }
  </code></pre>
  
  <p>Which one is more efficient or is there a better way to do this?</p>