www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14479] New: isInputRange returns false on a slice of

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

          Issue ID: 14479
           Summary: isInputRange returns false on a slice of noncopyables.
           Product: D
           Version: unspecified
          Hardware: x86_64
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: Phobos
          Assignee: nobody puremagic.com
          Reporter: block8437 gmail.com

Example: http://dpaste.dzfl.pl/644619159a4f

import std.range, std.stdio;

struct Noncopyable {
    int num;
     disable this(this);
}


void main() {
    writeln(isInputRange!(Noncopyable[]));
}

It is believed that this problem is caused by r.front needing to return a value
instead of a reference, in contradiction of the docs, which say "r.front
returns the current element in the range.  It may return by value or by
reference."

This prevents using range utility functions like chain() on arrays of
noncopyables, such as in http://dpaste.dzfl.pl/3993a52c54df .

--
Apr 21 2015