c++ - Does the standard guarantee, that std::string::resize will not do reallocate memory, if the new size is less than or equal to as the old one? -
i need make string empty , append chars it. std::string::clear() may realloc std::string::resize(0) realloc? standard's words didn't garentee it.
i think best possible answer "notes" section @ http://en.cppreference.com/w/cpp/string/basic_string/clear.
unlike std::vector::clear, c++ standard not explicitly require capacity unchanged function, existing implementations not change capacity.
and if capacity unchanged, mean no allocation or freeing functions called. that's best can do, short of looking @ each , every implementation care about.
Comments
Post a Comment