#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()
Default constructor.
bitset(const bitset& other)
Copy constructor.
bitset(const ibitset& other)
Copy constructor.

Public functions

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

Friends

auto operator&(const bitset& a, const bitset& b) -> bitset
Returns a bitset containing the result of binary AND of the given bitsets.
auto operator|(const bitset& a, const bitset& b) -> bitset
Returns a bitset containing the result of binary OR of the given bitsets.
auto operator^(const bitset& a, const bitset& b) -> bitset
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)

Copy constructor.

Parameters
other bitset to copy.

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

Copy constructor.

Parameters
other ibitset to copy.

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

Copy assignment operator.

Parameters
other bitset to copy.
Returns Reference to this.

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

Copy assignment operator.

Parameters
other ibitset to copy.
Returns Reference to this.

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

Sets all bits to true.

Returns Reference to this.

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

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)

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()

Sets all bits to false.

Returns Reference to this.

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

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()

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)

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)

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)

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)

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

Parameters
other Another ibitset.
Returns Reference to this.