Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
magic_enum::containers::bitset< E, Index > Class Template Reference

#include <magic_enum_containers.hpp>

Classes

class  reference_impl
 

Public Types

using const_reference = reference_impl< const bitset * >
 
using container_type = std::array< base_type, base_type_count >
 
using index_type = Index
 
using reference = reference_impl<>
 

Public Member Functions

constexpr bool all () const noexcept
 
constexpr bool any () const noexcept
 
constexpr bitset (detail::raw_access_t, const char_type *str, std::size_t n=~std::size_t{0}, char_type zero=static_cast< char_type >('0'), char_type one=static_cast< char_type >('1'))
 
constexpr bitset (detail::raw_access_t, string_view sv, string_view::size_type pos=0, string_view::size_type n=string_view::npos, char_type zero=static_cast< char_type >('0'), char_type one=static_cast< char_type >('1'))
 
constexpr bitset (detail::raw_access_t, unsigned long long val)
 
constexpr bitset (detail::raw_access_t=raw_access) noexcept
 
constexpr bitset (std::initializer_list< E > starters)
 
template<typename Cmp = std::equal_to<>>
constexpr bitset (string_view sv, Cmp &&cmp={}, char_type sep=static_cast< char_type >('|'))
 
template<typename V , std::enable_if_t< std::is_same_v< V, E > &&magic_enum::detail::subtype_v< V >==magic_enum::detail::enum_subtype::flags, int > = 0>
constexpr bitset (V starter)
 
constexpr std::size_t count () const noexcept
 
constexpr bitsetflip () noexcept
 
constexpr std::size_t max_size () const noexcept
 
constexpr bool none () const noexcept
 
template<typename V = E>
constexpr operator std::enable_if_t< magic_enum::detail::subtype_v< V >==magic_enum::detail::enum_subtype::flags, E > () const
 
constexpr bitsetoperator&= (const bitset &other) noexcept
 
constexpr reference operator[] (E pos)
 
constexpr bool operator[] (E pos) const
 
constexpr bitsetoperator^= (const bitset &other) noexcept
 
constexpr bitsetoperator|= (const bitset &other) noexcept
 
constexpr bitset operator~ () const noexcept
 
constexpr bitsetreset () noexcept
 
constexpr bitsetreset (E pos)
 
constexpr bitsetset () noexcept
 
constexpr bitsetset (E pos, bool value=true)
 
constexpr std::size_t size () const noexcept
 
constexpr bool test (E pos) const
 
string to_string (char_type sep=static_cast< char_type >('|')) const
 
string to_string (detail::raw_access_t, char_type zero=static_cast< char_type >('0'), char_type one=static_cast< char_type >('1')) const
 
constexpr unsigned long long to_ullong (detail::raw_access_t raw) const
 
constexpr unsigned long long to_ulong (detail::raw_access_t raw) const
 

Private Types

using base_type = std::conditional_t< enum_count< E >()<=8, std::uint_least8_t, std::conditional_t< enum_count< E >()<=16, std::uint_least16_t, std::conditional_t< enum_count< E >()<=32, std::uint_least32_t, std::uint_least64_t > >>
 

Private Member Functions

template<typename T >
constexpr T to_ (detail::raw_access_t) const
 

Private Attributes

container_type a
 

Static Private Attributes

static constexpr std::size_t base_type_count = (enum_count<E>() > 0 ? (enum_count<E>() - 1) / bits_per_base + 1 : 0)
 
static constexpr std::size_t bits_per_base = sizeof(base_type) * 8
 
static constexpr base_type last_value_max = (base_type{1} << (bits_per_base - not_interested)) - 1
 
static constexpr std::size_t not_interested = base_type_count * bits_per_base - enum_count<E>()
 

Friends

constexpr friend bool operator!= (const bitset &lhs, const bitset &rhs) noexcept
 
constexpr friend bitset operator& (const bitset &lhs, const bitset &rhs) noexcept
 
std::ostream & operator<< (std::ostream &o, const bitset &bs)
 
constexpr friend bool operator== (const bitset &lhs, const bitset &rhs) noexcept
 
std::istream & operator>> (std::istream &i, bitset &bs)
 
constexpr friend bitset operator^ (const bitset &lhs, const bitset &rhs) noexcept
 
constexpr friend bitset operator| (const bitset &lhs, const bitset &rhs) noexcept
 

Detailed Description

template<typename E, typename Index = default_indexing<E>>
class magic_enum::containers::bitset< E, Index >

Definition at line 485 of file magic_enum_containers.hpp.

Member Typedef Documentation

◆ base_type

template<typename E , typename Index = default_indexing<E>>
using magic_enum::containers::bitset< E, Index >::base_type = std::conditional_t<enum_count<E>() <= 8, std::uint_least8_t, std::conditional_t<enum_count<E>() <= 16, std::uint_least16_t, std::conditional_t<enum_count<E>() <= 32, std::uint_least32_t, std::uint_least64_t> >>
private

Definition at line 493 of file magic_enum_containers.hpp.

◆ const_reference

template<typename E , typename Index = default_indexing<E>>
using magic_enum::containers::bitset< E, Index >::const_reference = reference_impl<const bitset*>

Definition at line 559 of file magic_enum_containers.hpp.

◆ container_type

template<typename E , typename Index = default_indexing<E>>
using magic_enum::containers::bitset< E, Index >::container_type = std::array<base_type, base_type_count>

Definition at line 557 of file magic_enum_containers.hpp.

◆ index_type

template<typename E , typename Index = default_indexing<E>>
using magic_enum::containers::bitset< E, Index >::index_type = Index

Definition at line 556 of file magic_enum_containers.hpp.

◆ reference

template<typename E , typename Index = default_indexing<E>>
using magic_enum::containers::bitset< E, Index >::reference = reference_impl<>

Definition at line 558 of file magic_enum_containers.hpp.

Constructor & Destructor Documentation

◆ bitset() [1/7]

template<typename E , typename Index = default_indexing<E>>
constexpr magic_enum::containers::bitset< E, Index >::bitset ( detail::raw_access_t  = raw_access)
inlineexplicitconstexprnoexcept

Definition at line 561 of file magic_enum_containers.hpp.

◆ bitset() [2/7]

template<typename E , typename Index = default_indexing<E>>
constexpr magic_enum::containers::bitset< E, Index >::bitset ( detail::raw_access_t  ,
unsigned long long  val 
)
inlineexplicitconstexpr

Definition at line 563 of file magic_enum_containers.hpp.

◆ bitset() [3/7]

template<typename E , typename Index = default_indexing<E>>
constexpr magic_enum::containers::bitset< E, Index >::bitset ( detail::raw_access_t  ,
string_view  sv,
string_view::size_type  pos = 0,
string_view::size_type  n = string_view::npos,
char_type  zero = static_cast<char_type>('0'),
char_type  one = static_cast<char_type>('1') 
)
inlineexplicitconstexpr

Definition at line 576 of file magic_enum_containers.hpp.

◆ bitset() [4/7]

template<typename E , typename Index = default_indexing<E>>
constexpr magic_enum::containers::bitset< E, Index >::bitset ( detail::raw_access_t  ,
const char_type str,
std::size_t  n = ~std::size_t{0},
char_type  zero = static_cast<char_type>('0'),
char_type  one = static_cast<char_type>('1') 
)
inlineexplicitconstexpr

Definition at line 592 of file magic_enum_containers.hpp.

◆ bitset() [5/7]

template<typename E , typename Index = default_indexing<E>>
constexpr magic_enum::containers::bitset< E, Index >::bitset ( std::initializer_list< E >  starters)
inlineconstexpr

Definition at line 595 of file magic_enum_containers.hpp.

◆ bitset() [6/7]

template<typename E , typename Index = default_indexing<E>>
template<typename V , std::enable_if_t< std::is_same_v< V, E > &&magic_enum::detail::subtype_v< V >==magic_enum::detail::enum_subtype::flags, int > = 0>
constexpr magic_enum::containers::bitset< E, Index >::bitset ( starter)
inlineexplicitconstexpr

Definition at line 607 of file magic_enum_containers.hpp.

◆ bitset() [7/7]

template<typename E , typename Index = default_indexing<E>>
template<typename Cmp = std::equal_to<>>
constexpr magic_enum::containers::bitset< E, Index >::bitset ( string_view  sv,
Cmp &&  cmp = {},
char_type  sep = static_cast<char_type>('|') 
)
inlineexplicitconstexpr

Definition at line 621 of file magic_enum_containers.hpp.

Member Function Documentation

◆ all()

template<typename E , typename Index = default_indexing<E>>
constexpr bool magic_enum::containers::bitset< E, Index >::all ( ) const
inlineconstexprnoexcept

Definition at line 659 of file magic_enum_containers.hpp.

◆ any()

template<typename E , typename Index = default_indexing<E>>
constexpr bool magic_enum::containers::bitset< E, Index >::any ( ) const
inlineconstexprnoexcept

Definition at line 676 of file magic_enum_containers.hpp.

◆ count()

template<typename E , typename Index = default_indexing<E>>
constexpr std::size_t magic_enum::containers::bitset< E, Index >::count ( ) const
inlineconstexprnoexcept

Definition at line 687 of file magic_enum_containers.hpp.

◆ flip()

template<typename E , typename Index = default_indexing<E>>
constexpr bitset& magic_enum::containers::bitset< E, Index >::flip ( )
inlineconstexprnoexcept

Definition at line 761 of file magic_enum_containers.hpp.

◆ max_size()

template<typename E , typename Index = default_indexing<E>>
constexpr std::size_t magic_enum::containers::bitset< E, Index >::max_size ( ) const
inlineconstexprnoexcept

Definition at line 697 of file magic_enum_containers.hpp.

◆ none()

template<typename E , typename Index = default_indexing<E>>
constexpr bool magic_enum::containers::bitset< E, Index >::none ( ) const
inlineconstexprnoexcept

Definition at line 685 of file magic_enum_containers.hpp.

◆ operator std::enable_if_t< magic_enum::detail::subtype_v< V >==magic_enum::detail::enum_subtype::flags, E >()

template<typename E , typename Index = default_indexing<E>>
template<typename V = E>
constexpr magic_enum::containers::bitset< E, Index >::operator std::enable_if_t< magic_enum::detail::subtype_v< V >==magic_enum::detail::enum_subtype::flags, E > ( ) const
inlineexplicitconstexpr

Definition at line 782 of file magic_enum_containers.hpp.

◆ operator&=()

template<typename E , typename Index = default_indexing<E>>
constexpr bitset& magic_enum::containers::bitset< E, Index >::operator&= ( const bitset< E, Index > &  other)
inlineconstexprnoexcept

Definition at line 699 of file magic_enum_containers.hpp.

◆ operator[]() [1/2]

template<typename E , typename Index = default_indexing<E>>
constexpr reference magic_enum::containers::bitset< E, Index >::operator[] ( pos)
inlineconstexpr

Definition at line 647 of file magic_enum_containers.hpp.

◆ operator[]() [2/2]

template<typename E , typename Index = default_indexing<E>>
constexpr bool magic_enum::containers::bitset< E, Index >::operator[] ( pos) const
inlineconstexpr

Definition at line 642 of file magic_enum_containers.hpp.

◆ operator^=()

template<typename E , typename Index = default_indexing<E>>
constexpr bitset& magic_enum::containers::bitset< E, Index >::operator^= ( const bitset< E, Index > &  other)
inlineconstexprnoexcept

Definition at line 713 of file magic_enum_containers.hpp.

◆ operator|=()

template<typename E , typename Index = default_indexing<E>>
constexpr bitset& magic_enum::containers::bitset< E, Index >::operator|= ( const bitset< E, Index > &  other)
inlineconstexprnoexcept

Definition at line 706 of file magic_enum_containers.hpp.

◆ operator~()

template<typename E , typename Index = default_indexing<E>>
constexpr bitset magic_enum::containers::bitset< E, Index >::operator~ ( ) const
inlineconstexprnoexcept

Definition at line 720 of file magic_enum_containers.hpp.

◆ reset() [1/2]

template<typename E , typename Index = default_indexing<E>>
constexpr bitset& magic_enum::containers::bitset< E, Index >::reset ( )
inlineconstexprnoexcept

Definition at line 751 of file magic_enum_containers.hpp.

◆ reset() [2/2]

template<typename E , typename Index = default_indexing<E>>
constexpr bitset& magic_enum::containers::bitset< E, Index >::reset ( pos)
inlineconstexpr

Definition at line 753 of file magic_enum_containers.hpp.

◆ set() [1/2]

template<typename E , typename Index = default_indexing<E>>
constexpr bitset& magic_enum::containers::bitset< E, Index >::set ( )
inlineconstexprnoexcept

Definition at line 732 of file magic_enum_containers.hpp.

◆ set() [2/2]

template<typename E , typename Index = default_indexing<E>>
constexpr bitset& magic_enum::containers::bitset< E, Index >::set ( pos,
bool  value = true 
)
inlineconstexpr

Definition at line 743 of file magic_enum_containers.hpp.

◆ size()

template<typename E , typename Index = default_indexing<E>>
constexpr std::size_t magic_enum::containers::bitset< E, Index >::size ( ) const
inlineconstexprnoexcept

Definition at line 695 of file magic_enum_containers.hpp.

◆ test()

template<typename E , typename Index = default_indexing<E>>
constexpr bool magic_enum::containers::bitset< E, Index >::test ( pos) const
inlineconstexpr

Definition at line 652 of file magic_enum_containers.hpp.

◆ to_()

template<typename E , typename Index = default_indexing<E>>
template<typename T >
constexpr T magic_enum::containers::bitset< E, Index >::to_ ( detail::raw_access_t  ) const
inlineconstexprprivate

Definition at line 541 of file magic_enum_containers.hpp.

◆ to_string() [1/2]

template<typename E , typename Index = default_indexing<E>>
string magic_enum::containers::bitset< E, Index >::to_string ( char_type  sep = static_cast<char_type>('|')) const
inline

Definition at line 792 of file magic_enum_containers.hpp.

◆ to_string() [2/2]

template<typename E , typename Index = default_indexing<E>>
string magic_enum::containers::bitset< E, Index >::to_string ( detail::raw_access_t  ,
char_type  zero = static_cast<char_type>('0'),
char_type  one = static_cast<char_type>('1') 
) const
inline

Definition at line 807 of file magic_enum_containers.hpp.

◆ to_ullong()

template<typename E , typename Index = default_indexing<E>>
constexpr unsigned long long magic_enum::containers::bitset< E, Index >::to_ullong ( detail::raw_access_t  raw) const
inlineconstexpr

Definition at line 816 of file magic_enum_containers.hpp.

◆ to_ulong()

template<typename E , typename Index = default_indexing<E>>
constexpr unsigned long long magic_enum::containers::bitset< E, Index >::to_ulong ( detail::raw_access_t  raw) const
inlineconstexpr

Definition at line 818 of file magic_enum_containers.hpp.

Friends And Related Function Documentation

◆ operator!=

template<typename E , typename Index = default_indexing<E>>
constexpr friend bool operator!= ( const bitset< E, Index > &  lhs,
const bitset< E, Index > &  rhs 
)
friend

Definition at line 640 of file magic_enum_containers.hpp.

◆ operator&

template<typename E , typename Index = default_indexing<E>>
constexpr friend bitset operator& ( const bitset< E, Index > &  lhs,
const bitset< E, Index > &  rhs 
)
friend

Definition at line 763 of file magic_enum_containers.hpp.

◆ operator<<

template<typename E , typename Index = default_indexing<E>>
std::ostream& operator<< ( std::ostream &  o,
const bitset< E, Index > &  bs 
)
friend

Definition at line 820 of file magic_enum_containers.hpp.

◆ operator==

template<typename E , typename Index = default_indexing<E>>
constexpr friend bool operator== ( const bitset< E, Index > &  lhs,
const bitset< E, Index > &  rhs 
)
friend

Definition at line 638 of file magic_enum_containers.hpp.

◆ operator>>

template<typename E , typename Index = default_indexing<E>>
std::istream& operator>> ( std::istream &  i,
bitset< E, Index > &  bs 
)
friend

Definition at line 822 of file magic_enum_containers.hpp.

◆ operator^

template<typename E , typename Index = default_indexing<E>>
constexpr friend bitset operator^ ( const bitset< E, Index > &  lhs,
const bitset< E, Index > &  rhs 
)
friend

Definition at line 775 of file magic_enum_containers.hpp.

◆ operator|

template<typename E , typename Index = default_indexing<E>>
constexpr friend bitset operator| ( const bitset< E, Index > &  lhs,
const bitset< E, Index > &  rhs 
)
friend

Definition at line 769 of file magic_enum_containers.hpp.

Member Data Documentation

◆ a

template<typename E , typename Index = default_indexing<E>>
container_type magic_enum::containers::bitset< E, Index >::a
private

Definition at line 831 of file magic_enum_containers.hpp.

◆ base_type_count

template<typename E , typename Index = default_indexing<E>>
constexpr std::size_t magic_enum::containers::bitset< E, Index >::base_type_count = (enum_count<E>() > 0 ? (enum_count<E>() - 1) / bits_per_base + 1 : 0)
staticconstexprprivate

Definition at line 496 of file magic_enum_containers.hpp.

◆ bits_per_base

template<typename E , typename Index = default_indexing<E>>
constexpr std::size_t magic_enum::containers::bitset< E, Index >::bits_per_base = sizeof(base_type) * 8
staticconstexprprivate

Definition at line 495 of file magic_enum_containers.hpp.

◆ last_value_max

template<typename E , typename Index = default_indexing<E>>
constexpr base_type magic_enum::containers::bitset< E, Index >::last_value_max = (base_type{1} << (bits_per_base - not_interested)) - 1
staticconstexprprivate

Definition at line 498 of file magic_enum_containers.hpp.

◆ not_interested

template<typename E , typename Index = default_indexing<E>>
constexpr std::size_t magic_enum::containers::bitset< E, Index >::not_interested = base_type_count * bits_per_base - enum_count<E>()
staticconstexprprivate

Definition at line 497 of file magic_enum_containers.hpp.


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


magic_enum
Author(s):
autogenerated on Fri Feb 21 2025 03:20:19