mirror of
https://github.com/dlang/phobos.git
synced 2025-05-08 03:56:54 +03:00
fix Issue 11603 - std.algorithm.canFind does not work when needle is 1-byte zero
This commit is contained in:
parent
ae34e224f8
commit
ab34fb92ad
1 changed files with 10 additions and 1 deletions
|
@ -3916,7 +3916,7 @@ if (isInputRange!InputRange &&
|
||||||
{
|
{
|
||||||
EType* ptr = null;
|
EType* ptr = null;
|
||||||
//Note: we use "min/max" to handle sign mismatch.
|
//Note: we use "min/max" to handle sign mismatch.
|
||||||
if (min(EType.min, needle) == EType.min, needle && max(EType.max, needle) == EType.max)
|
if (min(EType.min, needle) == EType.min && max(EType.max, needle) == EType.max)
|
||||||
ptr = cast(EType*) memchr(haystack.ptr, needle, haystack.length);
|
ptr = cast(EType*) memchr(haystack.ptr, needle, haystack.length);
|
||||||
|
|
||||||
return ptr ?
|
return ptr ?
|
||||||
|
@ -4042,6 +4042,15 @@ unittest
|
||||||
dg();
|
dg();
|
||||||
assertCTFEable!dg;
|
assertCTFEable!dg;
|
||||||
}
|
}
|
||||||
|
unittest
|
||||||
|
{
|
||||||
|
// Bugzilla 11603
|
||||||
|
enum Foo : ubyte { A }
|
||||||
|
assert([Foo.A].find(Foo.A).empty == false);
|
||||||
|
|
||||||
|
ubyte x = 0;
|
||||||
|
assert([x].find(x).empty == false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Finds a forward range in another. Elements are compared for
|
Finds a forward range in another. Elements are compared for
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue