[Issue 15687] New: isInputRange/isForwardRange discriminate against void[]

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Feb 15 06:53:18 PST 2016


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

          Issue ID: 15687
           Summary: isInputRange/isForwardRange discriminate against
                    void[]
           Product: D
           Version: D2
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: tomerfiliba at gmail.com

I tried using `chunks(data, size)` when data was const(void)[], but it didn't
work. When I changed it to const(ubyte)[] everything was OK. It boils down to
the fact that 

pragma(msg, isInputRange!(void[]));    // false
pragma(msg, isInputRange!(ubyte[]));   // true

which uses

template isInputRange(R) {
    R r = R.init;
    r.popFront();
}

which guards against it:

std.range.primitives.popFront(T)(ref T[] a) if (!isNarrowString!(T[]) &&
!is(T[] == void[]))

I'm not sure if it's a bug or not, but I think chunks(void[]) ought to work as
it returns `void[]`, not `void`

--


More information about the Digitalmars-d-bugs mailing list