www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15687] New: isInputRange/isForwardRange discriminate against

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 puremagic.com
          Reporter: tomerfiliba 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`

--
Feb 15 2016