Can’t use UFCS to create InputRange?

Simen Kjærås simen.kjaras at gmail.com
Wed Apr 29 09:12:37 UTC 2020


On Wednesday, 29 April 2020 at 08:34:53 UTC, Ogi wrote:
> 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
>
> What’s going on here?


The template IsInputRange is in the std.range.primitives module, 
and thus can't see the front, popFront and empty definitions in 
your module.

--
   Simen


More information about the Digitalmars-d-learn mailing list