Second CT-Parameter of isRange Predicates

Alex Parrill via Digitalmars-d digitalmars-d at puremagic.com
Mon Nov 2 06:23:57 PST 2015


On Monday, 2 November 2015 at 14:16:53 UTC, Nordlöw wrote:
> Is there a reason why
>
>     isOutputRange(R,E)
>
> takes a second argument `E` but not other range predicates
>
>     isInputRange(R)
>     isForwardRange(R)
>     ...
>
> ?
>
> If so, I still think it would very be nice to have a second 
> argument `E` for all the other `isXRange` traits to simplify, 
> for instance,
>
>     if (isInputRange!R && is(int == ElementType!R))
>
> to simpler
>
>     if (isInputRange!(R, int))
>
> or even
>
>     if (isInputRange!R && is(isSomeChar!(ElementType!R)))
>
> to simpler
>
>     if (isInputRange!(R, isSomeChar))
>
> ?
>
> What do think?
>
> I'm planning to add a PR for this and simplify Phobos in all 
> places where this pattern is used.

I think it's because output ranges can accept more than one type 
of value. That said, the `isInputRange!(R,E)` shortcut for 
`isInputRange!R && is(int == ElementType!R)` would be nice.


More information about the Digitalmars-d mailing list