isBidirectionalRange fails for unknown reasons

Jack Stouffer via Digitalmars-d-learn digitalmars-d-learn at
Wed Dec 16 12:43:02 PST 2015

I'm trying to add a ReferenceBidirectionalRange range type to 
std.internal.test.dummyrange so I can test some range code I'm 
writing, but I've hit a wall and I'm not sure why. For some 
reason, the isBidirectionalRange check fails even though back and 
popBack are present. Any help here would be appreciated.

the code:
import std.range;

class ReferenceInputRange(T)
     import std.array : array;

     this(Range)(Range r) if (isInputRange!Range) { _payload = 
array(r); }
     final @property ref T front(){ return _payload.front; }
     final void popFront(){ _payload.popFront(); }
     final @property bool empty(){ return _payload.empty; }
     protected T[] _payload;

class ReferenceForwardRange(T) : ReferenceInputRange!T
     this(Range)(Range r) if (isInputRange!Range) { super(r); }
     final @property ReferenceForwardRange save()
     {return new ReferenceForwardRange!T( _payload); }

class ReferenceBidirectionalRange(T) : ReferenceForwardRange!T
     this(Range)(Range r) if (isInputRange!Range) { super(r); }
     final @property ref T back(){ return _payload.back; }
     final void popBack(){ _payload.popBack(); }

     static assert(isInputRange!(ReferenceInputRange!int)); // 
     static assert(isForwardRange!(ReferenceForwardRange!int)); // 

More information about the Digitalmars-d-learn mailing list