December 30, 2018 [Issue 19525] New: Duration is not usable with zero-arg std.algorithm.sum | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=19525 Issue ID: 19525 Summary: Duration is not usable with zero-arg std.algorithm.sum Product: D Version: D2 Hardware: x86 OS: Windows Status: NEW Severity: enhancement Priority: P1 Component: phobos Assignee: nobody@puremagic.com Reporter: simen.kjaras@gmail.com Source: https://stackoverflow.com/questions/53967917/using-std-algorithm-iteration-sum-with-duration import std.algorithm : sum; import std.datetime : Duration, minutes; unittest { // Error: struct `core.time.Duration` member this is not accessible assert([1.minutes].sum() == 1.minutes); } The above code fails because sum() tries to construct Duration(0), which fails to compile. The error message (member this is not accessible) leaves something to be desired. Workaround for now: [1.minutes].sum(Duration.zero). Suggested fix: have sum() check if Seed.zero exists, and use that. -- |
Copyright © 1999-2021 by the D Language Foundation