fix Issue 8055 - std.algorithm.move corrupts moved object field

This commit is contained in:
k-hara 2012-05-07 11:32:12 +09:00
parent 5bbfed888b
commit 279963c9d0

View file

@ -1406,11 +1406,37 @@ unittest
/// Ditto
T move(T)(ref T src)
{
T result=void;
T result = T.init;
move(src, result);
return result;
}
unittest//Issue 6217
{
auto x = map!"a"([1,2,3]);
x = move(x);
}
unittest// Issue 8055
{
static struct S
{
int x;
~this()
{
assert(x == 0);
}
}
S foo(S s)
{
return move(s);
}
S a;
a.x = 0;
auto b = foo(a);
assert(b.x == 0);
}
// moveAll
/**
For each element $(D a) in $(D src) and each element $(D b) in $(D
@ -8791,9 +8817,3 @@ unittest
//writeln(b[0]);
assert(b[0] == tuple(4.0, 2u));
}
unittest//Issue 6217
{
auto x = map!"a"([1,2,3]);
x = move(x);
}