Utility Bitmask#
- group Bitmask
Functions
-
inline constexpr size_type word_index(size_type bit_index)#
Returns the index of the word containing the specified bit.
- Parameters:
bit_index – The index of the bit to query
- Returns:
The index of the word containing the specified bit
-
inline constexpr size_type intra_word_index(size_type bit_index)#
Returns the position within a word of the specified bit.
- Parameters:
bit_index – The index of the bit to query
- Returns:
The position within a word of the specified bit
- inline void set_bit_unsafe(
- bitmask_type *bitmask,
- size_type bit_index
Sets the specified bit to
1This function is not thread-safe, i.e., attempting to update bits within the same word concurrently from multiple threads results in undefined behavior.
- Parameters:
bitmask – The bitmask containing the bit to set
bit_index – Index of the bit to set
- inline void clear_bit_unsafe(
- bitmask_type *bitmask,
- size_type bit_index
Sets the specified bit to
0This function is not thread-safe, i.e., attempting to update bits within the same word concurrently from multiple threads results in undefined behavior.
- Parameters:
bitmask – The bitmask containing the bit to clear
bit_index – The index of the bit to clear
- inline bool bit_is_set(
- bitmask_type const *bitmask,
- size_type bit_index
Indicates whether the specified bit is set to
1- Parameters:
bitmask – The bitmask containing the bit to test
bit_index – Index of the bit to test
- Returns:
true The specified bit is
1- Returns:
false The specified bit is
0
- inline bool bit_value_or(
- bitmask_type const *bitmask,
- size_type bit_index,
- bool default_value
optional-like interface to check if a specified bit of a bitmask is set.
- Parameters:
bitmask – The bitmask containing the bit to clear
bit_index – Index of the bit to test
default_value – Value to return if
bitmaskis nullptr
- Returns:
true The specified bit is
1- Returns:
false The specified bit is
0- Returns:
default_valueifbitmaskis nullptr
- inline constexpr bitmask_type set_least_significant_bits( )#
Returns a bitmask word with the
nleast significant bits set.Behavior is undefined if
n < 0or ifn >= size_in_bits<bitmask_type>()- Parameters:
n – The number of least significant bits to set
- Returns:
A bitmask word with
nleast significant bits set
-
inline constexpr bitmask_type set_most_significant_bits(size_type n)#
Returns a bitmask word with the
nmost significant bits set.Behavior is undefined if
n < 0or ifn >= size_in_bits<bitmask_type>()- Parameters:
n – The number of most significant bits to set
- Returns:
A bitmask word with
nmost significant bits set
-
inline constexpr size_type word_index(size_type bit_index)#