Expressing range constraints in CNF form
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Sun Jun 11 17:51:25 PDT 2017
On Monday, 12 June 2017 at 00:13:46 UTC, Adam D. Ruppe wrote:
> On Sunday, 11 June 2017 at 00:28:58 UTC, Andrei Alexandrescu
> wrote:
>> // Also possible (no change to the language)
>> enum bool isInputRange(R) =
>> is(typeof((ref R r) => r)) && msg("must be copyable")
>
>
> Or how about
>
> enum bool isInputRange(R) =
> isCopyable!R &&
> supportsBoolEmpty!R &&
> supportsFront!R &&
> supportsPopFront!R;
>
> and the compiler just calls out which condition didn't match?
Much better. Probably could be a bit more generic than that :)
>
>> && is(typeof(lvalueOf!R.popFront)) && msg("must support
>> back");
>
> hey look you already messed up the string by repeating it.
Exactly my point.
-Steve
More information about the Digitalmars-d
mailing list