mirror of
https://github.com/dlang/phobos.git
synced 2025-04-30 07:00:37 +03:00
fix issue 18804 - std.algorithm.mutation.copy puts whole source range into target range when it should put elements
This commit is contained in:
parent
42e9d6ffb9
commit
19052b08de
1 changed files with 20 additions and 1 deletions
|
@ -414,7 +414,8 @@ if (!areCopyCompatibleArrays!(SourceRange, TargetRange) &&
|
|||
}
|
||||
else
|
||||
{
|
||||
put(target, source);
|
||||
foreach (element; source)
|
||||
put(target, element);
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
@ -535,6 +536,24 @@ $(LINK2 http://en.cppreference.com/w/cpp/algorithm/copy_backward, STL's `copy_ba
|
|||
}}
|
||||
}
|
||||
|
||||
@safe unittest // issue 18804
|
||||
{
|
||||
static struct NullSink
|
||||
{
|
||||
void put(E)(E) {}
|
||||
}
|
||||
int line = 0;
|
||||
struct R
|
||||
{
|
||||
int front;
|
||||
@property bool empty() { return line == 1; }
|
||||
void popFront() { line = 1; }
|
||||
}
|
||||
R r;
|
||||
copy(r, NullSink());
|
||||
assert(line == 1);
|
||||
}
|
||||
|
||||
/**
|
||||
Assigns `value` to each element of input range `range`.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue