|
Mjolnir Core
Core functionality of the Mjolnir API
|
Contains utility functions for bit related operations like setting and reading specific bits. More...
#include "mjolnir/core/fundamental_types.h"#include <concepts>#include <limits>#include <initializer_list>#include <algorithm>#include <cassert>

Go to the source code of this file.
Functions | |
| template<std::unsigned_integral T_Type, UST... t_bit_values> | |
| consteval auto | bit_construct ([[maybe_unused]] bool left_is_low=false) noexcept -> T_Type |
| Construct an unsigned integer by setting its individual bits. More... | |
| template<UST t_num_int_bits, std::unsigned_integral T_Type, UST... t_integers> | |
| consteval auto | bit_construct_from_ints (bool left_is_low=false) noexcept -> T_Type |
| Construct an unsigned integer from the bit patterns of multiple integer values. More... | |
| template<std::unsigned_integral T_Type, UST t_num_bits> | |
| constexpr auto | bit_construct_set_first_n_bits () noexcept -> T_Type |
Construct an unsigned integer with its first t_num_bits set to 1. More... | |
| template<std::unsigned_integral T_Type> | |
| constexpr void | clear_bit (T_Type &integer, UST index) noexcept |
| Clear a single specific bit of an unsigned integer. More... | |
| template<UST t_num_bits, std::unsigned_integral T_Type> | |
| constexpr void | clear_bits (T_Type &integer, UST index) noexcept |
| Clear multiple consecutive bits of an unsigned integer. More... | |
| template<UST t_index, I32 t_shift = 0, std::unsigned_integral T_Type = UST, std::unsigned_integral T_ReturnType = T_Type> | |
| constexpr auto | get_bit (T_Type integer) noexcept -> T_ReturnType |
| Extract a bit from an integer and store it with an optional shift in a new integer. More... | |
| template<std::unsigned_integral T_Type = UST, std::unsigned_integral T_ReturnType = T_Type> | |
| constexpr auto | get_bit (T_Type integer, UST index, I32 shift=0) noexcept -> T_ReturnType |
| Extract a bit from an integer and store it with an optional shift in a new integer. More... | |
| template<UST t_index, bool t_shift_right = true, std::unsigned_integral T_Type = UST, std::unsigned_integral T_ReturnType = T_Type> | |
| constexpr auto | get_bit_shift_max (T_Type integer) noexcept -> T_ReturnType |
| Extract a bit from an integer and shift it maximally. More... | |
| template<bool t_shift_right = true, std::unsigned_integral T_Type = UST, std::unsigned_integral T_ReturnType = T_Type> | |
| constexpr auto | get_bit_shift_max (T_Type integer, UST index) noexcept -> T_ReturnType |
| Extract a bit from an integer and shift it maximally. More... | |
| template<UST t_index, UST t_num_bits, I32 t_shift = 0, std::unsigned_integral T_Type = UST, std::unsigned_integral T_ReturnType = T_Type> | |
| constexpr auto | get_bits (T_Type integer) noexcept -> T_ReturnType |
| Extract a bit pattern from an integer and store it with an optional shift in a new integer. More... | |
| template<UST t_num_bits, std::unsigned_integral T_Type = UST, std::unsigned_integral T_ReturnType = T_Type> | |
| constexpr auto | get_bits (T_Type integer, UST index, I32 shift=0) noexcept -> T_ReturnType |
| Extract a bit pattern from an integer and store it with an optional shift in a new integer. More... | |
| template<UST t_index, UST t_num_bits, bool t_shift_right = true, std::unsigned_integral T_Type = UST, std::unsigned_integral T_ReturnType = T_Type> | |
| constexpr auto | get_bits_shift_max (T_Type integer) noexcept -> T_ReturnType |
| Extract a bit pattern from an integer and store it with a maximal shift in a new integer. More... | |
| template<UST t_num_bits, bool t_shift_right = true, std::unsigned_integral T_Type = UST, std::unsigned_integral T_ReturnType = T_Type> | |
| constexpr auto | get_bits_shift_max (T_Type integer, UST index) noexcept -> T_ReturnType |
| Extract a bit pattern from an integer and store it with a maximal shift in a new integer. More... | |
| template<typename T_Type > | |
| constexpr auto | is_bit_set (T_Type integer, UST index) noexcept -> bool |
Return true if a specific bit is set and false otherwise. More... | |
| template<std::unsigned_integral T_Type> | |
| constexpr void | set_bit (T_Type &integer, UST index) noexcept |
| Set a single specific bit of an unsigned integer. More... | |
| template<UST t_value, std::unsigned_integral T_Type> | |
| constexpr void | set_bit_to (T_Type &integer, UST index) noexcept |
| Set a single bit of an unsigned integer to the specified value. More... | |
| template<UST t_num_bits, std::unsigned_integral T_Type> | |
| constexpr void | set_bits (T_Type &integer, UST index) noexcept |
| Set multiple consecutive bits of an unsigned integer. More... | |
| template<UST t_num_bits, bool t_clear_bits = true, std::unsigned_integral T_Type> | |
| constexpr void | set_bits_with_int (T_Type &integer, UST index, UST value) noexcept |
| Set multiple consecutive bits of an unsigned integer using the bit pattern of another integer value. More... | |
Variables | |
| template<typename T_Type > | |
| constexpr UST | num_bits = sizeof(T_Type) * CHAR_BIT |
| The size of a type in bits. More... | |
Contains utility functions for bit related operations like setting and reading specific bits.