<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"Consolas\,";}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0563C1;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Hi all-<o:p></o:p></p>
<p class="MsoNormal">I’m attempting to implement CWG1734[0], which changes the definition of TriviallyCopyable[1]. My motivating examples that need to pass are[2]:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="background:#FFFFFE"><span style="font-family:"Consolas,",serif;color:blue">struct</span><span style="font-family:"Consolas,",serif;color:black"> A{};<o:p></o:p></span></p>
<p class="MsoNormal" style="background:#FFFFFE"><span style="font-family:"Consolas,",serif;color:blue">struct</span><span style="font-family:"Consolas,",serif;color:black"> C : A {<o:p></o:p></span></p>
<p class="MsoNormal" style="background:#FFFFFE"><span style="font-family:"Consolas,",serif;color:blue">const</span><span style="font-family:"Consolas,",serif;color:black"> A a;<o:p></o:p></span></p>
<p class="MsoNormal" style="background:#FFFFFE"><span style="font-family:"Consolas,",serif;color:black">};<o:p></o:p></span></p>
<p class="MsoNormal" style="background:#FFFFFE"><span style="font-family:"Consolas,",serif;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="background:#FFFFFE"><span style="font-family:"Consolas,",serif;color:blue">struct</span><span style="font-family:"Consolas,",serif;color:black"> A{};<o:p></o:p></span></p>
<p class="MsoNormal" style="background:#FFFFFE"><span style="font-family:"Consolas,",serif;color:blue">struct</span><span style="font-family:"Consolas,",serif;color:black"> D : A {<o:p></o:p></span></p>
<p class="MsoNormal" style="background:#FFFFFE"><span style="font-family:"Consolas,",serif;color:blue">const</span><span style="font-family:"Consolas,",serif;color:black"> A a;<o:p></o:p></span></p>
<p class="MsoNormal" style="background:#FFFFFE"><span style="font-family:"Consolas,",serif;color:black">D& operator=(D&&) = default;<o:p></o:p></span></p>
<p class="MsoNormal" style="background:#FFFFFE"><span style="font-family:"Consolas,",serif;color:black">};<o:p></o:p></span></p>
<p class="MsoNormal" style="background:#FFFFFE"><span style="font-family:"Consolas,",serif;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="background:#FFFFFE"><span style="font-family:"Consolas,",serif;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="background:#FFFFFE"><span style="font-family:"Consolas,",serif;color:blue">struct</span><span style="font-family:"Consolas,",serif;color:black"> E {<o:p></o:p></span></p>
<p class="MsoNormal" style="background:#FFFFFE"><span style="font-family:"Consolas,",serif;color:black"> E &</span><span style="font-family:"Consolas,",serif;color:blue">operator</span><span style="font-family:"Consolas,",serif;color:black">=(E&&)=</span><span style="font-family:"Consolas,",serif;color:blue">delete</span><span style="font-family:"Consolas,",serif;color:black">;<o:p></o:p></span></p>
<p class="MsoNormal" style="background:#FFFFFE"><span style="font-family:"Consolas,",serif;color:black">};<o:p></o:p></span></p>
<p class="MsoNormal" style="background:#FFFFFE"><span style="font-family:"Consolas,",serif;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal" style="background:#FFFFFE"><span style="font-family:"Consolas,",serif;color:blue">static_assert</span><span style="font-family:"Consolas,",serif;color:black">(__is_trivially_copyable(C),</span><span style="font-family:"Consolas,",serif;color:#A31515">""</span><span style="font-family:"Consolas,",serif;color:black">);<o:p></o:p></span></p>
<p class="MsoNormal" style="background:#FFFFFE"><span style="font-family:"Consolas,",serif;color:blue">static_assert</span><span style="font-family:"Consolas,",serif;color:black">(__is_trivially_copyable(D),</span><span style="font-family:"Consolas,",serif;color:#A31515">""</span><span style="font-family:"Consolas,",serif;color:black">);<o:p></o:p></span></p>
<p class="MsoNormal" style="background:#FFFFFE"><span style="font-family:"Consolas,",serif;color:blue">static_assert</span><span style="font-family:"Consolas,",serif;color:black">(__is_trivially_copyable(E),</span><span style="font-family:"Consolas,",serif;color:#A31515">""</span><span style="font-family:"Consolas,",serif;color:black">);<o:p></o:p></span></p>
<p class="MsoNormal" style="background:#FFFFFE"><span style="font-family:"Consolas,",serif;color:black"><o:p> </o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Currently the 1<sup>st</sup> and 2<sup>nd</sup> static asserts fail. However, because of CWG1734 all 3 should pass (based on my reading). ‘C’ has its move assignment deleted, as does D, with E explicitly deleted.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">However, we don’t seem to have a good way of validating each of these. I identified has(Non)TrivialMoveAssignment and data().DefaultedMoveAssignmentIsDeleted as the possible things, however there isn’t really a bit of logic that works
for that. <o:p></o:p></p>
<p class="MsoNormal"><br>
C: <o:p></o:p></p>
<p class="MsoNormal">hasTrivialMoveAssignment : false<o:p></o:p></p>
<p class="MsoNormal">hasNonTrivialMoveAssignment : true<o:p></o:p></p>
<p class="MsoNormal">data().DefaultedMoveAssignmentIsDeleted : true<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">D:<o:p></o:p></p>
<p class="MsoNormal">hasTrivialMoveAssignment : false<o:p></o:p></p>
<p class="MsoNormal">hasNonTrivialMoveAssignment : true<o:p></o:p></p>
<p class="MsoNormal">data().DefaultedMoveAssignmentIsDeleted : false<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">E:<o:p></o:p></p>
<p class="MsoNormal">hasTrivialMoveAssignment : true<o:p></o:p></p>
<p class="MsoNormal">hasNonTrivialMoveAssignment : false<o:p></o:p></p>
<p class="MsoNormal">data().DefaultedMoveAssignmentIsDeleted : false<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">There seems to be a piece of information that I don’t have yet, or a piece of logic that I need to figure out, but I’m not sure what it could be yet. Can anyone give me a hint as to the logic? Do we need to capture the =delete in a similar
flag in the DefinitionData struct? It seems that we need a hasDeleted(Copy/Move)(Constructor/Assignment) that includes the test for defaulted deleted AND trivially marked delete.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">-Erich<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">[0] https://wg21.cmeerw.net/cwg/issue1734<o:p></o:p></p>
<p class="MsoNormal">[1] <a href="https://en.cppreference.com/w/cpp/named_req/TriviallyCopyable">
https://en.cppreference.com/w/cpp/named_req/TriviallyCopyable</a><o:p></o:p></p>
<p class="MsoNormal">[2] <a href="https://godbolt.org/z/PYGb-r">https://godbolt.org/z/PYGb-r</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>