The class template bitset represents a fixed-size sequence of Bits bits. Bitsets can be manipulated by standard logic operators.
More...
|
constexpr | bitset () noexcept=default |
| Constructs a bitset with all bits set to zero.
|
|
template<typename CharT , typename Traits > |
constexpr | bitset (basic_string_view< CharT, Traits > const &str, typename basic_string_view< CharT, Traits >::size_type pos=0, typename basic_string_view< CharT, Traits >::size_type n=basic_string_view< CharT, Traits >::npos, CharT zero=CharT('0'), CharT one=CharT('1')) |
| Constructs a bitset using the characters in the etl::basic_string_view str.
|
|
template<typename CharT > |
constexpr | bitset (CharT const *str, typename basic_string_view< CharT >::size_type n=basic_string_view< CharT >::npos, CharT zero=CharT('0'), CharT one=CharT('1')) |
| Constructs a bitset using the characters in the char const* str.
|
|
constexpr | bitset (unsigned long long val) noexcept |
| Constructs a bitset, initializing the first (rightmost, least significant) M bit positions to the corresponding bit values of val, where M is the smaller of the number of bits in an unsigned long long and the number of bits Bits in the bitset being constructed. If M is less than Bits (the bitset is longer than 64 bits, for typical implementations of unsigned long long), the remaining bit positions are initialized to zeroes.
|
|
constexpr auto | all () const noexcept -> bool |
| Checks if all bits are set to true.
|
|
constexpr auto | any () const noexcept -> bool |
| Checks if any bits are set to true.
|
|
constexpr auto | count () const noexcept -> size_t |
| Returns the number of bits that are set to true.
|
|
constexpr auto | flip () noexcept -> bitset & |
| Flips all bits (like operator~, but in-place).
|
|
constexpr auto | flip (size_t pos) noexcept -> bitset & |
| Flips the bit at the position pos.
|
|
constexpr auto | none () const noexcept -> bool |
| Checks if none bits are set to true.
|
|
constexpr auto | operator&= (bitset const &other) noexcept -> bitset & |
| Sets the bits to the result of binary AND on corresponding pairs of bits of *this and other.
|
|
constexpr auto | operator== (bitset const &rhs) const noexcept -> bool |
| Returns true if all of the bits in *this and rhs are equal.
|
|
constexpr auto | operator[] (size_t const pos) -> reference |
| Returns a reference like proxy to the bit at the position pos. Perfoms no bounds checking.
|
|
constexpr auto | operator[] (size_t const pos) const -> bool |
| Returns the value of the bit at the position pos. Perfoms no bounds checking.
|
|
constexpr auto | operator^= (bitset const &other) noexcept -> bitset & |
| Sets the bits to the result of binary XOR on corresponding pairs of bits of *this and other.
|
|
constexpr auto | operator|= (bitset const &other) noexcept -> bitset & |
| Sets the bits to the result of binary OR on corresponding pairs of bits of *this and other.
|
|
constexpr auto | operator~ () const noexcept -> bitset |
| Returns a temporary copy of *this with all bits flipped (binary NOT).
|
|
constexpr auto | reset () noexcept -> bitset & |
| Sets all bits to false.
|
|
constexpr auto | reset (size_t pos) noexcept -> bitset & |
| Sets the bit at position pos to false.
|
|
constexpr auto | set () noexcept -> bitset & |
| Sets all bits to true.
|
|
constexpr auto | set (etl::size_t pos, bool value=true) -> bitset & |
| Sets the bit at the given position to the given value.
|
|
constexpr auto | size () const noexcept -> size_t |
| Returns the number of bits that the bitset holds.
|
|
constexpr auto | test (size_t const pos) const -> bool |
| Returns the value of the bit at the position pos. Perfoms no bounds checking.
|
|
template<size_t Capacity, typename CharT = char, typename Traits = char_traits<CharT>>
requires (Capacity >= Bits) |
constexpr auto | to_string (CharT zero=CharT('0'), CharT one=CharT('1')) const -> basic_inplace_string< CharT, Capacity, Traits > |
| Converts the contents of the bitset to a string. Uses zero to represent bits with value of false and one to represent bits with value of true. The resulting string contains Bits characters with the first character corresponds to the last (Bits-1th) bit and the last character corresponding to the first bit.
|
|
constexpr auto | to_ullong () const noexcept -> unsigned long long requires(etl::numeric_limits< unsigned long long >::digits >=Bits) |
| Converts the contents of the bitset to an unsigned long long integer. The first bit corresponds to the least significant digit of the number and the last bit corresponds to the most significant digit.
|
|
constexpr auto | to_ulong () const noexcept -> unsigned long requires(etl::numeric_limits< unsigned long >::digits >=Bits) |
| Converts the contents of the bitset to an unsigned long integer. The first bit corresponds to the least significant digit of the number and the last bit corresponds to the most significant digit.
|
|
The class template bitset represents a fixed-size sequence of Bits bits. Bitsets can be manipulated by standard logic operators.
- Examples
- bitset.cpp, chrono.cpp, memory.cpp, numeric.cpp, set.cpp, source_location.cpp, string.cpp, tuple.cpp, type_traits.cpp, utility.cpp, and vector.cpp.