Defining inout returned values for ranges

Jonathan Crapuchettes jcrapuchettes at gmail.com
Tue Sep 3 17:56:39 PDT 2013


If a range struct (Range) is defined inside another struct (Test), how 
can the constness or mutability of Test be attributed to the return type 
of Range.front? I'm running into this problem because I need the range to 
be iterated, but I need the pointer in T to be marked const when 
appropriate.

Thank you,
JC

Pseudo-Example:
struct Test
{
    static struct T
    {
        uint* ptr;
    }
    ...

    auto opSlice() inout
    {
        static struct Range
        {
            inout(T) front() @property
            {
                ...
            }
            ...
        }

        return Range();
    }
}


More information about the Digitalmars-d-learn mailing list