Namespaces
Variants
Views
Actions

Talk:cpp/string/basic string/clear

From cppreference.com

The requirement to keep the capacity unchanged appears to be unfounded, could you site the source, please? 216.239.45.80 11:43, 16 October 2014 (PDT) Ruslan aruslan@me.com

Per 21.4.4[string.capacity]/15, it behaves as erase(begin(), end()), which is defined in 21.4.6.5[string::erase]/10. Neither paragraph lists a change to the capacity as an effect or a postcondition (compare to Effects of reserve() or shrink_to_fit()). Also, erase is not allowed to reallocate in general (thanks for bringing attention to the page though, the end iterator note was wrong) --Cubbi (talk) 12:09, 16 October 2014 (PDT)