[cfe-dev] std::pair not trivially copyable?
Nevin Liber via cfe-dev
cfe-dev at lists.llvm.org
Mon Aug 31 08:38:20 PDT 2020
On Wed, Aug 26, 2020 at 1:34 PM Richard Smith <richard at metafoo.co.uk> wrote:
> Making std::pair be trivially-copyable whenever possible would affect
> whether std::pair is POD for the purpose of layout, which could result in
> an ABI break for at least any code that derives from std::pair or that
> contains a [[no_unique_address]] std::pair member:
Given Key and T are trivially copyable types:
pair<const Key, T> is trivially copyable.
pair<Key, T> is not trivially copyable.
I find this surprising.
And if we look at node handles for associative containers:
<https://eel.is/c++draft/container.node.overview#4> the standard says: "If
a user-defined specialization of pair exists for pair<const Key, T> or
pair<Key, T>, where Key is the container's key_type and T is the
container's mapped_type, the behavior of operations involving node handles
I presumed that was done so standard library implementations could type pun
between pair<const Key, T> and pair<Key, T> in their implementations of
Is this just not a problem in practice?
Nevin ":-)" Liber <mailto:nevin at cplusplusguy.com <nevin at eviloverlord.com>>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev