[cfe-dev] std::pair not trivially copyable?
Nevin Liber via cfe-dev
cfe-dev at lists.llvm.org
Thu Aug 27 23:15:21 PDT 2020
On Wed, Aug 26, 2020 at 1:34 PM Richard Smith <richard at metafoo.co.uk> wrote:
> This is certainly not something we could do for the libc++ stable ABI.
> Maybe for the unstable ABI, but given the above change only makes layout
> worse, it's not clear that there would be a strong motivation. We already
> give std::pair trivial copy/move construction and trivial destruction
> whenever possible, so we can pass and return it efficiently.
Our motivation is that in the heterogeneous computing world (for instance
in SYCL/DPC++), trivially copyable is used to copy things between hosts and
devices (CPU and GPU).
There is an expectation that standard library wrapper types (pair, tuple,
optional, variant, etc.) don't break trivialness. This is especially true
of pair, which most people expect to be "just a struct" of two public types.
Nevin ":-)" Liber <mailto:nevin at cplusplusguy.com <nevin at eviloverlord.com>>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev