tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
basic_bitset< Bits, WordType > Struct Template Reference

#include <etl/bitset.hpp>

Classes

struct  reference
 

Public Member Functions

constexpr basic_bitset ()=default
 Default constructor. Constructs a bitset with all bits set to zero.
 
constexpr basic_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.
 
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 -> etl::size_t
 Returns the number of bits that are set to true.
 
constexpr auto flip () noexcept -> basic_bitset &
 Flips all bits.
 
constexpr auto none () const noexcept -> bool
 Checks if none of the bits are set to true.
 
constexpr auto operator&= (basic_bitset const &other) noexcept -> basic_bitset &
 Sets the bits to the result of binary AND on corresponding pairs of bits of *this and other
 
constexpr auto operator[] (etl::size_t pos) -> reference
 Returns a reference to the bit at position pos.
 
constexpr auto operator[] (etl::size_t pos) const -> bool
 Returns true if the bit at position pos is set.
 
constexpr auto operator^= (basic_bitset const &other) noexcept -> basic_bitset &
 Sets the bits to the result of binary XOR on corresponding pairs of bits of *this and other
 
constexpr auto operator|= (basic_bitset const &other) noexcept -> basic_bitset &
 Sets the bits to the result of binary OR on corresponding pairs of bits of *this and other
 
constexpr auto reset () noexcept -> basic_bitset &
 Sets all bits to false.
 
constexpr auto set () noexcept -> basic_bitset &
 Sets all bits to true.
 
constexpr auto size () const noexcept -> etl::size_t
 Returns the number of bits that the bitset holds.
 
constexpr auto unchecked_flip (etl::size_t pos) -> basic_bitset &
 Flip bit at position pos.
 
constexpr auto unchecked_reset (etl::size_t pos) -> basic_bitset &
 Sets the bit at position pos to false.
 
constexpr auto unchecked_set (etl::size_t pos, bool value=true) -> basic_bitset &
 Set bit at position pos to value.
 
constexpr auto unchecked_test (etl::size_t pos) const -> bool
 Returns true if the bit at position pos is set.
 

Friends

constexpr auto operator& (basic_bitset const &lhs, basic_bitset const &rhs) noexcept -> basic_bitset
 Returns a basic_bitset containing the result of binary AND on corresponding pairs of bits of lhs and rhs.
 
constexpr auto operator== (basic_bitset const &lhs, basic_bitset const &rhs) -> bool=default
 Returns true if all of the bits in lhs and rhs are equal.
 
constexpr auto operator^ (basic_bitset const &lhs, basic_bitset const &rhs) noexcept -> basic_bitset
 Returns a basic_bitset containing the result of binary XOR on corresponding pairs of bits of lhs and rhs.
 
constexpr auto operator| (basic_bitset const &lhs, basic_bitset const &rhs) noexcept -> basic_bitset
 Returns a basic_bitset containing the result of binary OR on corresponding pairs of bits of lhs and rhs.
 

Constructor & Destructor Documentation

◆ basic_bitset() [1/2]

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
basic_bitset ( )
constexprdefault

Default constructor. Constructs a bitset with all bits set to zero.

◆ basic_bitset() [2/2]

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
basic_bitset ( unsigned long long val)
inlineconstexprnoexcept

Constructs a bitset, initializing the first (rightmost, least significant) M bit positions to the corresponding bit values of val.

Member Function Documentation

◆ all()

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
auto all ( ) const -> bool
inlinenodiscardconstexprnoexcept

Checks if all bits are set to true.

◆ any()

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
auto any ( ) const -> bool
inlinenodiscardconstexprnoexcept

Checks if any bits are set to true.

◆ count()

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
auto count ( ) const -> etl::size_t
inlinenodiscardconstexprnoexcept

Returns the number of bits that are set to true.

◆ flip()

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
auto flip ( ) -> basic_bitset&
inlineconstexprnoexcept

Flips all bits.

◆ none()

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
auto none ( ) const -> bool
inlinenodiscardconstexprnoexcept

Checks if none of the bits are set to true.

◆ operator&=()

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
auto operator&= ( basic_bitset< Bits, WordType > const & other) -> basic_bitset&
inlineconstexprnoexcept

Sets the bits to the result of binary AND on corresponding pairs of bits of *this and other

◆ operator[]() [1/2]

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
auto operator[] ( etl::size_t pos) -> reference
inlinenodiscardconstexpr

Returns a reference to the bit at position pos.

Precondition
pos < size()

◆ operator[]() [2/2]

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
auto operator[] ( etl::size_t pos) const -> bool
inlinenodiscardconstexpr

Returns true if the bit at position pos is set.

Precondition
pos < size()

◆ operator^=()

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
auto operator^= ( basic_bitset< Bits, WordType > const & other) -> basic_bitset&
inlineconstexprnoexcept

Sets the bits to the result of binary XOR on corresponding pairs of bits of *this and other

◆ operator|=()

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
auto operator|= ( basic_bitset< Bits, WordType > const & other) -> basic_bitset&
inlineconstexprnoexcept

Sets the bits to the result of binary OR on corresponding pairs of bits of *this and other

◆ reset()

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
auto reset ( ) -> basic_bitset&
inlineconstexprnoexcept

Sets all bits to false.

◆ set()

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
auto set ( ) -> basic_bitset&
inlineconstexprnoexcept

Sets all bits to true.

◆ size()

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
auto size ( ) const -> etl::size_t
inlinenodiscardconstexprnoexcept

Returns the number of bits that the bitset holds.

◆ unchecked_flip()

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
auto unchecked_flip ( etl::size_t pos) -> basic_bitset&
inlineconstexpr

Flip bit at position pos.

Precondition
pos < size()

◆ unchecked_reset()

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
auto unchecked_reset ( etl::size_t pos) -> basic_bitset&
inlineconstexpr

Sets the bit at position pos to false.

Precondition
pos < size()

◆ unchecked_set()

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
auto unchecked_set ( etl::size_t pos,
bool value = true ) -> basic_bitset&
inlineconstexpr

Set bit at position pos to value.

Precondition
pos < size()

◆ unchecked_test()

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
auto unchecked_test ( etl::size_t pos) const -> bool
inlinenodiscardconstexpr

Returns true if the bit at position pos is set.

Precondition
pos < size()

Friends And Related Symbol Documentation

◆ operator&

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
auto operator& ( basic_bitset< Bits, WordType > const & lhs,
basic_bitset< Bits, WordType > const & rhs ) -> basic_bitset
friend

Returns a basic_bitset containing the result of binary AND on corresponding pairs of bits of lhs and rhs.

◆ operator==

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
auto operator== ( basic_bitset< Bits, WordType > const & lhs,
basic_bitset< Bits, WordType > const & rhs ) -> bool=default
friend

Returns true if all of the bits in lhs and rhs are equal.

◆ operator^

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
auto operator^ ( basic_bitset< Bits, WordType > const & lhs,
basic_bitset< Bits, WordType > const & rhs ) -> basic_bitset
friend

Returns a basic_bitset containing the result of binary XOR on corresponding pairs of bits of lhs and rhs.

◆ operator|

template<etl::size_t Bits, etl::unsigned_integral WordType = etl::size_t>
auto operator| ( basic_bitset< Bits, WordType > const & lhs,
basic_bitset< Bits, WordType > const & rhs ) -> basic_bitset
friend

Returns a basic_bitset containing the result of binary OR on corresponding pairs of bits of lhs and rhs.


The documentation for this struct was generated from the following file: