www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - =?UTF-8?B?W0lzc3VlIDI0ODAxXSBOZXc6IGBSZWZSYW5nZWAgZG9lc27igJl0?=

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

          Issue ID: 24801
           Summary: `RefRange` doesn’t work if range primitives are not
                    `const`
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: ogion.art gmail.com

import std.range;

unittest {
    static struct R
    {
        int front() => 0;
        void popFront() {}
        bool empty() => false;
    }
    R range;
    auto r = RefRange!R(&range);
}

src/phobos/std/range/package.d(12407): Error: mutable method
`onlineapp.__unittest_L3_C1.R.front` is not callable using a `const` object
app.d(6):        Consider adding `const` or `inout` here
src/phobos/std/range/package.d(12433): Error: mutable method
`onlineapp.__unittest_L3_C1.R.empty` is not callable using a `const` object
app.d(8):        Consider adding `const` or `inout` here
app.d(11): Error: template instance `std.range.RefRange!(R)` error
instantiating

--
Oct 09