mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 06:30:28 +03:00
Merge pull request #2128 from AndrejMitrovic/Fix11253
Issue 11253 - std.algorithm.count is not nothrow
This commit is contained in:
commit
254290daf7
1 changed files with 7 additions and 2 deletions
|
@ -6676,9 +6676,8 @@ size_t count(alias pred = "a == b", R1, R2)(R1 haystack, R2 needle)
|
|||
isForwardRange!R2 &&
|
||||
is(typeof(binaryFun!pred(haystack.front, needle.front)) : bool))
|
||||
{
|
||||
import std.exception : enforce;
|
||||
assert(!needle.empty, "Cannot count occurrences of an empty range");
|
||||
|
||||
enforce(!needle.empty, "Cannot count occurrences of an empty range");
|
||||
static if (isInfinite!R2)
|
||||
{
|
||||
//Note: This is the special case of looking for an infinite inside a finite...
|
||||
|
@ -6716,6 +6715,12 @@ unittest
|
|||
assert(count("日本語") == 3);
|
||||
}
|
||||
|
||||
// Issue 11253
|
||||
nothrow unittest
|
||||
{
|
||||
assert([1, 2, 3].count([2, 3]) == 1);
|
||||
}
|
||||
|
||||
// balancedParens
|
||||
/**
|
||||
Checks whether $(D r) has "balanced parentheses", i.e. all instances
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue