mirror of
https://github.com/dlang/phobos.git
synced 2025-04-30 15:10:46 +03:00
Issue 5661 - std.algorithm.move does not work on elaborate struct
This commit is contained in:
parent
40dc28a235
commit
fe90698c78
1 changed files with 2 additions and 2 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue