uvw 2.12.1
Loading...
Searching...
No Matches
uvw::Flags< E > Class Template Referencefinal

Utility class to handle flags. More...

#include <util.h>

Public Member Functions

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

Static Public Member Functions

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

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 80 of file util.h.

Constructor & Destructor Documentation

◆ Flags() [1/2]

template<typename E >
uvw::Flags< E >::Flags ( E flag)
inlineconstexprnoexcept

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

Parameters
flagA value of the enum E.

Definition at line 105 of file util.h.

◆ Flags() [2/2]

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

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 113 of file util.h.

Member Function Documentation

◆ from()

template<typename E >
template<E... V>
static constexpr Flags< E > uvw::Flags< E >::from ( )
inlinestaticconstexpr

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 97 of file util.h.

◆ operator bool()

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

Checks if this instance is initialized.

Returns
False if it's uninitialized, true otherwise.

Definition at line 178 of file util.h.

◆ operator Type()

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

Casts the instance to the underlying type of E.

Returns
An integral representation of the contained flags.

Definition at line 186 of file util.h.

◆ operator&() [1/2]

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

And operator.

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

Definition at line 161 of file util.h.

◆ operator&() [2/2]

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

And operator.

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

Definition at line 170 of file util.h.

◆ operator|() [1/2]

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

Or operator.

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

Definition at line 143 of file util.h.

◆ operator|() [2/2]

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

Or operator.

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

Definition at line 152 of file util.h.


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