mirror of
https://github.com/dlang/phobos.git
synced 2025-04-29 14:40:30 +03:00
Unify Phobos by ensuring there's always a space after cast(...)
Command: sed -E 's/([^"])cast\(([^)]*?)\)([[:alnum:]])/\1cast(\2) \3/g' -i **/*.d
This commit is contained in:
parent
669ceb8a0d
commit
805c720595
80 changed files with 1389 additions and 1389 deletions
|
@ -1074,7 +1074,7 @@ private:
|
|||
import core.exception : onOutOfMemoryError;
|
||||
const nbytes = mulu(rc, _matrix[0].sizeof, overflow);
|
||||
if (overflow) assert(0);
|
||||
auto m = cast(CostType *)realloc(_matrix.ptr, nbytes);
|
||||
auto m = cast(CostType *) realloc(_matrix.ptr, nbytes);
|
||||
if (!m)
|
||||
onOutOfMemoryError();
|
||||
_matrix = m[0 .. r * c];
|
||||
|
|
|
@ -875,13 +875,13 @@ template each(alias pred = "a")
|
|||
enum isForeachUnaryIterable(R) =
|
||||
is(typeof((R r) {
|
||||
foreach (ref a; r)
|
||||
cast(void)unaryFun!pred(a);
|
||||
cast(void) unaryFun!pred(a);
|
||||
}));
|
||||
|
||||
enum isForeachBinaryIterable(R) =
|
||||
is(typeof((R r) {
|
||||
foreach (ref i, ref a; r)
|
||||
cast(void)binaryFun!BinaryArgs(i, a);
|
||||
cast(void) binaryFun!BinaryArgs(i, a);
|
||||
}));
|
||||
|
||||
enum isForeachIterable(R) =
|
||||
|
@ -896,7 +896,7 @@ template each(alias pred = "a")
|
|||
{
|
||||
while (!r.empty)
|
||||
{
|
||||
cast(void)unaryFun!pred(r.front);
|
||||
cast(void) unaryFun!pred(r.front);
|
||||
r.popFront();
|
||||
}
|
||||
}
|
||||
|
@ -905,7 +905,7 @@ template each(alias pred = "a")
|
|||
size_t i = 0;
|
||||
while (!r.empty)
|
||||
{
|
||||
cast(void)binaryFun!BinaryArgs(i, r.front);
|
||||
cast(void) binaryFun!BinaryArgs(i, r.front);
|
||||
r.popFront();
|
||||
i++;
|
||||
}
|
||||
|
@ -919,12 +919,12 @@ template each(alias pred = "a")
|
|||
static if (isForeachUnaryIterable!Iterable)
|
||||
{
|
||||
foreach (ref e; r)
|
||||
cast(void)unaryFun!pred(e);
|
||||
cast(void) unaryFun!pred(e);
|
||||
}
|
||||
else // if (isForeachBinaryIterable!Iterable)
|
||||
{
|
||||
foreach (ref i, ref e; r)
|
||||
cast(void)binaryFun!BinaryArgs(i, e);
|
||||
cast(void) binaryFun!BinaryArgs(i, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4518,7 +4518,7 @@ if (isSomeChar!C)
|
|||
{
|
||||
if (word in dictionary) continue; // Nothing to do
|
||||
auto newID = dictionary.length;
|
||||
dictionary[to!string(word)] = cast(uint)newID;
|
||||
dictionary[to!string(word)] = cast(uint) newID;
|
||||
}
|
||||
}
|
||||
assert(dictionary.length == 5);
|
||||
|
@ -4692,7 +4692,7 @@ if (isInputRange!R && !isInfinite!R)
|
|||
|
||||
void collapseStore(T)(T k)
|
||||
{
|
||||
auto lastToKeep = idx - cast(uint)bsf(k+1);
|
||||
auto lastToKeep = idx - cast(uint) bsf(k+1);
|
||||
while (idx > lastToKeep)
|
||||
{
|
||||
store[idx - 1] += store[idx];
|
||||
|
@ -4746,10 +4746,10 @@ if (isInputRange!R && !isInfinite!R)
|
|||
private auto sumPairwise16(F, R)(R r)
|
||||
if (isRandomAccessRange!R)
|
||||
{
|
||||
return (((cast(F)r[ 0] + r[ 1]) + (cast(F)r[ 2] + r[ 3]))
|
||||
+ ((cast(F)r[ 4] + r[ 5]) + (cast(F)r[ 6] + r[ 7])))
|
||||
+ (((cast(F)r[ 8] + r[ 9]) + (cast(F)r[10] + r[11]))
|
||||
+ ((cast(F)r[12] + r[13]) + (cast(F)r[14] + r[15])));
|
||||
return (((cast(F) r[ 0] + r[ 1]) + (cast(F) r[ 2] + r[ 3]))
|
||||
+ ((cast(F) r[ 4] + r[ 5]) + (cast(F) r[ 6] + r[ 7])))
|
||||
+ (((cast(F) r[ 8] + r[ 9]) + (cast(F) r[10] + r[11]))
|
||||
+ ((cast(F) r[12] + r[13]) + (cast(F) r[14] + r[15])));
|
||||
}
|
||||
|
||||
private auto sumPair(bool needEmptyChecks, F, R)(ref R r)
|
||||
|
@ -4821,8 +4821,8 @@ private auto sumKahan(Result, R)(Result result, R r)
|
|||
|
||||
@safe pure nothrow unittest
|
||||
{
|
||||
static assert(is(typeof(sum([cast( byte)1])) == int));
|
||||
static assert(is(typeof(sum([cast(ubyte)1])) == int));
|
||||
static assert(is(typeof(sum([cast( byte) 1])) == int));
|
||||
static assert(is(typeof(sum([cast(ubyte) 1])) == int));
|
||||
static assert(is(typeof(sum([ 1, 2, 3, 4])) == int));
|
||||
static assert(is(typeof(sum([ 1U, 2U, 3U, 4U])) == uint));
|
||||
static assert(is(typeof(sum([ 1L, 2L, 3L, 4L])) == long));
|
||||
|
|
|
@ -258,8 +258,8 @@ Unicode integrity is not preserved:
|
|||
|
||||
bringToFront(ar, br);
|
||||
|
||||
auto a = cast(char[])ar;
|
||||
auto b = cast(char[])br;
|
||||
auto a = cast(char[]) ar;
|
||||
auto b = cast(char[]) br;
|
||||
|
||||
// Illegal UTF-8
|
||||
assert(a == "\303");
|
||||
|
@ -798,7 +798,7 @@ if (isInputRange!Range && hasLvalueElements!Range && hasAssignableElements!Range
|
|||
{
|
||||
// static array initializer only contains initialization
|
||||
// for one element of the static array.
|
||||
auto elemp = cast(void *)addressOf(range.front);
|
||||
auto elemp = cast(void *) addressOf(range.front);
|
||||
auto endp = elemp + T.sizeof;
|
||||
while (elemp < endp)
|
||||
{
|
||||
|
|
|
@ -538,9 +538,9 @@ if (isNarrowString!R1 && isNarrowString!R2)
|
|||
assert(commonPrefix([1, 2, 3, 4], [1, 2, 3, 4]) == [1, 2, 3, 4]);
|
||||
assert(commonPrefix([1, 2, 3], [7, 2, 3, 4, 5]).empty);
|
||||
assert(commonPrefix([7, 2, 3, 4, 5], [1, 2, 3]).empty);
|
||||
assert(commonPrefix([1, 2, 3], cast(int[])null).empty);
|
||||
assert(commonPrefix(cast(int[])null, [1, 2, 3]).empty);
|
||||
assert(commonPrefix(cast(int[])null, cast(int[])null).empty);
|
||||
assert(commonPrefix([1, 2, 3], cast(int[]) null).empty);
|
||||
assert(commonPrefix(cast(int[]) null, [1, 2, 3]).empty);
|
||||
assert(commonPrefix(cast(int[]) null, cast(int[]) null).empty);
|
||||
|
||||
foreach (S; AliasSeq!(char[], const(char)[], string,
|
||||
wchar[], const(wchar)[], wstring,
|
||||
|
@ -1208,7 +1208,7 @@ if (isInputRange!R &&
|
|||
immutable arr = cast(T[])[0, 1, 2, 3, 4, 5];
|
||||
|
||||
//RA range
|
||||
assert(endsWith(arr, cast(int[])null));
|
||||
assert(endsWith(arr, cast(int[]) null));
|
||||
assert(!endsWith(arr, 0));
|
||||
assert(!endsWith(arr, 4));
|
||||
assert(endsWith(arr, 5));
|
||||
|
@ -1420,7 +1420,7 @@ if (isInputRange!InputRange &&
|
|||
import core.stdc.string : memchr;
|
||||
auto ptr = memchr(haystack.ptr, needle, haystack.length);
|
||||
return ptr ?
|
||||
haystack[cast(char*)ptr - haystack.ptr .. $] :
|
||||
haystack[cast(char*) ptr - haystack.ptr .. $] :
|
||||
haystack[$ .. $];
|
||||
}
|
||||
return trustedMemchr(haystack, needle);
|
||||
|
@ -1781,7 +1781,7 @@ if (isForwardRange!R1 && isForwardRange!R2
|
|||
Select!(haystack[0].sizeof == 1, ubyte[],
|
||||
Select!(haystack[0].sizeof == 2, ushort[], uint[]));
|
||||
// Will use the array specialization
|
||||
static TO force(TO, T)(T r) @trusted { return cast(TO)r; }
|
||||
static TO force(TO, T)(T r) @trusted { return cast(TO) r; }
|
||||
return force!R1(.find!(pred, Representation, Representation)
|
||||
(force!Representation(haystack), force!Representation(needle)));
|
||||
}
|
||||
|
@ -3112,7 +3112,7 @@ if (isInputRange!Range && !isInfinite!Range &&
|
|||
{
|
||||
UT v = UT.init;
|
||||
static if (isAssignable!(UT, T)) v = range.front;
|
||||
else v = cast(UT)range.front;
|
||||
else v = cast(UT) range.front;
|
||||
|
||||
for (range.popFront(); !range.empty; range.popFront())
|
||||
{
|
||||
|
@ -3121,7 +3121,7 @@ if (isInputRange!Range && !isInfinite!Range &&
|
|||
{
|
||||
// change the min
|
||||
static if (isAssignable!(UT, T)) v = range.front;
|
||||
else v = cast(UT)range.front; //Safe because !hasElaborateAssign!UT
|
||||
else v = cast(UT) range.front; //Safe because !hasElaborateAssign!UT
|
||||
occurrences = 1;
|
||||
}
|
||||
else
|
||||
|
@ -4208,7 +4208,7 @@ if (isInputRange!R &&
|
|||
immutable arr = cast(T[])[0, 1, 2, 3, 4, 5];
|
||||
|
||||
//RA range
|
||||
assert(startsWith(arr, cast(int[])null));
|
||||
assert(startsWith(arr, cast(int[]) null));
|
||||
assert(!startsWith(arr, 5));
|
||||
assert(!startsWith(arr, 1));
|
||||
assert(startsWith(arr, 0));
|
||||
|
|
|
@ -92,7 +92,7 @@ if (!allSatisfy!(isForwardRange, R1, R2) ||
|
|||
// covering the right and bottom edges of an increasing square area
|
||||
// over the infinite table of combinations. This schedule allows us
|
||||
// to require only forward ranges.
|
||||
return zip(sequence!"n"(cast(size_t)0), range1.save, range2.save,
|
||||
return zip(sequence!"n"(cast(size_t) 0), range1.save, range2.save,
|
||||
repeat(range1), repeat(range2))
|
||||
.map!(function(a) => chain(
|
||||
zip(repeat(a[1]), take(a[4].save, a[0])),
|
||||
|
|
|
@ -3846,7 +3846,7 @@ unittest
|
|||
auto b = new ubyte[5];
|
||||
topNIndex!("a > b")(a, b, Yes.sortOutput);
|
||||
//foreach (e; b) writeln(e, ":", a[e]);
|
||||
assert(b == [ cast(ubyte) 0, cast(ubyte)2, cast(ubyte)1, cast(ubyte)6, cast(ubyte)5], text(b));
|
||||
assert(b == [ cast(ubyte) 0, cast(ubyte) 2, cast(ubyte) 1, cast(ubyte) 6, cast(ubyte) 5], text(b));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue