ctSwapBit
fn
void ctSwapBit(T)(uint doSwap, ref T a, ref T b) if (is(T == ubyte) || is(T == ushort) || is(T == uint)
|| is(T == ulong)) pure nothrow @nogc @safeConditionally swaps two integers using an already normalized bit.
Unlike ctSwap, this primitive deliberately accepts only zero or one, allowing the mask conversion to use unsigned subtraction without a comparison that an optimizer may lower to control flow.
Parameters
doSwap | Zero or one. |
a | First value. |
b | Second value. |