Use endsWith.

This commit is contained in:
k-hara 2012-05-08 09:45:53 +09:00
parent dc6fb32f87
commit af50634ea7

View file

@ -1337,8 +1337,7 @@ void move(T)(ref T source, ref T target)
static if (hasElaborateDestructor!T || hasElaborateCopyConstructor!T) static if (hasElaborateDestructor!T || hasElaborateCopyConstructor!T)
{ {
static T empty; static T empty;
static if (T.tupleof[$-1].stringof.length >= "this".length && static if (T.tupleof[$-1].stringof.endsWith("this"))
T.tupleof[$-1].stringof[$-4 .. $] == "this")
{ {
// Keep original context pointer // Keep original context pointer
memcpy(&source, &empty, T.sizeof - (void*).sizeof); memcpy(&source, &empty, T.sizeof - (void*).sizeof);
@ -1416,9 +1415,7 @@ unittest
T move(T)(ref T src) T move(T)(ref T src)
{ {
T result = T.init; T result = T.init;
static if (is(T == struct) && static if (is(T == struct) && T.tupleof[$-1].stringof.endsWith("this"))
T.tupleof[$-1].stringof.length >= "this".length &&
T.tupleof[$-1].stringof[$-4 .. $] == "this")
{ {
// copy context pointer // copy context pointer
result.tupleof[$-1] = src.tupleof[$-1]; result.tupleof[$-1] = src.tupleof[$-1];