uvw  1.3.0
Public Member Functions | Static Public Member Functions | List of all members
uvw::Flags< E > Class Template Referencefinal

Utility class to handle flags. More...

#include <util.hpp>

Public Member Functions

constexpr Flags (E flag) noexcept
 Constructs a Flags object from a value of the enum E. More...
 
constexpr Flags (Type f)
 Constructs a Flags object from an instance of the underlying type of the enum E. More...
 
constexpr Flags ()
 Constructs an uninitialized Flags object.
 
constexpr Flags operator| (const Flags &f) const noexcept
 Or operator. More...
 
constexpr Flags operator| (E flag) const noexcept
 Or operator. More...
 
constexpr Flags operator & (const Flags &f) const noexcept
 And operator. More...
 
constexpr Flags operator & (E flag) const noexcept
 And operator. More...
 
constexpr operator bool () const noexcept
 Checks if this instance is initialized. More...
 
constexpr operator Type () const noexcept
 Casts the instance to the underlying type of E. More...
 

Static Public Member Functions

template<E... V>
static CONSTEXPR_SPECIFIER Flags< E > from ()
 Utility factory method to pack a set of values all at once. More...
 

Detailed Description

template<typename E>
class uvw::Flags< E >

Utility class to handle flags.

This class can be used to handle flags of a same enumeration type.
It is meant to be used as an argument for functions and member methods and as part of events.
Flags<E> objects can be easily or-ed and and-ed with other instances of the same type or with instances of the type E (that is, the actual flag type), thus converted to the underlying type when needed.

Definition at line 77 of file util.hpp.

Constructor & Destructor Documentation

◆ Flags() [1/2]

template<typename E>
constexpr uvw::Flags< E >::Flags ( flag)
inlinenoexcept

Constructs a Flags object from a value of the enum E.

Parameters
flagA value of the enum E.

Definition at line 100 of file util.hpp.

◆ Flags() [2/2]

template<typename E>
constexpr uvw::Flags< E >::Flags ( Type  f)
inline

Constructs a Flags object from an instance of the underlying type of the enum E.

Parameters
fAn instance of the underlying type of the enum E.

Definition at line 107 of file util.hpp.

Member Function Documentation

◆ from()

template<typename E>
template<E... V>
static CONSTEXPR_SPECIFIER Flags<E> uvw::Flags< E >::from ( )
inlinestatic

Utility factory method to pack a set of values all at once.

Returns
A valid instance of Flags instantiated from values V.

Definition at line 90 of file util.hpp.

◆ operator &() [1/2]

template<typename E>
constexpr Flags uvw::Flags< E >::operator& ( const Flags< E > &  f) const
inlinenoexcept

And operator.

Parameters
fA valid instance of Flags.
Returns
This instance and-ed with f.

Definition at line 148 of file util.hpp.

◆ operator &() [2/2]

template<typename E>
constexpr Flags uvw::Flags< E >::operator& ( flag) const
inlinenoexcept

And operator.

Parameters
flagA value of the enum E.
Returns
This instance and-ed with flag.

Definition at line 155 of file util.hpp.

◆ operator bool()

template<typename E>
constexpr uvw::Flags< E >::operator bool ( ) const
inlineexplicitnoexcept

Checks if this instance is initialized.

Returns
False if it's uninitialized, true otherwise.

Definition at line 161 of file util.hpp.

◆ operator Type()

template<typename E>
constexpr uvw::Flags< E >::operator Type ( ) const
inlinenoexcept

Casts the instance to the underlying type of E.

Returns
An integral representation of the contained flags.

Definition at line 167 of file util.hpp.

◆ operator|() [1/2]

template<typename E>
constexpr Flags uvw::Flags< E >::operator| ( const Flags< E > &  f) const
inlinenoexcept

Or operator.

Parameters
fA valid instance of Flags.
Returns
This instance or-ed with f.

Definition at line 134 of file util.hpp.

◆ operator|() [2/2]

template<typename E>
constexpr Flags uvw::Flags< E >::operator| ( flag) const
inlinenoexcept

Or operator.

Parameters
flagA value of the enum E.
Returns
This instance or-ed with flag.

Definition at line 141 of file util.hpp.


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