pkirk25 wrote in message
<11**********************@f16g2000cwb.googlegroups .com>...
vector<stringbuf_string;
buf_string.reserve(256);
vector<intbuf_mat_prices;
buf_mat_prices.reserve(1000);
During loops I fill the vectors and then I empty them with commands
like buf_string.clear();
buf_mat_prices.clear();
Does this mean that the memory allocation returns to default or is my
original reserve still in place?
// Prove it for yourself: // using std::cout;
cout << buf_string.size() << std::endl; // S/B '0'
cout << buf_string.capacity() << std::endl; // clear() doesn't resize
cout << buf_mat_prices.size() << std::endl; // S/B '0'
cout << buf_mat_prices.capacity() << std::endl; // clear() doesn't
resize
You can re-size the vector by using (surprise!):
buf_string.resize(25);
cout << buf_string.size() << std::endl;
cout << buf_string.capacity() << std::endl;
That help?
--
Bob R
POVrookie