dynamic_bitset 1.3.3
Simple Useful Libraries: C++17/20 header-only dynamic bitset
Loading...
Searching...
No Matches
sul::dynamic_bitset< Block, Allocator >::reference Class Reference

Reference to a sul::dynamic_bitset bit. More...

#include <sul/dynamic_bitset.hpp>

Public Member Functions

constexpr reference (dynamic_bitset< Block, Allocator > &bitset, size_type bit_pos)
 Constructs a reference to a bit from a sul::dynamic_bitset and a bit position.
constexpr reference (const reference &) noexcept=default
 Copy constructor.
constexpr reference (reference &&) noexcept=default
 Move constructor.
 ~reference () noexcept=default
 Destructor.
constexpr reference & operator= (bool v)
 Assign a value to the referenced bit.
constexpr reference & operator= (const reference &rhs)
 Assign a value to the referenced bit from another reference.
constexpr reference & operator= (reference &&rhs) noexcept
 Assign a value to the referenced bit from another reference.
constexpr reference & operator&= (bool v)
 Apply binary operator AND to the referenced bit and a value, and assign the result to the referenced bit.
constexpr reference & operator|= (bool v)
 Apply binary operator OR to the referenced bit and a value, and assign the result to the referenced bit.
constexpr reference & operator^= (bool v)
 Apply binary operator XOR to the referenced bit and a value, and assign the result to the referenced bit.
constexpr reference & operator-= (bool v)
 Apply binary difference to the referenced bit and a value, and assign the result to the referenced bit.
constexpr bool operator~ () const
 Return the result of applying unary NOT operator.
constexpr operator bool () const
 bool conversion operator.
constexpr void operator& ()=delete
 Deleted to avoid taking the address of a temporary proxy object.
constexpr reference & set ()
 Set the referenced bit to true.
constexpr reference & reset ()
 Reset the referenced bit to false.
constexpr reference & flip ()
 Flip the referenced bit.
constexpr reference & assign (bool v)
 Assign the value v to the referenced bit.

Detailed Description

template<typename Block = unsigned long long, typename Allocator = std::allocator<Block>>
class sul::dynamic_bitset< Block, Allocator >::reference

Reference to a sul::dynamic_bitset bit.

As the bits in the sul::dynamic_bitset class are stored in an optimized way in blocks, it is not possible for the subscript operators to return a reference to a boolean. Hence this class is used as a proxy to enable subscript operator of the sul::dynamic_bitset class to be used as if it was an array of bools.

Since
1.0.0

Constructor & Destructor Documentation

◆ reference() [1/3]

template<typename Block, typename Allocator>
sul::dynamic_bitset< Block, Allocator >::reference::reference ( dynamic_bitset< Block, Allocator > & bitset,
size_type bit_pos )
constexpr

Constructs a reference to a bit from a sul::dynamic_bitset and a bit position.

Parameters
bitsetsul::dynamic_bitset containing the bit
[in]bit_posPosition of the bit to reference in the sul::dynamic_bitset
Complexity
Constant.
Since
1.0.0

◆ reference() [2/3]

template<typename Block = unsigned long long, typename Allocator = std::allocator<Block>>
sul::dynamic_bitset< Block, Allocator >::reference::reference ( const reference & )
constexprdefaultnoexcept

Copy constructor.

Since
1.0.0

◆ reference() [3/3]

template<typename Block = unsigned long long, typename Allocator = std::allocator<Block>>
sul::dynamic_bitset< Block, Allocator >::reference::reference ( reference && )
constexprdefaultnoexcept

Move constructor.

Since
1.0.0

◆ ~reference()

template<typename Block = unsigned long long, typename Allocator = std::allocator<Block>>
sul::dynamic_bitset< Block, Allocator >::reference::~reference ( )
defaultnoexcept

Destructor.

Since
1.0.0

Member Function Documentation

◆ assign()

template<typename Block, typename Allocator>
dynamic_bitset< Block, Allocator >::reference & sul::dynamic_bitset< Block, Allocator >::reference::assign ( bool v)
constexpr

Assign the value v to the referenced bit.

Parameters
[in]vValue to assign to the bit
Returns
The reference
Complexity
Constant.
Since
1.0.0

◆ flip()

template<typename Block, typename Allocator>
dynamic_bitset< Block, Allocator >::reference & sul::dynamic_bitset< Block, Allocator >::reference::flip ( )
constexpr

Flip the referenced bit.

Returns
The reference
Complexity
Constant.
Since
1.0.0

◆ operator bool()

template<typename Block, typename Allocator>
sul::dynamic_bitset< Block, Allocator >::reference::operator bool ( ) const
nodiscardconstexpr

bool conversion operator.

Complexity
Constant.
Since
1.0.0

◆ operator&()

template<typename Block = unsigned long long, typename Allocator = std::allocator<Block>>
void sul::dynamic_bitset< Block, Allocator >::reference::operator& ( )
constexprdelete

Deleted to avoid taking the address of a temporary proxy object.

Since
1.0.0

◆ operator&=()

template<typename Block, typename Allocator>
dynamic_bitset< Block, Allocator >::reference & sul::dynamic_bitset< Block, Allocator >::reference::operator&= ( bool v)
constexpr

Apply binary operator AND to the referenced bit and a value, and assign the result to the referenced bit.

Parameters
[in]vValue to apply binary operator AND with
Returns
The reference
Complexity
Constant.
Since
1.0.0

◆ operator-=()

template<typename Block, typename Allocator>
dynamic_bitset< Block, Allocator >::reference & sul::dynamic_bitset< Block, Allocator >::reference::operator-= ( bool v)
constexpr

Apply binary difference to the referenced bit and a value, and assign the result to the referenced bit.

Equivalent to:

this &= !v;
Parameters
[in]vValue to apply binary difference with
Returns
The reference
Complexity
Constant.
Since
1.0.0

◆ operator=() [1/3]

template<typename Block, typename Allocator>
dynamic_bitset< Block, Allocator >::reference & sul::dynamic_bitset< Block, Allocator >::reference::operator= ( bool v)
constexpr

Assign a value to the referenced bit.

Parameters
[in]vValue to assign to the referenced bit
Returns
The reference
Complexity
Constant.
Since
1.0.0

◆ operator=() [2/3]

template<typename Block = unsigned long long, typename Allocator = std::allocator<Block>>
reference & sul::dynamic_bitset< Block, Allocator >::reference::operator= ( const reference & rhs)
constexpr

Assign a value to the referenced bit from another reference.

Parameters
[in]rhsreference to the bit to assign value from
Returns
The reference
Complexity
Constant.
Since
1.0.0

◆ operator=() [3/3]

template<typename Block, typename Allocator>
dynamic_bitset< Block, Allocator >::reference & sul::dynamic_bitset< Block, Allocator >::reference::operator= ( dynamic_bitset::reference && rhs)
constexprnoexcept

Assign a value to the referenced bit from another reference.

Parameters
[in]rhsreference to the bit to assign value from
Returns
The reference
Complexity
Constant.
Since
1.0.0

◆ operator^=()

template<typename Block, typename Allocator>
dynamic_bitset< Block, Allocator >::reference & sul::dynamic_bitset< Block, Allocator >::reference::operator^= ( bool v)
constexpr

Apply binary operator XOR to the referenced bit and a value, and assign the result to the referenced bit.

Parameters
[in]vValue to apply binary operator XOR with
Returns
The reference
Complexity
Constant.
Since
1.0.0

◆ operator|=()

template<typename Block, typename Allocator>
dynamic_bitset< Block, Allocator >::reference & sul::dynamic_bitset< Block, Allocator >::reference::operator|= ( bool v)
constexpr

Apply binary operator OR to the referenced bit and a value, and assign the result to the referenced bit.

Parameters
[in]vValue to apply binary operator OR with
Returns
The reference
Complexity
Constant.
Since
1.0.0

◆ operator~()

template<typename Block, typename Allocator>
bool sul::dynamic_bitset< Block, Allocator >::reference::operator~ ( ) const
nodiscardconstexpr

Return the result of applying unary NOT operator.

Returns
The opposite of the referenced bit
Complexity
Constant.
Since
1.0.0

◆ reset()

template<typename Block, typename Allocator>
dynamic_bitset< Block, Allocator >::reference & sul::dynamic_bitset< Block, Allocator >::reference::reset ( )
constexpr

Reset the referenced bit to false.

Returns
The reference
Complexity
Constant.
Since
1.0.0

◆ set()

template<typename Block, typename Allocator>
dynamic_bitset< Block, Allocator >::reference & sul::dynamic_bitset< Block, Allocator >::reference::set ( )
constexpr

Set the referenced bit to true.

Returns
The reference
Complexity
Constant.
Since
1.0.0

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