#include "tensorstore/util/small_bit_set.h"
template <typename T>
class tensorstore::BitRef;

Mutable or constant reference to a single bit of a packed bit sequence.

BitRef is bound to a bit location by the constructor, and cannot be rebound.

Template Parameters:
typename T

The unsigned integer “block” type used to store the packed bits. A mutable reference is indicated by an unqualified type, e.g. BitRef<uint32_t>, while a const reference is indicated by a const-qualified type, e.g. BitRef<const uint32_t>.

Requires:

std::is_unsigned_v<T>.

Types

using block_type = T;

Block type used to represent the bits.

using value_type = bool;
using element_type = bool;

Element type of the reference.

Data members

constexpr const ptrdiff_t kBitsPerBlock = sizeof(T) * 8;

Number of bits stored per T value.

Constructors

constexpr BitRef(Tblockptrdiff_t offset);

Binds to bit offset % kBitsPerBlock of *block.

Conversion operators

constexpr operator bool() const;

Returns the value of the bound bit.

Methods

const BitRefoperator=(bool value) const;

Sets the bound bit to value, leaving all other bits unchanged.

const BitRefoperator=(BitRef value) const;

Equivalent to *this = static_cast<bool>(value).

Friend functions

friend void swap(BitRef aboolx);
friend void swap(boolxBitRef a);

Swaps the referenced bit with a bool value.

void tensorstore::swap(BitRef<T> aBitRef<U> b);

Swaps the contents of the bit to which a refers with the contents of the bit to which b refers (does not rebind a or b).