Bit manipulation.
|
template<typename T = unsigned, typename ReturnT = BitFunctionReturnType<T>> |
constexpr auto | gul14::bit_set (unsigned bit) noexcept -> ReturnT |
| Set a bit in an integral type. More...
|
|
template<typename T , typename ReturnT = BitFunctionReturnType<T>> |
constexpr auto | gul14::bit_set (T previous, unsigned bit) noexcept -> ReturnT |
| Set a bit in an integral value. More...
|
|
template<typename T , typename ReturnT = BitFunctionReturnType<T>> |
constexpr auto | gul14::bit_reset (T previous, unsigned bit) noexcept -> ReturnT |
| Reset a bit in an integral value. More...
|
|
template<typename T , typename ReturnT = BitFunctionReturnType<T>> |
constexpr auto | gul14::bit_flip (T previous, unsigned bit) noexcept -> ReturnT |
| Flip a bit in an integral value. More...
|
|
template<typename T > |
constexpr bool | gul14::bit_test (T bits, unsigned bit) noexcept |
| Test a bit in an integral value. More...
|
|
template<typename T , typename ReturnT = BitFunctionReturnType<T>>
constexpr auto gul14::bit_flip |
( |
T |
previous, |
|
|
unsigned |
bit |
|
) |
| -> ReturnT |
|
inlineconstexprnoexcept |
Flip a bit in an integral value.
Flips the bit number bit in the existing value previous. This inverts the state of the bit: setting the bit if it was previously not set and resetting the bit if it was previously set.
When bit is greater or equal to the number of bits in type T, std::abort() is called (via assert()).
- Parameters
-
previous | Existing integral value where the bit shall be modified |
bit | Number of the bit that is to be modified (LSB == 0) |
- Returns
- New integral value with the bit modified.
- Template Parameters
-
T | Type of the bit-holding integral value. |
- Since
- GUL version 1.8
- See also
- bit_set(bit), bit_set(previous, bit), bit_reset(previous, bit), bit_test(bits, bit)
template<typename T , typename ReturnT = BitFunctionReturnType<T>>
constexpr auto gul14::bit_reset |
( |
T |
previous, |
|
|
unsigned |
bit |
|
) |
| -> ReturnT |
|
inlineconstexprnoexcept |
Reset a bit in an integral value.
Reset (clear) the bit number bit in the existing value previous.
When bit is greater or equal to the number of bits in type T, std::abort() is called (via assert()).
- Parameters
-
previous | Existing integral value where the bit shall be modified |
bit | Number of the bit that is to be modified (LSB == 0) |
- Returns
- New integral value with the bit modified.
- Template Parameters
-
T | Type of the bit-holding integral value. |
- Since
- GUL version 1.8
- See also
- bit_set(bit), bit_set(previous, bit), bit_flip(previous, bit), bit_test(bits, bit)
template<typename T , typename ReturnT = BitFunctionReturnType<T>>
constexpr auto gul14::bit_set |
( |
T |
previous, |
|
|
unsigned |
bit |
|
) |
| -> ReturnT |
|
inlineconstexprnoexcept |
Set a bit in an integral value.
Set the bit number bit in the existing value previous.
When bit is greater or equal to the number of bits in type T, std::abort() is called (via assert()).
- Parameters
-
previous | Existing integral value where the bit shall be modified |
bit | Number of the bit that is to be modified (LSB == 0) |
- Returns
- New integral value with the bit modified.
- Template Parameters
-
T | Type of the bit-holding integral value. |
- Since
- GUL version 1.8
- See also
- bit_set(bit), bit_reset(previous, bit), bit_flip(previous, bit), bit_test(bits, bit)
template<typename T = unsigned, typename ReturnT = BitFunctionReturnType<T>>
constexpr auto gul14::bit_set |
( |
unsigned |
bit | ) |
-> ReturnT |
|
inlineconstexprnoexcept |
Set a bit in an integral type.
Return an integral value of type T where the bit number bit and only that bit is set.
When bit is greater or equal to the number of bits in type T, std::abort() is called (via assert()).
- Parameters
-
bit | Number of the bit that is to be set (LSB == 0) |
- Returns
- Integral value with the bit set.
- Template Parameters
-
T | Type of the bit-holding integral value. |
- Note
- If no type T is specified an unsigned int will be returned.
- Since
- GUL version 1.8
- See also
- bit_set(previous, bit), bit_reset(previous, bit), bit_flip(previous, bit), bit_test(bits, bit)