struct R {}
int front(R r) { return 42; }
void popFront(R r) {}
bool empty(R r) { return false; }

void main() {
    import std.range.primitives : isInputRange;
    static assert(isInputRange!R);
}

Error: static assert:  `isInputRange!(R)` is false

Whats really weird is that if I replace isInputRange with its definition from std.range.primitives, it returns true:

import std;

struct R {}
int front(R r) { return 42; }
void popFront(R r) {}
bool empty(R r) { return false; }

void main() {
    static assert(is(typeof(R.init) == R)
            && is(ReturnType!((R r) => r.empty) == bool)
            && is(typeof((return ref R r) => r.front))
            && !is(ReturnType!((R r) => r.front) == void)
            && is(typeof((R r) => r.popFront)));
}
This compiles.

What’s going on here?

Reply via email to