mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 22:21:09 +03:00
bitmanip: make use of new byteswap() function
This commit is contained in:
parent
a88271710b
commit
76caec12f4
1 changed files with 2 additions and 2 deletions
|
@ -2767,11 +2767,11 @@ public:
|
||||||
T swapEndian(T)(const T val) @safe pure nothrow @nogc
|
T swapEndian(T)(const T val) @safe pure nothrow @nogc
|
||||||
if (isIntegral!T || isSomeChar!T || isBoolean!T)
|
if (isIntegral!T || isSomeChar!T || isBoolean!T)
|
||||||
{
|
{
|
||||||
import core.bitop : bswap;
|
import core.bitop : bswap, byteswap;
|
||||||
static if (val.sizeof == 1)
|
static if (val.sizeof == 1)
|
||||||
return val;
|
return val;
|
||||||
else static if (T.sizeof == 2)
|
else static if (T.sizeof == 2)
|
||||||
return cast(T) (((val & 0xff00U) >> 8) | ((val & 0x00ffU) << 8));
|
return cast(T) byteswap(cast(ushort) val);
|
||||||
else static if (T.sizeof == 4)
|
else static if (T.sizeof == 4)
|
||||||
return cast(T) bswap(cast(uint) val);
|
return cast(T) bswap(cast(uint) val);
|
||||||
else static if (T.sizeof == 8)
|
else static if (T.sizeof == 8)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue