parsi/internal/bitset.hpp

namespace parsi
namespace internal
template<std::size_t N>
class Bitset
#include <bitset.hpp>

Bitset provides a fast Bitset container similar to std::bitset, but constexpr friendly.

Public Functions

inline constexpr Bitset() noexcept
inline constexpr auto as_byte_span() const noexcept -> std::span<const primary_type, k_array_size>
inline constexpr auto test(const std::size_t index) const noexcept -> bool

test whether the bit at given index is set or not.

inline constexpr void set(const std::size_t index, const bool value) noexcept

set the bit value at given index.

template<std::size_t M>
inline constexpr void set(const Bitset<M> &other) noexcept
template<std::size_t M>
inline constexpr auto joined(const Bitset<M> &other) const noexcept -> Bitset<std::max(N, M)>
inline constexpr void negate() noexcept

bit flips all the set bits to false and all the not set bits to true.

inline constexpr auto negated() const noexcept -> Bitset

bit flips all the set bits to false and all the not set bits to true.

Private Types

using primary_type = std::size_t

Private Members

std::array<primary_type, k_array_size> _bytes = {0}

Private Static Attributes

static constexpr std::size_t k_cell_bitcount = sizeof(primary_type) * 8
static constexpr std::size_t k_array_size = N / k_cell_bitcount + (N % k_cell_bitcount != 0)

Friends

template<std::size_t M> inline friend constexpr friend bool operator== (const Bitset &lhs, const Bitset< M > &rhs) noexcept
template<std::size_t M> inline friend constexpr friend bool operator!= (const Bitset &lhs, const Bitset< M > &rhs) noexcept