|
Mjolnir Core
Core functionality of the Mjolnir API
|
This submodule of the core module contains various utility functions. More...
Typedefs | |
| template<auto... t_pack> | |
| using | PackType = decltype(internal::pack_type(t_pack...)) |
| The type of a parameter pack that consist of values and not of types. More... | |
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 = void> | |
| auto | integer_to_pointer (UPT integer) noexcept -> T_Type * |
| Turn an integer into a pointer of the chosen type. More... | |
| template<UST t_alignment, typename T_Type > | |
| auto | is_aligned (const volatile T_Type *pointer) noexcept -> bool |
| Check if a passed pointer is aligned. More... | |
| template<typename T_Type > | |
| auto | is_aligned (const volatile T_Type *pointer, UST alignment) noexcept -> bool |
| Check if a passed pointer is aligned. More... | |
| template<typename T_Type , typename T_OtherType , typename... T_TypeList> | |
| consteval auto | is_any_of () noexcept -> bool |
Return true if the tested type is identical to any of a list of types. 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<typename T_Type > | |
| requires Number< T_Type > auto | is_close_abs (T_Type lhs, T_Type rhs, T_Type tolerance=default_tolerance_abs< T_Type >) noexcept -> bool |
Return ´true´ if the difference between lhs and rhs is inside an absolute tolerance and false otherwise. More... | |
| template<UST t_alignment, typename T_Type > | |
| auto | misalignment (const volatile T_Type *pointer) noexcept -> UST |
| Calculate the misalignment of a pointer. More... | |
| template<typename T_Type > | |
| auto | misalignment (const volatile T_Type *pointer, UST alignment) noexcept -> UST |
| Calculate the misalignment of a pointer. More... | |
| template<auto... t_pack, std::invocable< PackType< t_pack... >> T_Func> | |
| consteval auto | pack_all (T_Func func) noexcept -> bool |
Return true if the passed function object returns true for all parameter pack values as input. More... | |
| template<bool... t_pack> | |
| consteval auto | pack_all_false () noexcept -> bool |
Return true if all values of an boolean parameter pack are false and false otherwise. More... | |
| template<UST... t_pack> | |
| consteval auto | pack_all_less (UST value) noexcept -> bool |
Return true if all values of an unsigned integer parameter pack are less then a given value and false otherwise. More... | |
| template<bool... t_pack> | |
| consteval auto | pack_all_true () noexcept -> bool |
Return true if all values of an boolean parameter pack are true and false otherwise. More... | |
| template<typename T_Type > | |
| auto | pointer_to_integer (const volatile T_Type *pointer) noexcept -> UPT |
| Turn a pointer into an integer. 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... | |
| template<std::integral T_Type> | |
| constexpr auto | signed_to_unsigned (T_Type value) -> EquallySizedUnsignedType< T_Type > |
| Cast an integer to an equally sized unsigned type. More... | |
Variables | |
| template<typename T_Type > | |
| constexpr T_Type | default_tolerance_abs = static_cast<T_Type>(1E-6) |
| The default absolute tolerance. More... | |
| template<typename T_Type > | |
| constexpr UST | num_bits = sizeof(T_Type) * CHAR_BIT |
| The size of a type in bits. More... | |
This submodule of the core module contains various utility functions.