[Static if] replace overload constraints with static if (searching.d)#5150
[Static if] replace overload constraints with static if (searching.d)#5150wilzbach wants to merge 1 commit intodlang:masterfrom
Conversation
01949bb to
9328a55
Compare
9328a55 to
74a5a5e
Compare
wilzbach
left a comment
There was a problem hiding this comment.
(some comments about the constraints)
| if (isNarrowString!R1 && isInputRange!R2 && !isNarrowString!R2 && | ||
| is(typeof(r1.front == r2.front))) | ||
| if (isNarrowString!R1 && (isNarrowString!R2 || | ||
| isInputRange!R2 && is(typeof(r1.front == r2.front)))) |
There was a problem hiding this comment.
The next overload is isNarrowString!R1 && isNarrowString!R2, which implies R2 is either a narrow string or an input range with the same element type as R1.
std/algorithm/searching.d
Outdated
| (is(typeof(binaryFun!pred(doesThisEnd.back, withThis)) : bool) || | ||
| isBidirectionalRange!R2 && | ||
| is(typeof(binaryFun!pred(doesThisEnd.back, withThis.back)) : bool)) | ||
| is(typeof(binaryFun!pred(doesThisEnd.back, withThis.back)) : bool))) |
There was a problem hiding this comment.
The next overload is isBidirectionalRange!R && is(typeof(binaryFun!pred(doesThisEnd.back, withThis)) : bool)
Which implies it's either bidirectional and back of both ends is comparable with pred or
Todo!!!
| (isRandomAccessRange!R1 && ( | ||
| isForwardRange!R2 || | ||
| hasLength!R1 && hasSlicing!R1 && isBidirectionalRange!R2)) | ||
| )) |
There was a problem hiding this comment.
This groups these overloads:
isRandomAccessRange!R1 && hasLength!R1 && hasSlicing!R1 && isBidirectionalRange!R2 && is(typeof(binaryFun!pred(haystack.front, needle.front)) : bool))
isRandomAccessRange!R1 && isForwardRange!R2 && !isBidirectionalRange!R2 && is(typeof(binaryFun!pred(haystack.front, needle.front)) : bool))
Notice
- for all of them the
frontof both ranges needs to be comparable with the given binary function:is(typeof(binaryFun!pred(haystack.front, needle.front)) : bool))is required - overload 2 & 3 can be grouped further as they both require
RandomAccess
| if (isBidirectionalRange!R1 && ( | ||
| is(typeof(binaryFun!pred(doesThisEnd.back, withThis)) : bool) || | ||
| isBidirectionalRange!R2 && (is(typeof(binaryFun!pred(doesThisEnd.back, withThis.back)) : bool)) | ||
| )) |
There was a problem hiding this comment.
The next overload is isBidirectionalRange!R && is(typeof(binaryFun!pred(doesThisEnd.back, withThis)) : bool))
-> isBidirectionalRange!R is the overlapping constraint.
|
The reason to have the overloads is to have the acceptable overloads visible. |
And the reason for unifying them under one function is that @WalterBright and others agree that |
|
Mostly superseded by #5575 |
Split up of #5145