[Issue 5661] std.algorithm.move does not work on elaborate struct
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Feb 27 21:34:15 PST 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5661
Kenji Hara <k.hara.pg at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |patch
--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> 2011-02-27 21:31:26 PST ---
Following patch fixes this bug:
std/algorithm.d | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/std/algorithm.d b/std/algorithm.d
index 0a1e496..ed05c85 100644
--- a/std/algorithm.d
+++ b/std/algorithm.d
@@ -1057,11 +1057,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);
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list