Library for bit manipulation.
|
Typedefs | |
template<typename... Ts> | |
using | org::ttldtor::bits::Max = detail::MaxImpl<Ts...>::Type |
Returns max type by size (first is better) | |
Functions | |
template<std::integral ValueType, std::integral ShiftType> | |
constexpr ValueType | org::ttldtor::bits::sar (ValueType value, ShiftType shift) noexcept |
Performs a right arithmetic bit shift operation (>> in Java, C, etc.). | |
template<std::integral ValueType, std::unsigned_integral UnsignedShiftType> | |
constexpr ValueType | org::ttldtor::bits::leftArithmeticShift (ValueType value, UnsignedShiftType shift) noexcept |
Performs a left arithmetic bit shift operation (sal , << in Java, C, etc.). | |
template<std::integral ValueType, std::signed_integral SignedShiftType> | |
constexpr ValueType | org::ttldtor::bits::leftArithmeticShift (ValueType value, SignedShiftType shift) noexcept |
Performs a left arithmetic bit shift operation (sal , << in Java, C, etc.). | |
template<std::integral ValueType, std::integral ShiftType> | |
constexpr ValueType | org::ttldtor::bits::sal (ValueType value, ShiftType shift) noexcept |
Performs a left arithmetic bit shift operation (<< in Java, C, etc.). | |
template<std::integral ValueType, std::unsigned_integral UnsignedShiftType> | |
constexpr ValueType | org::ttldtor::bits::rightArithmeticShift (ValueType value, UnsignedShiftType shift) noexcept |
Performs a right arithmetic bit shift operation (sar , >> in Java, C, etc.). | |
template<std::integral ValueType, std::signed_integral SignedShiftType> | |
constexpr ValueType | org::ttldtor::bits::rightArithmeticShift (ValueType value, SignedShiftType shift) noexcept |
Performs a right arithmetic bit shift operation (sar , >> in Java, C, etc.). | |
template<std::integral ValueType, std::integral ShiftType> | |
constexpr ValueType | org::ttldtor::bits::shr (ValueType value, ShiftType shift) noexcept |
Performs a right logical bit shift operation (>>> in Java). | |
template<std::integral ValueType, std::unsigned_integral UnsignedShiftType> | |
constexpr ValueType | org::ttldtor::bits::leftLogicalShift (ValueType value, UnsignedShiftType shift) noexcept |
Performs a left logical bit shift operation (shl , <<< ). | |
template<std::integral ValueType, std::integral SignedShiftType> | |
constexpr ValueType | org::ttldtor::bits::leftLogicalShift (ValueType value, SignedShiftType shift) noexcept |
Performs a left logical bit shift operation (shl , <<< ). | |
template<std::integral ValueType, std::integral ShiftType> | |
constexpr ValueType | org::ttldtor::bits::shl (ValueType value, ShiftType shift) noexcept |
Performs a left logical bit shift operation (shl , <<< ). | |
template<std::integral ValueType, std::unsigned_integral UnsignedShiftType> | |
constexpr ValueType | org::ttldtor::bits::rightLogicalShift (ValueType value, UnsignedShiftType shift) noexcept |
Performs a right logical bit shift operation (shr , >>> in Java). | |
template<std::integral ValueType, std::signed_integral SignedShiftType> | |
constexpr ValueType | org::ttldtor::bits::rightLogicalShift (ValueType value, SignedShiftType shift) noexcept |
Performs a right logical bit shift operation (shr , >>> in Java). | |
template<std::integral FirstType, std::integral SecondType> | |
constexpr FirstType | org::ttldtor::bits::andOp (FirstType first, SecondType second) noexcept |
Performs a bitwise AND operation between two values of possibly different types and ensures the result is cast back to the type of the first argument. | |
template<std::integral FirstType, std::integral SecondType> | |
constexpr FirstType | org::ttldtor::bits::orOp (FirstType first, SecondType second) noexcept |
Performs a bitwise OR operation between two values of possibly different types and ensures the result is cast back to the type of the first argument. | |
template<std::integral FirstType, std::integral SecondType> | |
constexpr FirstType | org::ttldtor::bits::xorOp (FirstType first, SecondType second) noexcept |
Performs a bitwise XOR operation between two values of possibly different types and ensures the result is cast back to the type of the first argument. | |
template<std::unsigned_integral T> | |
constexpr bool | org::ttldtor::bits::bitsAreSet (T sourceBits, T bitMaskToCheck) |
Determines if the specified bits are set in the source value. | |
template<std::integral SourceBitsType, std::integral BitMaskType> | |
constexpr bool | org::ttldtor::bits::bitsAreSet (SourceBitsType sourceBits, BitMaskType bitMaskToCheck) |
Determines if the specified bits are set in the source value. | |
template<std::unsigned_integral T> | |
constexpr T | org::ttldtor::bits::setBits (T sourceBits, T bitMaskToSet) |
Sets specific bits in the source value using a bitmask. | |
template<std::integral SourceBitsType, std::integral BitMaskType> | |
constexpr SourceBitsType | org::ttldtor::bits::setBits (SourceBitsType sourceBits, BitMaskType bitMaskToSet) |
Sets specific bits in the source value using a bitmask. | |
template<std::unsigned_integral T> | |
constexpr T | org::ttldtor::bits::resetBits (T sourceBits, T bitMaskToReset) |
Resets (clears) specific bits in a bitmask. | |
template<std::integral SourceBitsType, std::integral BitMaskType> | |
constexpr SourceBitsType | org::ttldtor::bits::resetBits (SourceBitsType sourceBits, BitMaskType bitMaskToReset) |
Resets (clears) specific bits in a bitmask. | |
|
constexprnoexcept |
Performs a bitwise AND operation between two values of possibly different types and ensures the result is cast back to the type of the first argument.
FirstType | The type of the first argument. |
SecondType | The type of the second argument. |
first | The first operand of type FirstType . |
second | The second operand of type SecondType . |
FirstType
.
|
constexpr |
Determines if the specified bits are set in the source value.
SourceBitsType | The type of the source bits (e.g., an integer type). |
BitMaskType | The type of the bit mask (e.g., an integer type). |
sourceBits | The value to check for the presence of specific bits. |
bitMaskToCheck | The mask of bits to check against the source value. |
true
if the specified bits are set in the source value.
|
constexpr |
Determines if the specified bits are set in the source value.
T | the type of arguments. |
sourceBits | The value to check for the presence of specific bits. |
bitMaskToCheck | The mask of bits to check against the source value. |
true
if the specified bits are set in the source value.
|
constexprnoexcept |
Performs a left arithmetic bit shift operation (sal
, <<
in Java, C, etc.).
The shift
is signed.
The result of the shift will be of the same type as the value
being shifted. If the shift is a negative number of bits, then a right arithmetic shift will be performed. If the shift size is greater than or equal to the number of bits in the shifted value
, then 0
will be returned.
ValueType | The type of value |
SignedShiftType | The type of shift |
value | The value to be shifted |
shift | The shift in bits |
value
|
constexprnoexcept |
Performs a left arithmetic bit shift operation (sal
, <<
in Java, C, etc.).
The shift
is unsigned.
The result of the shift will be of the same type as the value
being shifted. If the shift size is greater than or equal to the number of bits in the shifted value
, then 0
will be returned.
ValueType | The type of value |
UnsignedShiftType | The type of shift |
value | The value to be shifted |
shift | The shift in bits |
value
|
constexprnoexcept |
Performs a left logical bit shift operation (shl
, <<<
).
The shift
is signed.
The result of the shift will be of the same type as the value
being shifted. If the shift is a negative number of bits, then a right logical shift will be performed. If the shift size is greater than or equal to the number of bits in the shifted value
, then 0
will be returned.
ValueType | The type of value |
SignedShiftType | The type of shift |
value | The value to be shifted |
shift | The shift in bits |
value
|
constexprnoexcept |
Performs a left logical bit shift operation (shl
, <<<
).
The shift
is unsigned.
The result of the shift will be of the same type as the value
being shifted. If the shift is a negative number of bits, then a right logical shift will be performed. If the shift size is greater than or equal to the number of bits in the shifted value
, then 0
will be returned.
ValueType | The type of value |
UnsignedShiftType | The type of shift |
value | The value to be shifted |
shift | The shift in bits |
value
|
constexprnoexcept |
Performs a bitwise OR operation between two values of possibly different types and ensures the result is cast back to the type of the first argument.
FirstType | The type of the first argument. |
SecondType | The type of the second argument. |
first | The first operand of type FirstType . |
second | The second operand of type SecondType . |
FirstType
.
|
constexpr |
Resets (clears) specific bits in a bitmask.
SourceBitsType | The type of the source bits (e.g., an integer type). |
BitMaskType | The type of the bit mask (e.g., an integer type). |
sourceBits | The original bitmask containing the bits to modify. |
bitMaskToReset | The bitmask specifying the bits to reset. |
|
constexpr |
Resets (clears) specific bits in a bitmask.
T | The type of the source bits and the bitmask. Should be an integral type. |
sourceBits | The original bitmask containing the bits to modify. |
bitMaskToReset | The bitmask specifying the bits to reset. |
|
constexprnoexcept |
Performs a right arithmetic bit shift operation (sar
, >>
in Java, C, etc.).
The shift
is signed. The sign bit is extended to preserve the signedness of the number.
The result of the shift will be of the same type as the value
being shifted. If the shift is a negative number of bits, then a left arithmetic shift will be performed. If the shift size is greater than or equal to the number of bits in the shifted value
, then, if the value
is negative (a signed integer type), -1
will be returned, and if positive, then 0
will be returned.
ValueType | The type of value |
SignedShiftType | The type of shift |
value | The value to be shifted |
shift | The shift in bits |
value
|
constexprnoexcept |
Performs a right arithmetic bit shift operation (sar
, >>
in Java, C, etc.).
The shift
is unsigned. The sign bit is extended to preserve the signedness of the number.
The result of the shift will be of the same type as the value
being shifted. If the shift size is greater than or equal to the number of bits in the shifted value
, then, if the value
is negative (a signed integer type), -1
will be returned, and if positive, then 0
will be returned.
ValueType | The type of value |
UnsignedShiftType | The type of shift |
value | The value to be shifted |
shift | The shift in bits |
value
|
constexprnoexcept |
Performs a right logical bit shift operation (shr
, >>>
in Java).
The shift
is signed. Fills the left bits by zero.
The result of the shift will be of the same type as the value
being shifted. If the shift is a negative number of bits, then a left logical shift will be performed. If the shift size is greater than or equal to the number of bits in the shifted value
, then 0
will be returned.
ValueType | The type of value |
SignedShiftType | The type of shift |
value | The value to be shifted |
shift | The shift in bits |
value
|
constexprnoexcept |
Performs a right logical bit shift operation (shr
, >>>
in Java).
The shift
is unsigned. Fills the left bits by zero.
The result of the shift will be of the same type as the value
being shifted. If the shift is a negative number of bits, then a left logical shift will be performed. If the shift size is greater than or equal to the number of bits in the shifted value
, then 0
will be returned.
ValueType | The type of value |
UnsignedShiftType | The type of shift |
value | The value to be shifted |
shift | The shift in bits |
value
|
constexprnoexcept |
Performs a left arithmetic bit shift operation (<<
in Java, C, etc.).
The result of the shift will be of the same type as the value
being shifted. If the shift is a negative number of bits, then a right arithmetic shift will be performed. If the shift size is greater than or equal to the number of bits in the shifted value
, then 0
will be returned.
ValueType | The type of value |
ShiftType | The type of shift |
value | The value to be shifted. |
shift | The shift in bits |
value
|
constexprnoexcept |
Performs a right arithmetic bit shift operation (>>
in Java, C, etc.).
The sign bit is extended to preserve the signedness of the number.
The result of the shift will be of the same type as the value
being shifted. If the shift is a negative number of bits, then a left arithmetic shift will be performed. If the shift size is greater than or equal to the number of bits in the shifted value
, then, if the value
is negative (a signed integer type), -1
will be returned, and if positive, then 0
will be returned.
ValueType | The type of value |
ShiftType | The type of shift |
value | The value to be shifted. |
shift | The shift in bits |
value
|
constexpr |
Sets specific bits in the source value using a bitmask.
SourceBitsType | The type of the source bits (e.g., an integer type). |
BitMaskType | The type of the bit mask (e.g., an integer type). |
sourceBits | The original bits to modify. |
bitMaskToSet | The bitmask representing the bits to be set. |
|
constexpr |
Sets specific bits in the source value using a bitmask.
T | The type of arguments. |
sourceBits | The original bits to modify. |
bitMaskToSet | The bitmask representing the bits to be set. |
|
constexprnoexcept |
Performs a left logical bit shift operation (shl
, <<<
).
The result of the shift will be of the same type as the value
being shifted. If the shift is a negative number of bits, then a right logical shift will be performed. If the shift size is greater than or equal to the number of bits in the shifted value
, then 0
will be returned.
ValueType | The type of value |
ShiftType | The type of shift |
value | The value to be shifted. |
shift | The shift in bits |
value
|
constexprnoexcept |
Performs a right logical bit shift operation (>>>
in Java).
Performs a right logical bit shift operation (shr
, >>>
in Java).
Fills the left bits by zero.
The result of the shift will be of the same type as the value
being shifted. If the shift is a negative number of bits, then a left logical shift will be performed. If the shift size is greater than or equal to the number of bits in the shifted value
, then 0
will be returned.
ValueType | The type of value |
ShiftType | The type of shift |
value | The value to be shifted. |
shift | The shift in bits |
value
|
constexprnoexcept |
Performs a bitwise XOR operation between two values of possibly different types and ensures the result is cast back to the type of the first argument.
FirstType | The type of the first argument. |
SecondType | The type of the second argument. |
first | The first operand of type FirstType . |
second | The second operand of type SecondType . |
FirstType
.