diff --git a/std/algorithm.d b/std/algorithm.d index 8408613c2..641def579 100644 --- a/std/algorithm.d +++ b/std/algorithm.d @@ -3976,12 +3976,12 @@ unittest @safe pure nothrow unittest { int[] a1 = [1, 2, 3]; - assert(find ([1, 2, 3], 2)); - assert(find!((a,b)=>a==b)([1, 2, 3], 2)); + assert(!find ([1, 2, 3], 2).empty); + assert(!find!((a,b)=>a==b)([1, 2, 3], 2).empty); ubyte[] a2 = [1, 2, 3]; ubyte b2 = 2; - assert(find ([1, 2, 3], 2)); - assert(find!((a,b)=>a==b)([1, 2, 3], 2)); + assert(!find ([1, 2, 3], 2).empty); + assert(!find!((a,b)=>a==b)([1, 2, 3], 2).empty); } @safe pure unittest { @@ -7251,7 +7251,7 @@ private: void AllocMatrix(size_t r, size_t c) { rows = r; cols = c; - if (!_matrix || _matrix.length < r || _matrix[0].length < c) { + if (_matrix.length < r || _matrix[0].length < c) { delete _matrix; _matrix = new CostType[][](r, c); InitMatrix(); @@ -7262,7 +7262,7 @@ private: foreach (i, row; _matrix) { row[0] = i * _deletionIncrement; } - if (!_matrix) return; + if (!_matrix.length) return; for (auto i = 0u; i != _matrix[0].length; ++i) { _matrix[0][i] = i * _insertionIncrement; } diff --git a/std/array.d b/std/array.d index d485c666a..04779a9d3 100644 --- a/std/array.d +++ b/std/array.d @@ -1955,7 +1955,7 @@ void replaceInPlace(T, Range)(ref T[] array, size_t from, size_t to, Range stuff !is(T == const T) && !is(T == immutable T)) { - if (overlap(array, stuff)) + if (overlap(array, stuff).length) { // use slower/conservative method array = array[0 .. from] ~ stuff ~ array[to .. $]; diff --git a/std/csv.d b/std/csv.d index 98fb7e765..45744118f 100644 --- a/std/csv.d +++ b/std/csv.d @@ -1165,7 +1165,7 @@ public: void popFront() { // Skip last of record when header is depleted. - if(_popCount && _popCount.empty) + if(_popCount.ptr && _popCount.empty) while(!recordEnd()) { prime(1); diff --git a/std/exception.d b/std/exception.d index 297092a1b..60c8e20c2 100644 --- a/std/exception.d +++ b/std/exception.d @@ -331,6 +331,7 @@ unittest -------------------- +/ T enforce(T)(T value, lazy const(char)[] msg = null, string file = __FILE__, size_t line = __LINE__) + if (is(typeof({ if (!value) {} }))) { if (!value) bailOut(file, line, msg); return value; @@ -344,6 +345,7 @@ T enforce(T)(T value, lazy const(char)[] msg = null, string file = __FILE__, siz +/ T enforce(T, string file, size_t line = __LINE__) (T value, lazy const(char)[] msg = null) + if (is(typeof({ if (!value) {} }))) { if (!value) bailOut(file, line, msg); return value; @@ -357,7 +359,8 @@ T enforce(T, string file, size_t line = __LINE__) +/ T enforce(T, Dg, string file = __FILE__, size_t line = __LINE__) (T value, scope Dg dg) - if (isSomeFunction!Dg && is(typeof( dg() ))) + if (isSomeFunction!Dg && is(typeof( dg() )) && + is(typeof({ if (!value) {} }))) { if (!value) dg(); return value; diff --git a/std/format.d b/std/format.d index 6b7feb57f..c8e7b7121 100644 --- a/std/format.d +++ b/std/format.d @@ -2417,7 +2417,7 @@ if (is(AssocArrayTypeOf!T) && !is(T == enum) && !hasToString!(T, Char)) fmt.writeUpToNextSpec(w); formatElement(w, v, fmt); } - if (f.sep) + if (f.sep.length) { fmt.writeUpToNextSpec(w); if (++i != end) diff --git a/std/traits.d b/std/traits.d index 0d106fc03..5d3ec321a 100644 --- a/std/traits.d +++ b/std/traits.d @@ -318,7 +318,7 @@ template packageName(alias T) enum string parent = null; static if (T.stringof.startsWith("package ")) - enum packageName = (parent ? parent ~ '.' : "") ~ T.stringof[8 .. $]; + enum packageName = (parent.length ? parent ~ '.' : "") ~ T.stringof[8 .. $]; else static if (parent) enum packageName = parent; else