C++ Logo


Advanced search

Re: [std-proposals] Custom call convention per type

From: Arthur O'Dwyer <arthur.j.odwyer_at_[hidden]>
Date: Fri, 29 Jul 2022 14:20:15 -0400
On Thu, Jul 28, 2022 at 5:26 PM Marcin Jaczewski via Std-Proposals <
std-proposals_at_[hidden]> wrote:

> Currently there are multiple problems linked to lifetime of function
> parameters.
> Simply current default behavior does not fit all corner cases.
> Example is `std::unique` that generates subpar code because the call
> site is a firewall that prevents the compiler to see at once destructor
> and move operation.

Can you elaborate on this? I admit I've never thought about `std::unique`
in this context before; but now that I have spent an hour or so thinking
about it, I still don't see how its current behavior can be improved. One
might rewrite `std::unique` to use swap instead of move-assignment, but one
can't really rewrite it to use relocation because `std::unique` is never
responsible for destroying anything. N objects go in, N objects come out
(and in the same memory locations, too).

What would you do differently here?


Received on 2022-07-29 18:20:27