nngn
Loading...
Searching...
No Matches
nngn::Flags< T > Struct Template Reference

Wrapper for a small unsigned integral representing flags. More...

#include <flags.h>

Public Types

using UT = std::underlying_type_t<T>
 Value type stored in the object.
 
using AT = std::conditional_t<scoped_enum<T>, T, UT>
 Accepted type for integral arguments.
 
using PT = std::common_type_t<UT, int>
 Promoted type after an operation involving Ts.
 

Public Member Functions

constexpr Flags (void)=default
 
constexpr Flags (UT u)
 
constexpr Flags (AT a)
 
constexpr operator T (void) const
 
constexpr T operator* (void) const
 
constexpr Flags operator~ (void) const
 
constexpr Flags operator- (void) const
 
constexpr Flags operator& (AT rhs)
 
constexpr Flags operator| (AT rhs)
 
constexpr Flags operator^ (AT rhs)
 
constexpr Flagsoperator&= (Flags rhs)
 
constexpr Flagsoperator|= (Flags rhs)
 
constexpr Flagsoperator^= (Flags rhs)
 
constexpr bool is_set (AT a) const
 
constexpr Flagscomp (void)
 
constexpr Flagsset (AT a)
 
constexpr Flagsset (AT a, bool b)
 
constexpr Flagsclear (AT a)
 
constexpr Flags check_and_clear (AT a)
 

Static Public Member Functions

static constexpr Flags cast (PT x)
 Creates an object from the result of an expression.
 

Public Attributes

UT v = {}
 

Detailed Description

template<typename T>
struct nngn::Flags< T >

Wrapper for a small unsigned integral representing flags.

Operations cast the result back to the underlying type to remove the need for explicit casts when it is converted to int.

Member Typedef Documentation

◆ AT

template<typename T >
using nngn::Flags< T >::AT = std::conditional_t<scoped_enum<T>, T, UT>

Accepted type for integral arguments.

◆ PT

template<typename T >
using nngn::Flags< T >::PT = std::common_type_t<UT, int>

Promoted type after an operation involving Ts.

◆ UT

template<typename T >
using nngn::Flags< T >::UT = std::underlying_type_t<T>

Value type stored in the object.

Constructor & Destructor Documentation

◆ Flags() [1/3]

template<typename T >
nngn::Flags< T >::Flags ( void )
constexprdefault

◆ Flags() [2/3]

template<typename T >
nngn::Flags< T >::Flags ( UT u)
inlineconstexpr

◆ Flags() [3/3]

template<typename T >
nngn::Flags< T >::Flags ( AT a)
inlineconstexpr

Member Function Documentation

◆ cast()

template<typename T >
static constexpr Flags nngn::Flags< T >::cast ( PT x)
inlinestaticconstexpr

Creates an object from the result of an expression.

Here is the caller graph for this function:

◆ check_and_clear()

template<typename T >
auto nngn::Flags< T >::check_and_clear ( AT a)
constexpr
Here is the caller graph for this function:

◆ clear()

template<typename T >
Flags & nngn::Flags< T >::clear ( AT a)
inlineconstexpr
Here is the caller graph for this function:

◆ comp()

template<typename T >
Flags & nngn::Flags< T >::comp ( void )
inlineconstexpr

◆ is_set()

template<typename T >
bool nngn::Flags< T >::is_set ( AT a) const
inlineconstexpr
Here is the caller graph for this function:

◆ operator T()

template<typename T >
nngn::Flags< T >::operator T ( void ) const
inlineconstexpr

◆ operator&()

template<typename T >
Flags nngn::Flags< T >::operator& ( AT rhs)
inlineconstexpr

◆ operator&=()

template<typename T >
Flags & nngn::Flags< T >::operator&= ( Flags< T > rhs)
inlineconstexpr

◆ operator*()

template<typename T >
T nngn::Flags< T >::operator* ( void ) const
inlineconstexpr

◆ operator-()

template<typename T >
Flags nngn::Flags< T >::operator- ( void ) const
inlineconstexpr
Here is the call graph for this function:

◆ operator^()

template<typename T >
Flags nngn::Flags< T >::operator^ ( AT rhs)
inlineconstexpr

◆ operator^=()

template<typename T >
Flags & nngn::Flags< T >::operator^= ( Flags< T > rhs)
inlineconstexpr

◆ operator|()

template<typename T >
Flags nngn::Flags< T >::operator| ( AT rhs)
inlineconstexpr

◆ operator|=()

template<typename T >
Flags & nngn::Flags< T >::operator|= ( Flags< T > rhs)
inlineconstexpr

◆ operator~()

template<typename T >
Flags nngn::Flags< T >::operator~ ( void ) const
inlineconstexpr
Here is the call graph for this function:

◆ set() [1/2]

template<typename T >
Flags & nngn::Flags< T >::set ( AT a)
inlineconstexpr
Here is the caller graph for this function:

◆ set() [2/2]

template<typename T >
auto nngn::Flags< T >::set ( AT a,
bool b )
constexpr
Here is the call graph for this function:

Member Data Documentation

◆ v

template<typename T >
UT nngn::Flags< T >::v = {}

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