title: Is it expensive to compute vector size in for loops, each iteration?
body: <p>Does the c++ compiler take care of cases like, buildings is vector:</p>
  
  <pre><code>for (int i = 0; i &lt; buildings.size(); i++) {}
  </code></pre>
  
  <p>that is, does it notice if buildings is modified in the loop or not, and then
  based on that not evaluate it each iteration? Or maybe I should do this myself,
  not that pretty but:</p>
  
  <pre><code>int n = buildings.size();
  for (int i = 0; i &lt; n; i++) {}
  </code></pre>