Releasing storage of a vector

J

Jorgen Grahn

Jorgen Grahn said:
[Note that it's trivial for user code to do something like:
"if (...) v.shrink_to_fit()", to establish more refined behavior.]

In that case I'd prefer a method called unreserve(size_type) or
something -- if I have to do the work myself, I also want the full
control.

So when you release your standard, it'll be called that... :]

Naturally. It's coming soom -- I'm a committee of just one, so lead
times are short ;-)

....
As I mentioned elsewhere, this particular method seems to basically be
the committee's "OK, OK" response to complaints that performing this
often-wanted operation ("get rid of all the extra reserved space now
that I've finished filling in my vector") was clumsy in the old
standard.

My impression is that it wasn't really carefully thought out as a
general tool, just as a practical answer to those complaints. [...]

That is my impression, too[1]. And it doesn't bother me too much,
despite my whining upthread. std::vector was well designed when it
came ~20 years ago, and additions today are likely to be imperfect
patches for corner cases.

/Jorgen

[1] And there's probably a public proposal which contains the
rationale, in case someone is interested.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top