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

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Feb 16 13:23:42 PST 2016


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

Jonathan M Davis <issues.dlang at jmdavisProg.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |issues.dlang at jmdavisProg.co
                   |                            |m

--- Comment #2 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
Well, while I can see why some range-based functions might conceptually work
with void[], they won't in general, because of the issue with not being able to
have a valid front. So, I'm very much inclined to argue that this is not a bug
and that it's just life with ranges. To do otherwise would require either
special casing void[] with some functions or creating a new kind of range
concept that can be iterated over but not examined - and thus has popFront and
empty but not front - and I don't think that that's worth it. Casting to
const(ubyte)[] should work just fine, and if you really don't want to do that,
you can create a wrapper range with whatever you want for the element type and
which has assert(0) in front to make sure that it's not called - and then
presumably converts nicely to void[] after you've iterated however much you
want to iterate.

--


More information about the Digitalmars-d-bugs mailing list