News for hackers. Stuff that matters.
Re:Appending to an std:string character-by-character: how do... by rerdavies on Friday October 27, 2023 @01:43AM (#38035096)
Fwiw, they seem to imply (admit) that you can get precise growth using

    s.reserve(n); // precise allocation.
    s.resize(n);  // doesn't grow.
or

    s.reserve(n);
    s.append(....); // a fairly robust set of overloads.

That being said... I completely agree that imprecise resize() is unfortunate, and unexpected. I'm going to have to keep an eye out for how I use resize() going forward. (Not a lot, admittedly).

There are no comments on this comment yet.