C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Relocation in C++

From: Giuseppe D'Angelo <giuseppe.dangelo_at_[hidden]>
Date: Mon, 19 Dec 2022 21:21:39 +0100
On 19/12/2022 18:05, Edward Catmur via Std-Proposals wrote:
> This last point seems very unreasonable to me -- it sounds like the tag
> should be the opt-in to the ABI break (a bit like [[trivial_abi]] is),
> not opt-out.
>
>
> The same goes for adding any of the Rule of Five special member
> functions. Basically, Don't Do That if you want to preserve ABI.

If I have a type that honors the RO3, and I "optimize" it by adding move
operations (e.g.: std::vector), that doesn't break ABI. Does such a type
benefit from a relocation constructor, or would it be pointless to add
one? Does the eventual benefit outweigh the ABI break that would be
brought in by the constructor?

If I have a move-only type (e.g. unique_ptr), would I want to add a
relocation constructor to it? If yes, would I want the associated ABI
break, considering we live in a world where people don't want the ABI
break that would improve its moves and we could obtain _today_?

Or is relocation just meant to introduce new *kind* of types --
relocatable-but-non-movable types, so types that don't exist today, so
there's actually ... nothing to break?

(Again, apologies for the straightforward questions, please just leave
me a link to a paper and I'll read the fine printing :-)).


Thank you,
-- 
Giuseppe D'Angelo

Received on 2022-12-19 20:21:42