Issue 5661 - std.algorithm.move does not work on elaborate struct

This commit is contained in:
k-hara 2011-05-06 01:38:24 +09:00
parent 40dc28a235
commit fe90698c78

View file

@ -1321,11 +1321,11 @@ void move(T)(ref T source, ref T target)
{
// Most complicated case. Destroy whatever target had in it
// and bitblast source over it
static if (is(typeof(target.__dtor()))) target.__dtor();
static if (hasElaborateDestructor!T) typeid(T).destroy(&target);
memcpy(&target, &source, T.sizeof);
// If the source defines a destructor or a postblit hook, we must obliterate the
// object in order to avoid double freeing and undue aliasing
static if (is(typeof(source.__dtor())) || is(typeof(source.__postblit())))
static if (hasElaborateDestructor!T || hasElaborateCopyConstructor!T)
{
static T empty;
memcpy(&source, &empty, T.sizeof);