コンパイラがどの程度最適化を行うのか気になるので...
// assume we have this declared somewhere
std::vector<int> vec;
// my question is, when fully optimized will this...
for (int i(0); i<100; ++i)
vec.push_back(i);
// evaluate to this? psuedo code...
const size_t size = size();
const size_t newsize = size + 100;
if (size < vec.capacity())
vec.exponentialGrowth();
vec.setSize(newsize);
for (size_t i(size); i<newsize; ++i)
vector[i] = i;
最適化を有効にして Visual Studio Express 2012 を使用しています。逆アセンブルを見てみましたが、最適化により読みにくくなっています。