www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20496] New: chunkby should support ref predicates

https://issues.dlang.org/show_bug.cgi?id=20496

          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 puremagic.com
          Reporter: schveiguy 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).

--
Jan 09 2020