<div dir="auto"><div><div class="gmail_quote"><div dir="ltr">On Thu., 26 Jul. 2018, 2:45 am RazvanN via Digitalmars-d, <<a href="mailto:digitalmars-d@puremagic.com">digitalmars-d@puremagic.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
void opAssign(ref $q1 S rhs)    // version 3<br>
{<br>
     S tmp1 = rhs;                // call copy constructor<br>
     void[S.sizeof] tmp2 = void;<br>
<br>
     // swapbits(tmp1, this);<br>
     memcpy(tmp2, this);<br>
     memcpy(this, tmp1);<br>
     memcpy(tmp1, tmp2);<br>
<br>
     tmp1.__dtor();<br>
}<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Uh oh, you feel for the trap!</div><div dir="auto">You can't destruct like this.</div><div dir="auto">__xdtor at least, but even then it's not so simple.</div><div dir="auto"><br></div><div dir="auto">I think emplace() should be lifted to druntime, and destroy() should be complemented by destruct(), which will not post-assign .init.</div></div>