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 = INTEGER_TYPE
 
using element_type = bit_reference< integer_type >
 
using iterator = base_iterator< INTEGER_TYPE >
 
using const_iterator = base_iterator< INTEGER_TYPE const >
 

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_viewoperator= (bit_view const &) noexcept=default
 
bit_viewoperator= (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 constinteger_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 = base_iterator<INTEGER_TYPE const>

Definition at line 127 of file bit_view.h.

◆ element_type

template<bit_integral INTEGER_TYPE>
using ghassanpl::bit_view< INTEGER_TYPE >::element_type = bit_reference<integer_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 = INTEGER_TYPE

Definition at line 24 of file bit_view.h.

◆ iterator

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

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>
constexpr element_type ghassanpl::bit_view< INTEGER_TYPE >::at ( size_t  index)
inlineconstexpr

Definition at line 138 of file bit_view.h.

◆ at() [2/2]

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

Definition at line 143 of file bit_view.h.

◆ begin() [1/2]

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

Definition at line 133 of file bit_view.h.

◆ begin() [2/2]

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

Definition at line 131 of file bit_view.h.

◆ end() [1/2]

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

Definition at line 134 of file bit_view.h.

◆ end() [2/2]

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

Definition at line 132 of file bit_view.h.

◆ integer_at_bit() [1/2]

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

Definition at line 178 of file bit_view.h.

◆ integer_at_bit() [2/2]

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

Definition at line 179 of file bit_view.h.

◆ integers()

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

Definition at line 183 of file bit_view.h.

◆ operator[]() [1/2]

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

Definition at line 148 of file bit_view.h.

◆ operator[]() [2/2]

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

Definition at line 153 of file bit_view.h.

◆ real_bit_at_bit()

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

Definition at line 181 of file bit_view.h.

◆ size()

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

Definition at line 176 of file bit_view.h.

Member Data Documentation

◆ integer_type_bit_count

template<bit_integral INTEGER_TYPE>
constexpr 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>
constexpr bool ghassanpl::bit_view< INTEGER_TYPE >::is_const
staticconstexpr

Definition at line 28 of file bit_view.h.