Merge pull request #2128 from AndrejMitrovic/Fix11253

Issue 11253 - std.algorithm.count is not nothrow
This commit is contained in:
monarch dodra 2014-05-09 22:08:25 +02:00
commit 254290daf7

View file

@ -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