mirror of
https://github.com/dlang/phobos.git
synced 2025-05-09 13:02:30 +03:00
fix Issue 8055 - std.algorithm.move corrupts moved object field
This commit is contained in:
parent
5bbfed888b
commit
279963c9d0
1 changed files with 27 additions and 7 deletions
|
@ -1406,11 +1406,37 @@ unittest
|
||||||
/// Ditto
|
/// Ditto
|
||||||
T move(T)(ref T src)
|
T move(T)(ref T src)
|
||||||
{
|
{
|
||||||
T result=void;
|
T result = T.init;
|
||||||
move(src, result);
|
move(src, result);
|
||||||
return 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
|
// moveAll
|
||||||
/**
|
/**
|
||||||
For each element $(D a) in $(D src) and each element $(D b) in $(D
|
For each element $(D a) in $(D src) and each element $(D b) in $(D
|
||||||
|
@ -8791,9 +8817,3 @@ unittest
|
||||||
//writeln(b[0]);
|
//writeln(b[0]);
|
||||||
assert(b[0] == tuple(4.0, 2u));
|
assert(b[0] == tuple(4.0, 2u));
|
||||||
}
|
}
|
||||||
|
|
||||||
unittest//Issue 6217
|
|
||||||
{
|
|
||||||
auto x = map!"a"([1,2,3]);
|
|
||||||
x = move(x);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue