[Issue 12893] Cannot create a SortedRange from inout array

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


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |spec
                 CC|                            |bugzilla at kyllingen.net
          Component|phobos                      |dmd
           Hardware|x86                         |All
                 OS|Windows                     |All

--- Comment #2 from Lars T. Kyllingstad <bugzilla at kyllingen.net> ---
I think these are problems with the design of 'inout' rather than with Phobos. 
Perhaps it could be worked around with careful use of std.typecons.Unqual, but
that seems unfeasible to do, as there are *a lot* of types that have this
problem.  (Almost all ranges, for example, at least the ones that have internal
caching.)

Therefore, I'm recategorising this as a DMD/spec issue.  Here's a test case
that doesn't involve Phobos:

    struct Ptr(T)
    {
        T* ptr;
        alias ptr this;
    }

    Ptr!T takePtr(T)(ref T obj)
    {
        return Ptr!T(&obj);
    }

    inout(int[]) fun(inout int[] arr)
    {
        auto p = takePtr(arr);
        return *p;
    }

I wonder if we could invent a rule by which inout gets converted to const in
some places.

--


More information about the Digitalmars-d-bugs mailing list