<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">On Wed, Aug 26, 2020 at 1:34 PM Richard Smith <<a href="mailto:richard@metafoo.co.uk">richard@metafoo.co.uk</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">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: <a href="https://godbolt.org/z/GTvo4r" target="_blank">https://godbolt.org/z/GTvo4r</a></div></div></blockquote><div><br></div><div>Given Key and T are trivially copyable types:</div><div><br></div><div>pair<const Key, T> is trivially copyable.</div><div><div style="color:rgb(0,0,0)">pair<Key, T> is not trivially copyable.</div></div><div style="color:rgb(0,0,0)"><br></div><div style="color:rgb(0,0,0)">I find this surprising.</div><div style="color:rgb(0,0,0)"><br></div><div><br></div><div>And if we look at node handles for associative containers:</div><div><br></div><div>In <a href="https://eel.is/c++draft/container.node.overview#4">[container.node.overview]p4</a> 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."</div><div><br></div><div>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.</div><div><br></div><div>Is this just not a problem in practice?</div></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"> Nevin ":-)" Liber  <mailto:<a href="mailto:nevin@eviloverlord.com" target="_blank">nevin@cplusplusguy.com</a>>  +1-847-691-1404<br></div></div></div></div></div>