header_utils
Loading...
Searching...
No Matches
ghassanpl::bit_view< INTEGER_TYPE > Struct Template Reference

A view over an integral value allowing for iteration and modification of its individual bits. More...

#include <bit_view.h>

Public Types

using integer_type
 TODO: Should this have extent, like span<> ?
using element_type
using iterator
using const_iterator

Public Member Functions

 bit_view (std::span< integer_type > span) noexcept
 bit_view (bit_view const &) noexcept=default
 bit_view (bit_view &&) noexcept=default
bit_view & operator= (bit_view const &) noexcept=default
bit_view & operator= (bit_view &&) noexcept=default
constexpr const_iterator begin () const
constexpr const_iterator end () const
constexpr iterator begin ()
constexpr iterator end ()
constexpr const_iterator cbegin ()
constexpr const_iterator cend ()
constexpr element_type at (size_t index)
constexpr element_type at (size_t index) const
constexpr element_type operator[] (size_t index)
constexpr element_type operator[] (size_t index) const
constexpr void set (size_t index)
constexpr void clear (size_t index)
constexpr bool is_set (size_t index) const
constexpr void set_all ()
constexpr void clear_all ()
constexpr void toggle_all ()
constexpr bool are_all_set () const
template<typename U>
constexpr bool are_all_set (bit_view< U > const &bit_set) const
constexpr bool are_any_set () const
template<typename U>
constexpr bool are_any_set (bit_view< U > const &bit_set) const
constexpr size_t size () const noexcept
constexpr integer_type & integer_at_bit (size_t bit)
constexpr integer_type const & integer_at_bit (size_t bit) const
constexpr auto integers () const noexcept
template<typename U>
requires (!std::is_const_v<U>)
constexpr void copy_to (bit_view< U > &target) const
 [[nodiscard]] constexpr bit_view<integer_type> subview(size_t starting_at_bit, size_t bit_count) const;
template<typename U>
requires (!std::is_const_v<U>)
constexpr void and_with (bit_view< U > &target) const
template<typename U>
requires (!std::is_const_v<U>)
constexpr void or_with (bit_view< U > &target) const
template<typename U>
requires (!std::is_const_v<U>)
constexpr void xor_with (bit_view< U > &target) const
constexpr size_t find_first_bit (bool that_is) const noexcept
constexpr size_t find_last_bit (bool that_is) const noexcept
constexpr size_t count_bits (bool that_are) const noexcept

Static Public Member Functions

static constexpr size_t real_bit_at_bit (size_t bit)

Static Public Attributes

static constexpr size_t integer_type_bit_count
static constexpr bool is_const

Detailed Description

template<bit_integral INTEGER_TYPE>
struct ghassanpl::bit_view< INTEGER_TYPE >

A view over an integral value allowing for iteration and modification of its individual bits.

Definition at line 19 of file bit_view.h.

Member Typedef Documentation

◆ const_iterator

template<bit_integral INTEGER_TYPE>
using ghassanpl::bit_view< INTEGER_TYPE >::const_iterator

Definition at line 127 of file bit_view.h.

◆ element_type

template<bit_integral INTEGER_TYPE>
using ghassanpl::bit_view< INTEGER_TYPE >::element_type

Definition at line 25 of file bit_view.h.

◆ integer_type

template<bit_integral INTEGER_TYPE>
using ghassanpl::bit_view< INTEGER_TYPE >::integer_type

TODO: Should this have extent, like span<> ?

TODO: Should this store a bitcount and bitstart, so we can have views over non-integral bit counts?

Definition at line 24 of file bit_view.h.

◆ iterator

template<bit_integral INTEGER_TYPE>
using ghassanpl::bit_view< INTEGER_TYPE >::iterator

Definition at line 126 of file bit_view.h.

Constructor & Destructor Documentation

◆ bit_view()

template<bit_integral INTEGER_TYPE>
ghassanpl::bit_view< INTEGER_TYPE >::bit_view ( std::span< integer_type > span)
inlinenoexcept

Definition at line 31 of file bit_view.h.

Member Function Documentation

◆ at() [1/2]

template<bit_integral INTEGER_TYPE>
element_type ghassanpl::bit_view< INTEGER_TYPE >::at ( size_t index)
inlinenodiscardconstexpr

Definition at line 138 of file bit_view.h.

◆ at() [2/2]

template<bit_integral INTEGER_TYPE>
element_type ghassanpl::bit_view< INTEGER_TYPE >::at ( size_t index) const
inlinenodiscardconstexpr

Definition at line 143 of file bit_view.h.

◆ begin() [1/2]

template<bit_integral INTEGER_TYPE>
iterator ghassanpl::bit_view< INTEGER_TYPE >::begin ( )
inlinenodiscardconstexpr

Definition at line 133 of file bit_view.h.

◆ begin() [2/2]

template<bit_integral INTEGER_TYPE>
const_iterator ghassanpl::bit_view< INTEGER_TYPE >::begin ( ) const
inlinenodiscardconstexpr

Definition at line 131 of file bit_view.h.

◆ end() [1/2]

template<bit_integral INTEGER_TYPE>
iterator ghassanpl::bit_view< INTEGER_TYPE >::end ( )
inlinenodiscardconstexpr

Definition at line 134 of file bit_view.h.

◆ end() [2/2]

template<bit_integral INTEGER_TYPE>
const_iterator ghassanpl::bit_view< INTEGER_TYPE >::end ( ) const
inlinenodiscardconstexpr

Definition at line 132 of file bit_view.h.

◆ integer_at_bit() [1/2]

template<bit_integral INTEGER_TYPE>
integer_type & ghassanpl::bit_view< INTEGER_TYPE >::integer_at_bit ( size_t bit)
inlinenodiscardconstexpr

Definition at line 178 of file bit_view.h.

◆ integer_at_bit() [2/2]

template<bit_integral INTEGER_TYPE>
integer_type const & ghassanpl::bit_view< INTEGER_TYPE >::integer_at_bit ( size_t bit) const
inlinenodiscardconstexpr

Definition at line 179 of file bit_view.h.

◆ integers()

template<bit_integral INTEGER_TYPE>
auto ghassanpl::bit_view< INTEGER_TYPE >::integers ( ) const
inlinenodiscardconstexprnoexcept

Definition at line 183 of file bit_view.h.

◆ operator[]() [1/2]

template<bit_integral INTEGER_TYPE>
element_type ghassanpl::bit_view< INTEGER_TYPE >::operator[] ( size_t index)
inlinenodiscardconstexpr

Definition at line 148 of file bit_view.h.

◆ operator[]() [2/2]

template<bit_integral INTEGER_TYPE>
element_type ghassanpl::bit_view< INTEGER_TYPE >::operator[] ( size_t index) const
inlinenodiscardconstexpr

Definition at line 153 of file bit_view.h.

◆ real_bit_at_bit()

template<bit_integral INTEGER_TYPE>
constexpr size_t ghassanpl::bit_view< INTEGER_TYPE >::real_bit_at_bit ( size_t bit)
inlinestaticnodiscardconstexpr

Definition at line 181 of file bit_view.h.

◆ size()

template<bit_integral INTEGER_TYPE>
size_t ghassanpl::bit_view< INTEGER_TYPE >::size ( ) const
inlinenodiscardconstexprnoexcept

Definition at line 176 of file bit_view.h.

Member Data Documentation

◆ integer_type_bit_count

template<bit_integral INTEGER_TYPE>
size_t ghassanpl::bit_view< INTEGER_TYPE >::integer_type_bit_count
staticconstexpr

Definition at line 26 of file bit_view.h.

◆ is_const

template<bit_integral INTEGER_TYPE>
bool ghassanpl::bit_view< INTEGER_TYPE >::is_const
staticconstexpr

Definition at line 28 of file bit_view.h.