bn::ibitset class
#include <bn_bitset.h>

Base class of bitset.

Can be used as a reference type for all bitset containers.

Derived classes

template<int Size>
class bitset
bitset implementation.

Public types

class reference
Proxy to allow to interact with individual bits of a ibitset.
using element_t = uint8_t
Element type alias.

Public functions

auto operator=(const ibitset& other) -> ibitset& constexpr
Copy assignment operator.
auto data() const -> const element_t* constexpr
Returns a const pointer to the beginning of the internal data.
auto size() const -> int constexpr
Returns the bits count.
auto elements_size() const -> int constexpr
Returns the elements count.
auto count() const -> int constexpr
Returns the number of bits that are set to true.
auto test(int index) const -> bool constexpr
Returns the value stored at the specified index.
auto set() -> ibitset& constexpr
Sets all bits to true.
auto set(int index) -> ibitset& constexpr
Sets the specified bit to true.
auto set(int index, bool value) -> ibitset& constexpr
Sets the specified bit to the specified value.
auto reset() -> ibitset& constexpr
Sets all bits to false.
auto reset(int index) -> ibitset& constexpr
Sets the specified bit to false.
auto flip() -> ibitset& constexpr
Flips all values (changes true values to false and vice versa).
auto flip(int index) -> ibitset& constexpr
Flips the specified bit value (changes true value to false and vice versa).
auto operator[](int index) const -> bool constexpr
Returns the value stored at the specified index.
auto operator[](int index) -> reference constexpr
Returns a reference to the value stored at the specified index.
auto at(int index) const -> bool constexpr
Returns the value stored at the specified index.
auto at(int index) -> reference constexpr
Returns a reference to the value stored at the specified index.
auto all() const -> bool constexpr
Indicates if all values are true.
auto any() const -> bool constexpr
Indicates if any value is true.
auto none() const -> bool constexpr
Indicates if all values are false.
auto operator&=(const ibitset& other) -> ibitset& constexpr
Sets the bits to the result of binary AND of this ibitset and the given one.
auto operator|=(const ibitset& other) -> ibitset& constexpr
Sets the bits to the result of binary OR of this ibitset and the given one.
auto operator^=(const ibitset& other) -> ibitset& constexpr
Sets the bits to the result of binary XOR of this ibitset and the given one.
void swap(ibitset& other) constexpr
Exchanges the contents of this ibitset with those of the other one.

Friends

auto swap(ibitset& a, ibitset& b) -> friend void constexpr
Exchanges the contents of an ibitset with those of another one.
auto operator==(const ibitset& a, const ibitset& b) -> friend bool constexpr
Equal operator.
auto operator!=(const ibitset& a, const ibitset& b) -> friend bool constexpr
Not equal operator.

Function documentation

ibitset& bn::ibitset::operator=(const ibitset& other) constexpr

Copy assignment operator.

Parameters
other ibitset to copy.
Returns Reference to this.

ibitset& bn::ibitset::set() constexpr

Sets all bits to true.

Returns Reference to this.

ibitset& bn::ibitset::set(int index) constexpr

Sets the specified bit to true.

Parameters
index Index of the bit to set.
Returns Reference to this.

ibitset& bn::ibitset::set(int index, bool value) constexpr

Sets the specified bit to the specified value.

Parameters
index Index of the bit to set.
value Value to set.
Returns Reference to this.

ibitset& bn::ibitset::reset() constexpr

Sets all bits to false.

Returns Reference to this.

ibitset& bn::ibitset::reset(int index) constexpr

Sets the specified bit to false.

Parameters
index Index of the bit to set.
Returns Reference to this.

ibitset& bn::ibitset::flip() constexpr

Flips all values (changes true values to false and vice versa).

Returns Reference to this.

ibitset& bn::ibitset::flip(int index) constexpr

Flips the specified bit value (changes true value to false and vice versa).

Parameters
index Index of the bit to flip.
Returns Reference to this.

ibitset& bn::ibitset::operator&=(const ibitset& other) constexpr

Sets the bits to the result of binary AND of this ibitset and the given one.

Parameters
other Another ibitset.
Returns Reference to this.

ibitset& bn::ibitset::operator|=(const ibitset& other) constexpr

Sets the bits to the result of binary OR of this ibitset and the given one.

Parameters
other Another ibitset.
Returns Reference to this.

ibitset& bn::ibitset::operator^=(const ibitset& other) constexpr

Sets the bits to the result of binary XOR of this ibitset and the given one.

Parameters
other Another ibitset.
Returns Reference to this.

void bn::ibitset::swap(ibitset& other) constexpr

Exchanges the contents of this ibitset with those of the other one.

Parameters
other ibitset to exchange the contents with.

friend void swap(ibitset& a, ibitset& b) constexpr

Exchanges the contents of an ibitset with those of another one.

Parameters
a First ibitset to exchange the contents with.
b Second ibitset to exchange the contents with.

friend bool operator==(const ibitset& a, const ibitset& b) constexpr

Equal operator.

Parameters
a First ibitset to compare.
b Second ibitset to compare.
Returns true if the first ibitset is equal to the second one, otherwise false.

friend bool operator!=(const ibitset& a, const ibitset& b) constexpr

Not equal operator.

Parameters
a First ibitset to compare.
b Second ibitset to compare.
Returns true if the first ibitset is not equal to the second one, otherwise false.