CppCommon  1.0.4.1
C++ Common Library
Public Member Functions | Friends | List of all members
CppCommon::Flags< TEnum > Class Template Reference

Enum-based flags. More...

#include <flags.h>

Public Member Functions

 Flags () noexcept
 
 Flags (type value) noexcept
 
 Flags (TEnum value) noexcept
 
 Flags (const Flags &) noexcept=default
 
 Flags (Flags &&) noexcept=default
 
 ~Flags () noexcept=default
 
Flagsoperator= (type value) noexcept
 
Flagsoperator= (TEnum value) noexcept
 
Flagsoperator= (const Flags &) noexcept=default
 
Flagsoperator= (Flags &&) noexcept=default
 
 operator bool () const noexcept
 Is any flag set? More...
 
bool operator! () const noexcept
 Is no flag set? More...
 
Flags operator~ () const noexcept
 Reverse all flags. More...
 
Flagsoperator&= (const Flags &flags) noexcept
 Flags logical assign operators. More...
 
Flagsoperator|= (const Flags &flags) noexcept
 
Flagsoperator^= (const Flags &flags) noexcept
 
 operator TEnum () const noexcept
 Convert to the enum value. More...
 
bool isset () const noexcept
 Is any flag set? More...
 
bool isset (type value) const noexcept
 Is the given flag set? More...
 
bool isset (TEnum value) const noexcept
 Is the given flag set? More...
 
TEnum value () const noexcept
 Get the enum value. More...
 
type underlying () const noexcept
 Get the underlying enum value. More...
 
std::bitset< sizeof(type) *8 > bitset () const noexcept
 Get the bitset value. More...
 
void swap (Flags &flags) noexcept
 Swap two instances. More...
 

Friends

Flags operator& (const Flags &flags1, const Flags &flags2) noexcept
 Flags logical friend operators. More...
 
Flags operator| (const Flags &flags1, const Flags &flags2) noexcept
 
Flags operator^ (const Flags &flags1, const Flags &flags2) noexcept
 
bool operator== (const Flags &flags1, const Flags &flags2) noexcept
 
bool operator!= (const Flags &flags1, const Flags &flags2) noexcept
 
template<typename UEnum >
void swap (Flags< UEnum > &flags1, Flags< UEnum > &flags2) noexcept
 

Detailed Description

template<typename TEnum>
class CppCommon::Flags< TEnum >

Enum-based flags.

Helper class for enum based flags which wraps particular enum as a template parameter and provides flags manipulation operators and methods.

Not thread-safe.

Definition at line 64 of file flags.h.

Constructor & Destructor Documentation

◆ Flags() [1/5]

template<typename TEnum >
CppCommon::Flags< TEnum >::Flags ( )
inlinenoexcept

Definition at line 70 of file flags.h.

◆ Flags() [2/5]

template<typename TEnum >
CppCommon::Flags< TEnum >::Flags ( type  value)
inlinenoexcept

Definition at line 71 of file flags.h.

◆ Flags() [3/5]

template<typename TEnum >
CppCommon::Flags< TEnum >::Flags ( TEnum  value)
inlinenoexcept

Definition at line 72 of file flags.h.

◆ Flags() [4/5]

template<typename TEnum >
CppCommon::Flags< TEnum >::Flags ( const Flags< TEnum > &  )
defaultnoexcept

◆ Flags() [5/5]

template<typename TEnum >
CppCommon::Flags< TEnum >::Flags ( Flags< TEnum > &&  )
defaultnoexcept

◆ ~Flags()

template<typename TEnum >
CppCommon::Flags< TEnum >::~Flags ( )
defaultnoexcept

Member Function Documentation

◆ bitset()

template<typename TEnum >
std::bitset<sizeof(type) * 8> CppCommon::Flags< TEnum >::bitset ( ) const
inlinenoexcept

Get the bitset value.

Definition at line 130 of file flags.h.

◆ isset() [1/3]

template<typename TEnum >
bool CppCommon::Flags< TEnum >::isset ( ) const
inlinenoexcept

Is any flag set?

Definition at line 119 of file flags.h.

◆ isset() [2/3]

template<typename TEnum >
bool CppCommon::Flags< TEnum >::isset ( TEnum  value) const
inlinenoexcept

Is the given flag set?

Definition at line 123 of file flags.h.

◆ isset() [3/3]

template<typename TEnum >
bool CppCommon::Flags< TEnum >::isset ( type  value) const
inlinenoexcept

Is the given flag set?

Definition at line 121 of file flags.h.

◆ operator bool()

template<typename TEnum >
CppCommon::Flags< TEnum >::operator bool ( ) const
inlineexplicitnoexcept

Is any flag set?

Definition at line 85 of file flags.h.

◆ operator TEnum()

template<typename TEnum >
CppCommon::Flags< TEnum >::operator TEnum ( ) const
inlinenoexcept

Convert to the enum value.

Definition at line 116 of file flags.h.

◆ operator!()

template<typename TEnum >
bool CppCommon::Flags< TEnum >::operator! ( ) const
inlinenoexcept

Is no flag set?

Definition at line 88 of file flags.h.

◆ operator&=()

template<typename TEnum >
Flags& CppCommon::Flags< TEnum >::operator&= ( const Flags< TEnum > &  flags)
inlinenoexcept

Flags logical assign operators.

Definition at line 94 of file flags.h.

◆ operator=() [1/4]

template<typename TEnum >
Flags& CppCommon::Flags< TEnum >::operator= ( const Flags< TEnum > &  )
defaultnoexcept

◆ operator=() [2/4]

template<typename TEnum >
Flags& CppCommon::Flags< TEnum >::operator= ( Flags< TEnum > &&  )
defaultnoexcept

◆ operator=() [3/4]

template<typename TEnum >
Flags& CppCommon::Flags< TEnum >::operator= ( TEnum  value)
inlinenoexcept

Definition at line 79 of file flags.h.

◆ operator=() [4/4]

template<typename TEnum >
Flags& CppCommon::Flags< TEnum >::operator= ( type  value)
inlinenoexcept

Definition at line 77 of file flags.h.

◆ operator^=()

template<typename TEnum >
Flags& CppCommon::Flags< TEnum >::operator^= ( const Flags< TEnum > &  flags)
inlinenoexcept

Definition at line 98 of file flags.h.

◆ operator|=()

template<typename TEnum >
Flags& CppCommon::Flags< TEnum >::operator|= ( const Flags< TEnum > &  flags)
inlinenoexcept

Definition at line 96 of file flags.h.

◆ operator~()

template<typename TEnum >
Flags CppCommon::Flags< TEnum >::operator~ ( ) const
inlinenoexcept

Reverse all flags.

Definition at line 91 of file flags.h.

◆ swap()

template<typename TEnum >
void CppCommon::Flags< TEnum >::swap ( Flags< TEnum > &  flags)
inlinenoexcept

Swap two instances.

Definition at line 133 of file flags.h.

◆ underlying()

template<typename TEnum >
type CppCommon::Flags< TEnum >::underlying ( ) const
inlinenoexcept

Get the underlying enum value.

Definition at line 128 of file flags.h.

◆ value()

template<typename TEnum >
TEnum CppCommon::Flags< TEnum >::value ( ) const
inlinenoexcept

Get the enum value.

Definition at line 126 of file flags.h.

Friends And Related Function Documentation

◆ operator!=

template<typename TEnum >
bool operator!= ( const Flags< TEnum > &  flags1,
const Flags< TEnum > &  flags2 
)
friend

Definition at line 112 of file flags.h.

◆ operator&

template<typename TEnum >
Flags operator& ( const Flags< TEnum > &  flags1,
const Flags< TEnum > &  flags2 
)
friend

Flags logical friend operators.

Definition at line 102 of file flags.h.

◆ operator==

template<typename TEnum >
bool operator== ( const Flags< TEnum > &  flags1,
const Flags< TEnum > &  flags2 
)
friend

Definition at line 110 of file flags.h.

◆ operator^

template<typename TEnum >
Flags operator^ ( const Flags< TEnum > &  flags1,
const Flags< TEnum > &  flags2 
)
friend

Definition at line 106 of file flags.h.

◆ operator|

template<typename TEnum >
Flags operator| ( const Flags< TEnum > &  flags1,
const Flags< TEnum > &  flags2 
)
friend

Definition at line 104 of file flags.h.

◆ swap

template<typename TEnum >
template<typename UEnum >
void swap ( Flags< UEnum > &  flags1,
Flags< UEnum > &  flags2 
)
friend

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