Hi,
I want to know the behavior of modern C++ compilers for this short program.
Basically this tells us the rate by which vector grows.
#include <vector>
#include <iostream>
using namespace std;
int main ()
{
vector<int> v;
for (int i = 1; i <= 10; ++i)
{
v.push_back(i);
cout << v.capacity() << " ";
}
}
VC 7.0, 7.1 results - 1 2 3 4 6 6 9 9 9 13
g++ 3.3.1 results - 1 2 4 4 8 8 8 8 16 16
Can you share results of other major compiler vendors.
Thanks,
Sharad
P.S. - I know this has to to do with whether the allocator uses
first-fit/best-fit allocation strategy.