I need to frequently make a string empty and then append some chars into it. std::string::clear() may realloc Does std::string::resize(0) do realloc? The standard's words didn't garentee any about it.
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- how to split a list into a given number of sub-lis
- thread_local variables initialization
相关文章
- JSP String formatting Truncate
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
I think the best possible answer to this is the "Notes" section at http://en.cppreference.com/w/cpp/string/basic_string/clear.
And if the capacity is unchanged, that would almost certainly mean that no allocation or freeing functions are called. That's probably the best you can do, short of looking at each and every implementation you care about.