In a recent proposal vector will gain range construction and append operations. This will allow safely expressing operations that would otherwise require unchecked_emplace_back.

For example a reserve + push_back loop can be replaced by an append with a sized input range. The vector can internally reserve once based on the size, then it can do the equivalent of unchecked_emplace_back in a loop.


From: Victor Khomenko via Std-Discussion <std-discussion@lists.isocpp.org>
Sent: October 11, 2021 2:19:59 PM GMT+01:00
To: "std-discussion@lists.isocpp.org" <std-discussion@lists.isocpp.org>
Cc: Victor Khomenko <victor.khomenko@newcastle.ac.uk>, Alex <orangechicken@vivaldi.net>
Subject: Re: [std-discussion] Thoughts on making unchecked_emplace_back a public function for vector?

[It's best to use std-proposals list as you're trying to propose a new feature (this list is mostly about the current standard, things like wording/defects).]

I tried to propose something similar back in 2013, see the discussion here:

In the course of the discussion, push_back_ was (sensibly) renamed into unchecked_push_back.

My feeling was that people generally disliked this idea, so I didn't get to writing a proposal.

All the best,

-----Original Message-----
From: Std-Discussion <std-discussion-bounces@lists.isocpp.org> On Behalf Of
Alex via Std-Discussion
Sent: Monday, October 11, 2021 1:53 PM
To: std-discussion@lists.isocpp.org
Cc: Alex <orangechicken@vivaldi.net>
Subject: [std-discussion] Thoughts on making unchecked_emplace_back a public
function for vector?

⚠ External sender. Take care when opening links or attachments. Do not
provide your login details.

I've been playing around with a slightly modified version of the standard vector
header for a while now which makes "unchecked_emplace_back" a usable
function as well as some other utility functions I've added. There's more than a
few cases I've had so far to use it and net a bit of a bonus bit of performance.

Rough idea is a function (or functions) which assumes a bit more responsibility
on the side of the user, but it short cuts some redundant checks on the
containers capacity. In playing around I actually found a different way to go
about this which was way faster, however I think it might be a stretch because it
would pretty much allow full access over all the vector's members.

The only thing I'm really wondering is whether this is the right email to send this
to, some places suggested floating standards proposals here, wasn't exactly
clear. In any case, thoughts? The edits for reference to existing headers are
extremely minor, usually because an unchecked version of emplace_back is
already written as a utility function for emplace_back to work. I also have zero
reference for whether this has been brought up before.

-Alex Anderson
Std-Discussion mailing list
Std-Discussion mailing list