When I create a member variable std::stringin the class, will the default memory be already allocated when it is created? Or std::stringdelay the selection until actual use?
I am using Visual Studio 2010 at the moment, and I noticed when I create an empty string using
std::string s0;
std::string s1 = "";
Both have a capacity of == 15. Does this mean that it has already allocated 15 bytes of memory? If so, can I prevent this from being allocated?
Will this implementation be specific to different compilers?
source
share