[Issue 20496] New: chunkby should support ref predicates

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jan 10 04:40:04 UTC 2020


          Issue ID: 20496
           Summary: chunkby should support ref predicates
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: schveiguy at yahoo.com

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).


More information about the Digitalmars-d-bugs mailing list