mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 22:21:09 +03:00
Fix intentional discarding of return value in topN
This fixes a warning one gets when compiling with warnings enabled: "phobos/std/algorithm/sorting.d(3122): Warning: calling testcase.foo.__lambda1 without side effects discards return value of type bool, prepend a cast(void) if intentional" Testcase that fails compilation with `-w`: ``` import std.algorithm.sorting; auto foo() { int[] v = [ 25, 7, 9, 2, 0, 5, 21 ]; return topN!((a, b) => a > b)(v, 100); } ```
This commit is contained in:
parent
5964600c8d
commit
acb4c7838c
1 changed files with 1 additions and 1 deletions
|
@ -3119,7 +3119,7 @@ if (isRandomAccessRange!(Range) && hasLength!Range && hasSlicing!Range)
|
|||
// Workaround for https://issues.dlang.org/show_bug.cgi?id=16528
|
||||
// Safety checks: enumerate all potentially unsafe generic primitives
|
||||
// then use a @trusted implementation.
|
||||
binaryFun!less(r[0], r[r.length - 1]);
|
||||
cast(void) binaryFun!less(r[0], r[r.length - 1]);
|
||||
import std.algorithm.mutation : swapAt;
|
||||
r.swapAt(size_t(0), size_t(0));
|
||||
static assert(is(typeof(r.length) == size_t));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue