Bug 20496 – chunkby should support ref predicates

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-01-10T04:40:04Z
Last change time
2020-04-26T16:53:17Z
Keywords
pull
Assigned to
No Owner
Creator
Steven Schveighoffer

Comments

Comment #0 by schveiguy — 2020-01-10T04:40:04Z
auto r = [1,1,1,2,2,2,3,3,3]; writeln(r.chunkBy!((ref e1, ref e2) => e1 == e2)); Error: static assert: "chunkBy expects either a binary predicate or a unary predicate on range elements of type: int" The issue is that the test is using ElementType!Range.init as the parameters to the binary function. A workaround is to use auto ref (as the actual usage will be with lvalues).
Comment #1 by dlang-bot — 2020-04-26T01:21:18Z
@MoonlightSentinel created dlang/phobos pull request #7459 "Fix Issue 20496 - chunkby should support ref predicate" fixing this issue: - Fix Issue 20496 - chunkby should support ref predicate Provide an lvalue when checking the predicate https://github.com/dlang/phobos/pull/7459
Comment #2 by dlang-bot — 2020-04-26T02:28:53Z
dlang/phobos pull request #7459 "Fix Issue 20496 - chunkby should support ref predicate" was merged into master: - 8fd3b6d3a538ed347855b3fb046028b2f195bda6 by MoonlightSentinel: Fix Issue 20496 - chunkby should support ref predicate Provide an lvalue when checking the predicate https://github.com/dlang/phobos/pull/7459
Comment #3 by schveiguy — 2020-04-26T16:53:17Z
Thanks! Now I just have to remember which code I added this workaround to... ;)