title: Can modern compilers unroll `for` loops expressed using begin and end iterators
body: <p>Consider the following code</p>
  
  <pre><code> vector&lt;double&gt; v;
   // fill v
   const vector&lt;double&gt;::iterator end =v.end();
   for(vector&lt;double&gt;::iterator i = v.bgin(); i != end; ++i) {
     // do stuff
   }
  </code></pre>
  
  <p>Are compilers like g++, clang++, icc able to unroll loops like this. Unfortunately I do not know assembly to be able verify from the output whether the loop gets unrolled or not. (and I only have access to g++.)</p>
  
  <p>To me it seems that this will require more smartness than usual on behalf of the compiler, first to deduce that the iterator is a random access iterator, and then figure out the number of times the loop is executed. Can compilers do this when optimization is enabled ?</p>
  
  <p>Thanks for your replies, and before some of you start lecturing about premature optimization, this is an excercise in curiosity. </p>