[Issue 14478] isInputRange failed to recognize some ranges

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Feb 10 13:49:34 PST 2016


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

Lars T. Kyllingstad <bugzilla at kyllingen.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla at kyllingen.net

--- Comment #13 from Lars T. Kyllingstad <bugzilla at kyllingen.net> ---
I use a lot of noncopyable types, and I also think it is really important that
they work with ranges.

The comparison with C++ containers is somewhat tenuous, as containers generally
manage their own elements and therefore need to be able to move them around.
Ranges, on the other hand, typically do *not* own their elements, they are just
views on someone else's.  Consider this:

    struct S
    {
        @disable this(this);
    }

    S[9] array;
    auto slice = array[1 .. 5];

You would be very surprised if that last line didn't work, right?  Ranges are
just a higher-order abstraction of slices. 

Element copyability should most definitely be an orthogonal requirement to
range-ness.  As Peter pointed out, this will strictly be a loosening of a
constraint, and as such will not break any existing code.  To me it seems like
a no-brainer.

--


More information about the Digitalmars-d-bugs mailing list