title: C++11 Range-based for-loop efficiency "const auto &i" versus "auto i"
body: <p>In C++11, I can iterate over some container like so:</p>
  
  <pre><code>for(auto i : vec){
     std::cout &lt;&lt; i &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>But I know that this needlessly - <em>needlessly</em>, since I only need to <em>print</em> the values of <code>vec</code> - makes a copy of (<strong>EDIT</strong>:  each element of) <code>vec</code>, so instead I could do:</p>
  
  <pre><code>for(auto &amp;i : vec){
     std::cout &lt;&lt; i &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>But I want to make sure that the values of <code>vec</code> are never modified and abide by const-correctness, so I can do:</p>
  
  <pre><code>for(const auto &amp;i : vec){
     std::cout &lt;&lt; i &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>So my question is:  If I only need to <em>look</em> at the values of some container, wouldn't the very last loop (<code>const auto &amp;i</code>) always be preferred due to the increased effieciency of not having an extra copy of (<strong>EDIT</strong>:  each element of) <code>vec</code>?</p>
  
  <p>I have a program that I'm developing in which I'm considering making this change throughout, since efficiency is critical in it (the reason I'm using C++ in the fist place).</p>