mirror of
https://github.com/dlang/phobos.git
synced 2025-05-01 15:40:36 +03:00
std.range.choose: call payload postblit correctly
Fixes bugzilla issue 15708
This commit is contained in:
parent
bfe2a18389
commit
837b7deb7d
1 changed files with 24 additions and 1 deletions
|
@ -1882,7 +1882,7 @@ private struct ChooseResult(Ranges...)
|
||||||
this(this)
|
this(this)
|
||||||
{
|
{
|
||||||
actOnChosen!((ref r) {
|
actOnChosen!((ref r) {
|
||||||
static if (hasElaborateCopyConstructor!(typeof(r))) r.__postblit();
|
static if (hasElaborateCopyConstructor!(typeof(r))) r.__xpostblit();
|
||||||
})(this);
|
})(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2177,6 +2177,29 @@ pure @safe nothrow unittest
|
||||||
assert(chosen2.front.v == 4);
|
assert(chosen2.front.v == 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://issues.dlang.org/show_bug.cgi?id=15708
|
||||||
|
@safe unittest
|
||||||
|
{
|
||||||
|
static struct HasPostblit
|
||||||
|
{
|
||||||
|
this(this) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct Range
|
||||||
|
{
|
||||||
|
bool empty;
|
||||||
|
int front;
|
||||||
|
void popFront() {}
|
||||||
|
HasPostblit member;
|
||||||
|
}
|
||||||
|
|
||||||
|
Range range;
|
||||||
|
int[] arr;
|
||||||
|
|
||||||
|
auto chosen = choose(true, range, arr);
|
||||||
|
auto copy = chosen;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Choose one of multiple ranges at runtime.
|
Choose one of multiple ranges at runtime.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue