mirror of
https://github.com/dlang/phobos.git
synced 2025-05-14 17:05:58 +03:00
Merge pull request #5147 from wilzbach/static_if_std_algorithm_comparison
[Static if] Replace overload constraints with static if (comparison.d) merged-on-behalf-of: Sebastian Wilzbach <sebi.wilzbach@gmail.com>
This commit is contained in:
commit
d15447fb44
1 changed files with 69 additions and 69 deletions
|
@ -606,7 +606,9 @@ Returns:
|
||||||
|
|
||||||
*/
|
*/
|
||||||
int cmp(alias pred = "a < b", R1, R2)(R1 r1, R2 r2)
|
int cmp(alias pred = "a < b", R1, R2)(R1 r1, R2 r2)
|
||||||
if (isInputRange!R1 && isInputRange!R2 && !(isSomeString!R1 && isSomeString!R2))
|
if (isInputRange!R1 && isInputRange!R2)
|
||||||
|
{
|
||||||
|
static if (!(isSomeString!R1 && isSomeString!R2))
|
||||||
{
|
{
|
||||||
for (;; r1.popFront(), r2.popFront())
|
for (;; r1.popFront(), r2.popFront())
|
||||||
{
|
{
|
||||||
|
@ -617,10 +619,7 @@ if (isInputRange!R1 && isInputRange!R2 && !(isSomeString!R1 && isSomeString!R2))
|
||||||
if (binaryFun!pred(b, a)) return 1;
|
if (binaryFun!pred(b, a)) return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
/// ditto
|
|
||||||
int cmp(alias pred = "a < b", R1, R2)(R1 r1, R2 r2)
|
|
||||||
if (isSomeString!R1 && isSomeString!R2)
|
|
||||||
{
|
{
|
||||||
import core.stdc.string : memcmp;
|
import core.stdc.string : memcmp;
|
||||||
import std.utf : decode;
|
import std.utf : decode;
|
||||||
|
@ -688,6 +687,7 @@ if (isSomeString!R1 && isSomeString!R2)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@safe unittest
|
@safe unittest
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue