w***@googlemail.com
2014-04-14 19:20:07 UTC
Hi, this is my first post on this group.
Is it legal that method std::string::clear() also shrinks memory
buffer? For example:
std::string str("long string");
std::cout << str.size() << ", " << str.capacity(); // print: 11, 24
str.clear();
std::cout << str.size() << ", " << str.capacity(); // print: 0, 0
Popular implementations keeps the buffer (i.e. the fourth line prints
"0, 24"), but I can't find any requirement in the standard.
w.
Is it legal that method std::string::clear() also shrinks memory
buffer? For example:
std::string str("long string");
std::cout << str.size() << ", " << str.capacity(); // print: 11, 24
str.clear();
std::cout << str.size() << ", " << str.capacity(); // print: 0, 0
Popular implementations keeps the buffer (i.e. the fourth line prints
"0, 24"), but I can't find any requirement in the standard.
w.
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]