countUntil's constraints
Steven Schveighoffer
schveiguy at gmail.com
Wed Aug 8 01:33:26 UTC 2018
On 8/7/18 9:20 PM, Nicholas Wilson wrote:
> the first overload is
>
> ptrdiff_t countUntil(alias pred = "a == b", R, Rs...)(R haystack, Rs
> needles)
> if (isForwardRange!R
> && Rs.length > 0
> && isForwardRange!(Rs[0]) == isInputRange!(Rs[0])
> && is(typeof(startsWith!pred(haystack, needles[0])))
> && (Rs.length == 1
> || is(typeof(countUntil!pred(haystack, needles[1 .. $])))))
>
> What does `isForwardRange!(Rs[0]) == isInputRange!(Rs[0]` mean here?
> Is it just the same as `isForwardRange!(Rs[0])`? Why is it written like
> that?
No, not exactly the same.
Superficially, this rejects elements that are input ranges but NOT
forward ranges. Other than that, I can't tell you the reason why it's
that way.
-Steve
More information about the Digitalmars-d-learn
mailing list