Merge pull request #8943 from WalterBright/unqualCast

use cast() where we can
This commit is contained in:
Walter Bright 2024-03-09 16:52:09 -08:00 committed by GitHub
commit 046f56d58d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 10 deletions

View file

@ -2959,10 +2959,10 @@ if (__traits(isIntegral, T))
Unqual!T result; Unqual!T result;
version (LittleEndian) version (LittleEndian)
foreach_reverse (b; array) foreach_reverse (b; array)
result = cast(Unqual!T) ((result << 8) | b); result = cast() cast(T) ((result << 8) | b);
else else
foreach (b; array) foreach (b; array)
result = cast(Unqual!T) ((result << 8) | b); result = cast() cast(T) ((result << 8) | b);
return cast(T) result; return cast(T) result;
} }
@ -2977,7 +2977,7 @@ if (__traits(isIntegral, T))
foreach (i; 0 .. T.sizeof) foreach (i; 0 .. T.sizeof)
{ {
result[i] = cast(ubyte) tmp; result[i] = cast(ubyte) tmp;
tmp = cast(Unqual!T) (tmp >>> 8); tmp = cast() cast(T) (tmp >>> 8);
} }
} }
else else
@ -2985,7 +2985,7 @@ if (__traits(isIntegral, T))
foreach_reverse (i; 0 .. T.sizeof) foreach_reverse (i; 0 .. T.sizeof)
{ {
result[i] = cast(ubyte) tmp; result[i] = cast(ubyte) tmp;
tmp = cast(Unqual!T) (tmp >>> 8); tmp = cast()(T) (tmp >>> 8);
} }
} }
return result; return result;

View file

@ -5250,7 +5250,7 @@ if (isIntegral!T && isOutputRange!(W, char))
auto unsigned(T)(T x) auto unsigned(T)(T x)
if (isIntegral!T) if (isIntegral!T)
{ {
return cast(Unqual!(Unsigned!T))x; return cast() cast(Unsigned!T) x;
} }
/// ///
@ -5271,7 +5271,7 @@ if (isSomeChar!T)
{ {
// All characters are unsigned // All characters are unsigned
static assert(T.min == 0, T.stringof ~ ".min must be zero"); static assert(T.min == 0, T.stringof ~ ".min must be zero");
return cast(Unqual!T) x; return cast() x;
} }
@safe unittest @safe unittest
@ -5328,7 +5328,7 @@ if (isSomeChar!T)
auto signed(T)(T x) auto signed(T)(T x)
if (isIntegral!T) if (isIntegral!T)
{ {
return cast(Unqual!(Signed!T))x; return cast() cast(Signed!T) x;
} }
/// ///

View file

@ -974,9 +974,9 @@ private T powIntegralImpl(PowType type, T)(T val)
else else
{ {
static if (isSigned!T) static if (isSigned!T)
return cast(Unqual!T) (val < 0 ? -(T(1) << bsr(0 - val) + type) : T(1) << bsr(val) + type); return cast() cast(T) (val < 0 ? -(T(1) << bsr(0 - val) + type) : T(1) << bsr(val) + type);
else else
return cast(Unqual!T) (T(1) << bsr(val) + type); return cast() cast(T) (T(1) << bsr(val) + type);
} }
} }

View file

@ -382,7 +382,7 @@ private:
static if (isStaticArray!A && isDynamicArray!T) static if (isStaticArray!A && isDynamicArray!T)
{ {
auto this_ = (*src)[]; auto this_ = (*src)[];
emplaceRef(*cast(Unqual!T*) zat, cast(Unqual!T) this_); emplaceRef(*cast(Unqual!T*) zat, cast() cast(T) this_);
} }
else else
{ {