header_utils
Loading...
Searching...
No Matches
Flag Bits

Functions

template<typename RESULT_TYPE = unsigned long long, typename... ARGS>
requires detail::valid_flag_bits_arguments<RESULT_TYPE, ARGS...>
constexpr RESULT_TYPE ghassanpl::flag_bits (ARGS... args) noexcept
 Takes a list of enum values that represent bit numbers (not actual bit values) and returns a value with all the chosen bits set.
template<typename RESULT_TYPE = unsigned long long, typename BIT_TYPE>
constexpr RESULT_TYPE ghassanpl::bit_to_flag (BIT_TYPE bit) noexcept
template<typename INTEGRAL, typename ENUM_TYPE>
constexpr bool ghassanpl::is_flag_set (INTEGRAL const &bits, ENUM_TYPE flag) noexcept
 Checks if an integral value has the bit at number represented by flag set.
template<typename INTEGRAL, typename... ARGS>
constexpr bool ghassanpl::are_any_flags_set (INTEGRAL const &bits, ARGS... args) noexcept
 Checks if an integral value has any of the bits at numbers represented by args set.
template<typename INTEGRAL, typename... ARGS>
constexpr bool ghassanpl::are_all_flags_set (INTEGRAL const &bits, ARGS... args) noexcept
 Checks if an integral value has all of the bits at numbers represented by args set.
template<typename INTEGRAL, typename... ARGS>
constexpr void ghassanpl::set_flags (INTEGRAL &bits, ARGS... args) noexcept
 Sets the bits at numbers represented by args in bits.
template<typename INTEGRAL, typename... ARGS>
constexpr void ghassanpl::unset_flags (INTEGRAL &bits, ARGS... args) noexcept
 Unsets the bits at numbers represented by args in bits.
template<typename INTEGRAL, typename... ARGS>
constexpr void ghassanpl::toggle_flags (INTEGRAL &bits, ARGS... args) noexcept
 Toggles the bits at numbers represented by args in bits.
template<typename INTEGRAL, typename... ARGS>
constexpr void ghassanpl::set_flags_to (INTEGRAL &bits, bool val, ARGS... args) noexcept
 Sets the bits at numbers represented by args in bits to either 0 or 1, depending on val.

Detailed Description

Function Documentation

◆ are_all_flags_set()

template<typename INTEGRAL, typename... ARGS>
bool ghassanpl::are_all_flags_set ( INTEGRAL const & bits,
ARGS... args )
constexprnoexcept

Checks if an integral value has all of the bits at numbers represented by args set.

Definition at line 92 of file flag_bits.h.

◆ are_any_flags_set()

template<typename INTEGRAL, typename... ARGS>
bool ghassanpl::are_any_flags_set ( INTEGRAL const & bits,
ARGS... args )
constexprnoexcept

Checks if an integral value has any of the bits at numbers represented by args set.

Definition at line 84 of file flag_bits.h.

◆ bit_to_flag()

template<typename RESULT_TYPE = unsigned long long, typename BIT_TYPE>
RESULT_TYPE ghassanpl::bit_to_flag ( BIT_TYPE bit)
constexprnoexcept

Definition at line 68 of file flag_bits.h.

◆ flag_bits()

template<typename RESULT_TYPE = unsigned long long, typename... ARGS>
requires detail::valid_flag_bits_arguments<RESULT_TYPE, ARGS...>
RESULT_TYPE ghassanpl::flag_bits ( ARGS... args)
constexprnoexcept

Takes a list of enum values that represent bit numbers (not actual bit values) and returns a value with all the chosen bits set.

Example
enum class Flags {
Parity,
Zero,
Positive,
};
flag_bits(Flags::Parity, Flags::Positive) -> 3
constexpr RESULT_TYPE flag_bits(ARGS... args) noexcept
Takes a list of enum values that represent bit numbers (not actual bit values) and returns a value wi...
Definition flag_bits.h:60
Template Parameters
RESULT_TYPEthe type of the result value, unsigned long long by default

Definition at line 60 of file flag_bits.h.

◆ is_flag_set()

template<typename INTEGRAL, typename ENUM_TYPE>
bool ghassanpl::is_flag_set ( INTEGRAL const & bits,
ENUM_TYPE flag )
constexprnoexcept

Checks if an integral value has the bit at number represented by flag set.

Definition at line 79 of file flag_bits.h.

◆ set_flags()

template<typename INTEGRAL, typename... ARGS>
void ghassanpl::set_flags ( INTEGRAL & bits,
ARGS... args )
constexprnoexcept

Sets the bits at numbers represented by args in bits.

Definition at line 100 of file flag_bits.h.

◆ set_flags_to()

template<typename INTEGRAL, typename... ARGS>
void ghassanpl::set_flags_to ( INTEGRAL & bits,
bool val,
ARGS... args )
constexprnoexcept

Sets the bits at numbers represented by args in bits to either 0 or 1, depending on val.

Definition at line 115 of file flag_bits.h.

◆ toggle_flags()

template<typename INTEGRAL, typename... ARGS>
void ghassanpl::toggle_flags ( INTEGRAL & bits,
ARGS... args )
constexprnoexcept

Toggles the bits at numbers represented by args in bits.

Definition at line 110 of file flag_bits.h.

◆ unset_flags()

template<typename INTEGRAL, typename... ARGS>
void ghassanpl::unset_flags ( INTEGRAL & bits,
ARGS... args )
constexprnoexcept

Unsets the bits at numbers represented by args in bits.

Definition at line 105 of file flag_bits.h.