Expressing range constraints in CNF form

David Gileadi via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 12 10:35:59 PDT 2017


On 6/11/17 1:32 PM, Sebastiaan Koppe wrote:

> What about using ddoc?
> 
> enum bool isInputRange(R) =
>      is(typeof((ref R r) => r)) /// must be copyable
>      && is(ReturnType!((R r) => r.empty) == bool) /// must support bool 
> empty
>      && is(typeof(lvalueOf!R.front)) /// must support front
>      && is(typeof(lvalueOf!R.popFront)) /// must support back

If there's going to be compiler magic, this seems like a sensible 
syntax--documenting constraints is a good idea anyway, particularly for 
those of us who aren't is-expression masters.


More information about the Digitalmars-d mailing list