[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:
> https://godbolt.org/z/GTvo4r
>
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:
In [container.node.overview]p4
<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
is undefined."
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
node handles.
Is this just not a problem in practice?
--
Nevin ":-)" Liber <mailto:nevin at cplusplusguy.com <nevin at eviloverlord.com>>
+1-847-691-1404
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20200831/b9aa26ab/attachment.html>
More information about the cfe-dev
mailing list