C++ Logo

std-proposals

Advanced search

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

From: Edward Catmur <ecatmur_at_[hidden]>
Date: Fri, 20 May 2022 17:29:22 -0600
On Fri, 20 May 2022 at 08:23, Thiago Macieira <thiago_at_[hidden]> wrote:

> On Friday, 20 May 2022 06:01:58 PDT Edward Catmur wrote:
> > And if we don't get the ability to pass smart pointers in registers, and
> to
> > pass around relocate-only types and use them without gymnastics, then
> > there's really no point in this proposal at all.
>
> I disagree. There's a lot of value in doing relocation for dynamic-storage
> objects (i.e., inside of containers). THAT is what I'd like to see solved
> in
> the first place, because it's something we already do in a lot of
> containers,
> most aggressively in QVector. Standardising it would be very welcome.
>

That's a very good point, and I'm embarrassed to have not seen it. Would
it be viable to make a path for implementors to provide a facility for
libraries to opt out of the ABI break on function argument passing?

How about making the relocation mechanism on function parameters
implementation-defined (i.e. the implementation is permitted to select
move+destroy, even if a relocator proper is also available); then compilers
can create an attribute [[no_relocate_abi]] (possibly standardized,
although I'm not sure that's necessary), and libraries can put that
attribute on classes (or their relocate operators) if they want efficient
relocation available to containers but to still use the old ABI for
function argument passing. The attribute would need to propagate from bases
and members to the inheriting or containing class.

Received on 2022-05-20 23:29:35