5#include "../platform/attributes.hpp"
6#include "../platform/constexpr.hpp"
8#include <initializer_list>
42 using unsigned_type =
typename std::make_unsigned<underlying_type>::type;
76 REXLIB_CONSTEXPR
flagset(It first, It last) noexcept;
128 REXLIB_CONSTEXPR operator
bool() const noexcept;
170 friend REXLIB_CONSTEXPR
173 return lhs.m_data == rhs.m_data;
184 friend REXLIB_CONSTEXPR
187 return lhs.m_data != rhs.m_data;
247 REXLIB_CONSTEXPR
int count() const noexcept;
255 REXLIB_CONSTEXPR
bool parity() const noexcept;
305 friend REXLIB_CONSTEXPR
308 return flagset(lhs.m_data | rhs.m_data);
311 friend REXLIB_CONSTEXPR
314 return flagset(lhs.m_data & rhs.m_data);
317 friend REXLIB_CONSTEXPR
320 return flagset(lhs.m_data ^ rhs.m_data);
335#include "flagset.inl"
Stores a set of bits in the form of flags Similar to std::bitset but instead of a index based interfa...
Definition flagset.hpp:24
REXLIB_CONSTEXPR flagset & set(const flagset &other, bool value) noexcept
Set a particular set of flags to the desired value.
B bit_type
The provided enum declaration of the flag bits.
Definition flagset.hpp:30
REXLIB_CONSTEXPR bool none_of(const flagset &other) const noexcept
Checks if none of a set of flags are present in this.
REXLIB_CONSTEXPR bool contains(const bit_type &bit) const noexcept
Tests if the requested flag is set.
REXLIB_CONSTEXPR bool parity() const noexcept
Computes the parity of the stored flags.
typename std::underlying_type< bit_type >::type underlying_type
The underlying type of the provided enum.
Definition flagset.hpp:36
REXLIB_CONSTEXPR bool all_of(const flagset &other) const noexcept
Checks if all of a set of flags are present in this.
REXLIB_CONSTEXPR bool any_of(const flagset &other) const noexcept
Checks if any of a set of flags are present in this.
typename std::make_unsigned< underlying_type >::type unsigned_type
Unsigned underlying type of the provided enum.
Definition flagset.hpp:42
REXLIB_CONSTEXPR flagset & clear() noexcept
Clears all flags.
REXLIB_CONSTEXPR underlying_type get_bits() const noexcept
Obtain the underlying integer representation of the flags.
REXLIB_CONSTEXPR bool only_of(const flagset &other) const noexcept
Checks if only a set of flags are present in this.
REXLIB_CONSTEXPR int count() const noexcept
Counts the number of flags that are present.
REXLIB_CONSTEXPR bool has_single_bit() const noexcept
Checks if only one flag is present.
REXLIB_CONSTEXPR flagset & toggle(const flagset &other) noexcept
Toggles a particular set of flags.
friend REXLIB_CONSTEXPR bool operator!=(const flagset &lhs, const flagset &rhs) noexcept
Compares for inequality with another flagset.
Definition flagset.hpp:185
REXLIB_CONSTEXPR flagset() noexcept
Empty constructor. It initializes the set as none of the flags were set.
Arrays, the operations on them and the devices that run those operations.
Definition cpu_device.hpp:10
REXLIB_NODISCARD REXLIB_CONSTEXPR std::size_t bit(std::size_t i) noexcept
Returns a std::size_t type with a single bit set at the provided index.