mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 06:30:28 +03:00
More implicit array to bool
This commit is contained in:
parent
42c151df49
commit
1818d190b5
6 changed files with 14 additions and 11 deletions
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 .. $];
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue