Trouble creating bidirectional range
Martin Drasar
drasar at ics.muni.cz
Sun Sep 29 13:25:32 PDT 2013
Hi,
I have upgraded to dmd 2.063.2 and have some troubles making my custom
bidirectional range work (it used to). In fact, even this code fails on
assert and I am not really sure why...
import std.range;
struct MyRange(T)
{
private:
T[] data;
public:
T front() @property { return data[0]; }
T back() @property { return data[0]; }
void popFront() {}
void popBack() {}
bool empty() @property { return false; }
auto save()
{
typeof(this) result;
result.data = data;
return result;
}
}
static this()
{
MyRange!string tmp;
static assert(isInputRange!(MyRange!string));
static assert(is(typeof(tmp.save) == MyRange!string));
}
I get this when trying to compile:
> drasar at uriel:/tmp$ dmd test.d
> test.d(26): Error: static assert (is(pure nothrow @safe MyRange!(string)() == MyRange!(string))) is false
Do you have an idea?
Thanks,
Martin
More information about the Digitalmars-d-learn
mailing list