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 <email@example.com>
Sent: October 11, 2021 2:19:59 PM GMT+01:00
To: "firstname.lastname@example.org" <email@example.com>
Cc: Victor Khomenko <firstname.lastname@example.org>, Alex <email@example.com>
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,
From: Std-Discussion <firstname.lastname@example.org> On Behalf Of
Alex via Std-Discussion
Sent: Monday, October 11, 2021 1:53 PM
Cc: Alex <email@example.com>
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.
Std-Discussion mailing list