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.