On 6/2/15 4:14 PM, Timon Gehr wrote:
On 06/03/2015 01:07 AM, Andrei Alexandrescu wrote:
On 6/2/15 3:42 PM, Steven Schveighoffer wrote:
On 6/2/15 6:14 PM, Andrei Alexandrescu wrote:
On 6/2/15 2:57 PM, Timon Gehr wrote:
OK. What about copying in instead of out?

If the appropriate type has already been constructed, assignment
suffices. Otherwise, emplace(&target, source) is needed. -- Andrei

My concern is if you copy the enclosing type. This means you have
already copied the bits, and the postblit of the enclosing type is
responsible for calling the postblit of the valid union member (as
defined by the semantics of the type). How does it do that?

Copying unions as a whole won't do any miracles. Just memcpy. -- Andrei


Copy is memcpy & postblit.

If the bit-copy has already been done (e.g. execution is inside a
postblit) emplace(&f,f) seems wasteful.

Oh, I only now understood the question. Yes, it's possible to only call postblit if defined:

static if (hasElaborateCopyConstructor!T)
    tvar.__postblit();


Andrei

Reply via email to