On Wednesday, 8 August 2018 at 01:33:26 UTC, Steven Schveighoffer wrote:
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

But forward ranges are a superset of input ranges so `isForwardRange!(Rs[0]) == isInputRange!(Rs[0]` <=> `isForwardRange!(Rs[0])`, right?

Reply via email to