AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
EnumFlag.h File Reference
#include <type_traits>

Go to the source code of this file.

Classes

class  EnumFlag< T >
 

Namespaces

namespace  EnumTraits
 

Macros

#define DEFINE_ENUM_FLAG(enumType)   constexpr bool IsEnumFlag(enumType) { return true; }
 

Typedefs

template<typename T >
using EnumTraits::IsFlag = std::integral_constant< bool, IsEnumFlag(T{})>
 

Functions

template<typename T >
constexpr bool IsEnumFlag (T)
 
template<typename T , std::enable_if_t< EnumTraits::IsFlag< T >::value, std::nullptr_t > = nullptr>
constexpr T operator& (T left, T right)
 
template<typename T , std::enable_if_t< EnumTraits::IsFlag< T >::value, std::nullptr_t > = nullptr>
constexpr T & operator&= (T &left, T right)
 
template<typename T , std::enable_if_t< EnumTraits::IsFlag< T >::value, std::nullptr_t > = nullptr>
constexpr T operator| (T left, T right)
 
template<typename T , std::enable_if_t< EnumTraits::IsFlag< T >::value, std::nullptr_t > = nullptr>
constexpr T & operator|= (T &left, T right)
 
template<typename T , std::enable_if_t< EnumTraits::IsFlag< T >::value, std::nullptr_t > = nullptr>
constexpr T operator~ (T value)
 

Macro Definition Documentation

◆ DEFINE_ENUM_FLAG

#define DEFINE_ENUM_FLAG (   enumType)    constexpr bool IsEnumFlag(enumType) { return true; }

Function Documentation

◆ IsEnumFlag()

template<typename T >
constexpr bool IsEnumFlag ( )
constexpr
24{ return false; }

◆ operator&()

template<typename T , std::enable_if_t< EnumTraits::IsFlag< T >::value, std::nullptr_t > = nullptr>
constexpr T operator& ( left,
right 
)
inlineconstexpr
36{
37 return static_cast<T>(static_cast<std::underlying_type_t<T>>(left) & static_cast<std::underlying_type_t<T>>(right));
38}

◆ operator&=()

template<typename T , std::enable_if_t< EnumTraits::IsFlag< T >::value, std::nullptr_t > = nullptr>
constexpr T & operator&= ( T &  left,
right 
)
inlineconstexpr
42{
43 return left = left & right;
44}

◆ operator|()

template<typename T , std::enable_if_t< EnumTraits::IsFlag< T >::value, std::nullptr_t > = nullptr>
constexpr T operator| ( left,
right 
)
inlineconstexpr
48{
49 return static_cast<T>(static_cast<std::underlying_type_t<T>>(left) | static_cast<std::underlying_type_t<T>>(right));
50}

◆ operator|=()

template<typename T , std::enable_if_t< EnumTraits::IsFlag< T >::value, std::nullptr_t > = nullptr>
constexpr T & operator|= ( T &  left,
right 
)
inlineconstexpr
54{
55 return left = left | right;
56}

◆ operator~()

template<typename T , std::enable_if_t< EnumTraits::IsFlag< T >::value, std::nullptr_t > = nullptr>
constexpr T operator~ ( value)
inlineconstexpr
60{
61 return static_cast<T>(~static_cast<std::underlying_type_t<T>>(value));
62}