Is using size() for the 2nd expression in a for construct always bad?
<p>In the following example should I expect that <code>values.size()</code> will be called every time around the loop? In which case it might make sense to introduce a temporary <code>vectorSize</code> variable. Or should a modern compiler be able to optimize the calls away by recognising that the vector size cannot change.</p>

<pre><code>double sumVector(const std::vector&lt;double&gt;&amp; values) {
    double sum = 0.0;
    for (size_t ii = 0; ii &lt; values.size(); ++ii) {
        sum += values.at(ii);
    }
}
</code></pre>

<p>Note that I don't care if there are more efficient methods to sum the contents of a vector, this question is just about the use of size() in a for construct.</p>
