import std.range;
public struct myRng( E)
{
import std.range;
public:
@property E front()
{
return 0;
}
@property void front( int elem)
{
}
void popFront()
{
}
@property bool empty()
{
return true;
}
@property auto save()
{
return this;
}
}
static assert( isForwardRange!( myRng!int));
bool check_( SomeThing)( SomeThing fofo) if( isInputRange!SomeThing)
{
return is( fofo);
}
unittest
{
auto r = myRng!int();
assert( r.check_ == false);
assert( walkLength( r) == 0);
assert( r.walkLength == 1); // here the compiler fails
}$
$
$
$
$
$ dmd --version | fgrep -i dmd
DMD64 D Compiler v2.070.1
$
$
$
$ dmd t.d -lib -unittest
t.d(38): Error: cannot resolve type for r.walkLength(Range)(Range range) if (isInputRange!Range && !isInfinite!Range)
$
cant write import std.range; twice in that situation.
its not okay, because with "mixin template" i have to write it twice sometimes. (the compiler complains, if i dont write the imports into the mixins. i dont even know, if that is correct behaviour)
Comment #1 by mephisto — 2016-03-07T09:36:44Z
okay, after looking at it once more i noticed i actually dont have to write the "import" twice. i failed at that point