NUMA++ 0.11.0
Loading...
Searching...
No Matches
flags.hpp File Reference

Contains definitions for bitwise operators for enums. More...

#include <type_traits>

Go to the source code of this file.

Namespaces

namespace  numapp
 

Macros

#define NUMAPP_ENABLE_BITFLAG(enum)
 Enables numapp bitwise operators in overload set for the specified enumeration enum.
 

Functions

Bitwise operators for enabled enums

Convenience function to compose bit flags using bitwise OR and AND operators.

Example:

using numapp::operator|; // Bring in numapp::operator| in this scope
MyEnum f = MyEnum::A | MyEnum::B;
f &= MyEnum::A;
MyFunc(f);
MyFunc(MyEnum::A | MyEnum::B);
template<class Enum, typename = typename std::enable_if<IsFlagEnum<Enum>::value>::type>
constexpr Enum numapp::operator| (Enum lhs, Enum rhs) noexcept
 
template<class Enum, typename = typename std::enable_if<IsFlagEnum<Enum>::value>::type>
constexpr Enum & numapp::operator|= (Enum &lhs, Enum rhs) noexcept
 Sets lhs with logical OR between lhs and rhs.
 
template<class Enum, typename = typename std::enable_if<IsFlagEnum<Enum>::value>::type>
constexpr Enum numapp::operator& (Enum lhs, Enum rhs) noexcept
 
template<class Enum, typename = typename std::enable_if<IsFlagEnum<Enum>::value>::type>
constexpr Enum & numapp::operator&= (Enum &lhs, Enum rhs) noexcept
 Sets lhs with logical AND between lhs and rhs.
 

Detailed Description

Contains definitions for bitwise operators for enums.

Definition in file flags.hpp.

Macro Definition Documentation

◆ NUMAPP_ENABLE_BITFLAG

#define NUMAPP_ENABLE_BITFLAG ( enum)
Value:
template <>\
struct IsFlagEnum<enum> : std::true_type { \
static_assert(std::is_enum_v<enum>); \
};

Enables numapp bitwise operators in overload set for the specified enumeration enum.

Note
This macro must be used inside the namespace numapp.

Definition at line 17 of file flags.hpp.