C
CoolPint
Is there any way I can reduce the size of internal buffer to store
characters by std::string?
After having used a string object to store large strings, the object
seems to
retain the large buffer as I found out calling by capacity().
What if I do not need all that buffer space again want to reduce the
size to
a smaller one? I tried resize() passing a smaller size than the
current one,
but its capacity() still reports the old big size.
Here is a very contrived situation:
std::string msg;
msg.resize(10000);
// do whatever with the large buffer
msg.resize(80);
// I don't want the large buffer anymore
msg.capacity();
// but still the buffer seems to hold large space.
Or am I trying to do something I should not?
If there is a way to do this, I would love to learn about it.
If I am not "supposed" to do this, then I would like to know the
reasons behind.
Thank you in advance for your help and time.
characters by std::string?
After having used a string object to store large strings, the object
seems to
retain the large buffer as I found out calling by capacity().
What if I do not need all that buffer space again want to reduce the
size to
a smaller one? I tried resize() passing a smaller size than the
current one,
but its capacity() still reports the old big size.
Here is a very contrived situation:
std::string msg;
msg.resize(10000);
// do whatever with the large buffer
msg.resize(80);
// I don't want the large buffer anymore
msg.capacity();
// but still the buffer seems to hold large space.
Or am I trying to do something I should not?
If there is a way to do this, I would love to learn about it.
If I am not "supposed" to do this, then I would like to know the
reasons behind.
Thank you in advance for your help and time.