<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">On Tue, Aug 25, 2020 at 4:37 PM David Blaikie via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</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"><br></div><div class="gmail_quote"><div>From what I can tell, reading this ( <a href="https://stackoverflow.com/questions/58283694/why-is-pair-of-const-trivially-copyable-but-pair-is-not" target="_blank">https://stackoverflow.com/questions/58283694/why-is-pair-of-const-trivially-copyable-but-pair-is-not</a> ) and the C++17 spec, it just doesn't specify the copy and move assignment operators as defaulted, or say anything about their triviality, so they aren't trivial even for trivial types. Perhaps an oversight when thinking about the other complexities of when they shuold be deleted. </div></div></div></blockquote><div><br></div><div>In general, move/copy assignment cannot be defaulted for pair, because assignment of reference types has meaning:</div><div><br></div><div><font face="monospace">int i = 2;</font></div><div><font face="monospace">int j = 3;</font></div><div><font face="monospace">std::pair<int&, int> p1(i, 5); </font></div><div><font face="monospace">std::pair<int&, int> p2(j, 7);</font></div><div><font face="monospace">p2 = p1;  // j now has the value 2</font></div><div><font face="monospace"><br></font></div><div><font face="monospace"><br></font></div><div><div style="color:rgb(0,0,0)"><font face="monospace">struct A</font></div><div style="color:rgb(0,0,0)"><font face="monospace">{</font></div><div style="color:rgb(0,0,0)"><font face="monospace">    A(int& r_, int i_) : r(r_), i(i_) {}</font></div><div style="color:rgb(0,0,0)"><font face="monospace">    int& r;</font></div><div style="color:rgb(0,0,0)"><font face="monospace">    int i;</font></div><div style="color:rgb(0,0,0)"><font face="monospace">};</font></div><div style="color:rgb(0,0,0)"><font face="monospace"><br></font></div></div><div style="color:rgb(0,0,0)"><div><font face="monospace">int i = 2;</font></div><div><font face="monospace">int j = 3;</font></div></div><div><font face="monospace">A a1(i, 5);</font></div><div><font face="monospace">A a2(j, 7);</font></div><div><font face="monospace">a2 = a1;  // Compile time error - deleted copy assignment operator</font></div><div><br></div><div><br></div><div>Now,  this doesn't that pair couldn't have trivial copy/move assignment operators when it holds trivially copy/move assignable types, but I don't know how much of an ABI break this would be.</div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="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></div></div></div></div>