When I create a std::string
member variable in a class, will there be already a default memory allocated when it is instantiated? Or does std::string
defer allocation until it is actually used?
I'm using Visual Studio 2010 at the moment, and I noticed, when I create an empty string with:
std::string s0;
std::string s1 = "";
Both have capacity == 15 set. So does this mean that it already allocated 15 bytes of memory? If yes, can I prevent this so that no memory is allocated?
Would this be implementation specific across different compilers?