Hello all,


I am trying to implement a ("struct template" ? what is the correct word ?) range that just forwards its primitives ("empty", "front", "popFront") to another range, possibly with some very limited filtering/alteration, as std.range.Take (just to learn).

Initially, the "front" member function (property) used to be declared "const", but that was not accepted when the underlying range (denoted "R" in the code below) was std.stdio.File.ByChunk ("Error: mutable method std.stdio.File.ByChunk.front is not callable using a const object").

Is there any value in having the "front" range primitive declared to be a "const" member function ?

And if so, is the following implementation okay ? Could it be further simplified ?

    struct Taker (R)
    {
        private R _r;

        ...

static if (functionAttributes ! (R.front) & FunctionAttribute.const_) public @property auto front () const { return _r.front; }
        else
public @property auto front () { return _r.front; }

        ...
    }



Thank you respectfully !
Drone1h

Reply via email to