#include <bn_bitset.h>
template<int Size>
bn::bitset class

std::bitset like container.

Template parameters
Size Number of stored bits. It must be a multiple of 8.

It doesn't throw exceptions. Instead, asserts are used to ensure valid usage.

Base classes

class ibitset
Base class of bn::bitset.

Constructors, destructors, conversion operators

bitset() constexpr
Default constructor.
bitset(const bitset& other) constexpr
Copy constructor.
bitset(const ibitset& other) constexpr
Copy constructor.

Public functions

auto operator=(const bitset& other) -> bitset& constexpr
Copy assignment operator.
auto operator=(const ibitset& other) -> bitset& constexpr
Copy assignment operator.
auto set() -> bitset& constexpr
Sets all bits to true.
auto set(int index) -> bitset& constexpr
Sets the specified bit to true.
auto set(int index, bool value) -> bitset& constexpr
Sets the specified bit to the specified value.
auto reset() -> bitset& constexpr
Sets all bits to false.
auto reset(int index) -> bitset& constexpr
Sets the specified bit to false.
auto flip() -> bitset& constexpr
Flips all values (changes true values to false and vice versa).
auto flip(int index) -> bitset& constexpr
Flips the specified bit value (changes true value to false and vice versa).
auto operator&=(const ibitset& other) -> bitset& constexpr
Sets the bits to the result of binary AND of this ibitset and the given one.
auto operator|=(const ibitset& other) -> bitset& constexpr
Sets the bits to the result of binary OR of this ibitset and the given one.
auto operator^=(const ibitset& other) -> bitset& constexpr
Sets the bits to the result of binary XOR of this ibitset and the given one.
auto operator~() const -> bitset constexpr
Returns this bitset with all bits flipped (binary NOT).

Friends

auto operator&(const bitset& a, const bitset& b) -> bitset constexpr
Returns a bitset containing the result of binary AND of the given bitsets.
auto operator|(const bitset& a, const bitset& b) -> bitset constexpr
Returns a bitset containing the result of binary OR of the given bitsets.
auto operator^(const bitset& a, const bitset& b) -> bitset constexpr
Returns a bitset containing the result of binary XOR of the given bitsets.

Function documentation

template<int Size>
bn::bitset<Size>::bitset(const bitset& other) constexpr

Copy constructor.

Parameters
other bitset to copy.

template<int Size>
bn::bitset<Size>::bitset(const ibitset& other) constexpr

Copy constructor.

Parameters
other ibitset to copy.

template<int Size>
bitset& bn::bitset<Size>::operator=(const bitset& other) constexpr

Copy assignment operator.

Parameters
other bitset to copy.
Returns Reference to this.

template<int Size>
bitset& bn::bitset<Size>::operator=(const ibitset& other) constexpr

Copy assignment operator.

Parameters
other ibitset to copy.
Returns Reference to this.

template<int Size>
bitset& bn::bitset<Size>::set() constexpr

Sets all bits to true.

Returns Reference to this.

template<int Size>
bitset& bn::bitset<Size>::set(int index) constexpr

Sets the specified bit to true.

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

template<int Size>
bitset& bn::bitset<Size>::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.

template<int Size>
bitset& bn::bitset<Size>::reset() constexpr

Sets all bits to false.

Returns Reference to this.

template<int Size>
bitset& bn::bitset<Size>::reset(int index) constexpr

Sets the specified bit to false.

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

template<int Size>
bitset& bn::bitset<Size>::flip() constexpr

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

Returns Reference to this.

template<int Size>
bitset& bn::bitset<Size>::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.

template<int Size>
bitset& bn::bitset<Size>::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.

template<int Size>
bitset& bn::bitset<Size>::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.

template<int Size>
bitset& bn::bitset<Size>::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.