mirror of
https://github.com/dlang/phobos.git
synced 2025-04-27 21:51:40 +03:00
Fix bugzilla issue 24596: std.typecons.Rebindable2: Don't destroy classes! Only destroy structs! (#9012)
This commit is contained in:
parent
aee2a7b760
commit
539dc473ba
2 changed files with 19 additions and 1 deletions
|
@ -3873,6 +3873,21 @@ if (isInputRange!Range && !isInfinite!Range &&
|
|||
assert([BigInt(2), BigInt(3)].maxElement == BigInt(3));
|
||||
}
|
||||
|
||||
// https://issues.dlang.org/show_bug.cgi?id=24596
|
||||
@safe unittest
|
||||
{
|
||||
static class A {
|
||||
int i;
|
||||
int getI() @safe => i;
|
||||
this(int i) @safe { this.i = i; }
|
||||
}
|
||||
auto arr = [new A(2), new A(3)];
|
||||
|
||||
arr.maxElement!(a => a.getI);
|
||||
|
||||
assert(arr[0].getI == 2);
|
||||
}
|
||||
|
||||
// minPos
|
||||
/**
|
||||
Computes a subrange of `range` starting at the first occurrence of `range`'s
|
||||
|
|
|
@ -3125,7 +3125,10 @@ private:
|
|||
}
|
||||
|
||||
// call possible struct destructors
|
||||
.destroy!(No.initialize)(*cast(T*) &this.data);
|
||||
static if (is(T == struct))
|
||||
{
|
||||
.destroy!(No.initialize)(*cast(T*) &this.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue