diff --git a/std/algorithm.d b/std/algorithm.d index 618b8609291..a76512df420 100644 --- a/std/algorithm.d +++ b/std/algorithm.d @@ -2758,7 +2758,12 @@ private struct SplitterResult(alias isTerminator, Range) @property auto front() { - version(assert) if (empty) throw new RangeError(); + version(assert) + { + import core.exception : RangeError; + if (empty) + throw new RangeError(); + } static if (fullSlicing) return _input[0 .. _end]; else @@ -2767,7 +2772,12 @@ private struct SplitterResult(alias isTerminator, Range) void popFront() { - version(assert) if (empty) throw new RangeError(); + version(assert) + { + import core.exception : RangeError; + if (empty) + throw new RangeError(); + } static if (fullSlicing) { @@ -6160,6 +6170,8 @@ size_t count(alias pred = "a == b", Range, E)(Range haystack, E needle) /// unittest { + import std.uni : toLower; + // count elements in range int[] a = [ 1, 2, 4, 3, 2, 5, 3, 2, 4 ]; assert(count(a, 2) == 3); @@ -6169,7 +6181,7 @@ unittest assert(count("ababab", "abab") == 1); assert(count("ababab", "abx") == 0); // fuzzy count range in range - assert(count!"std.uni.toLower(a) == std.uni.toLower(b)"("AbcAdFaBf", "ab") == 2); + assert(count!((a, b) => std.uni.toLower(a) == std.uni.toLower(b))("AbcAdFaBf", "ab") == 2); // count predicate in range assert(count!("a > 1")(a) == 8); } diff --git a/std/uni.d b/std/uni.d index 82a14543bfa..c72dd04a588 100644 --- a/std/uni.d +++ b/std/uni.d @@ -1479,6 +1479,8 @@ private auto packedArrayView(T)(inout(size_t)* ptr, size_t items) @trusted pure // Partially unrolled binary search using Shar's method //============================================================================ +private import std.math : pow; + string genUnrolledSwitchSearch(size_t size) { assert(isPowerOf2(size)); @@ -5812,6 +5814,8 @@ int sicmp(S1, S2)(S1 str1, S2 str2) if(isForwardRange!S1 && is(Unqual!(ElementType!S1) == dchar) && isForwardRange!S2 && is(Unqual!(ElementType!S2) == dchar)) { + import std.utf : decode; + alias sTable = simpleCaseTable; size_t ridx=0; foreach(dchar lhs; str1) @@ -6532,6 +6536,8 @@ private auto splitNormalized(NormalizationForm norm, C)(const(C)[] input) private auto seekStable(NormalizationForm norm, C)(size_t idx, in C[] input) { + import std.utf : codeLength; + auto br = input[0..idx]; size_t region_start = 0;// default for(;;)