ToyGine2 26.2.0
Game Engine for retro consoles
Loading...
Searching...
No Matches
bitwise_enum.hpp File Reference

Opt-in bitwise operators for scoped enumerations used as flag sets. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  toy::EnableBitwiseOperators< T >
 Primary template: disables generic bitwise operators for T unless specialized. More...

Namespaces

namespace  toy
 Root namespace containing all engine modules.

Macros

#define ENABLE_BITWISE_OPERATORS(T)
 Specializes toy::EnableBitwiseOperators so that enable is true for the scoped enum T.

Functions

template<typename T>
constexpr T toy::operator| (T lhs, T rhs) noexcept
 Computes bitwise OR on the underlying integers, then casts back to T.
template<typename T>
constexpr T toy::operator& (T lhs, T rhs) noexcept
 Computes bitwise AND on the underlying integers, then casts back to T.
template<typename T>
constexpr T toy::operator^ (T lhs, T rhs) noexcept
 Computes bitwise XOR on the underlying integers, then casts back to T.
template<typename T>
constexpr T toy::operator~ (T lhs) noexcept
 Computes bitwise NOT of the underlying integer, then casts back to T.
template<typename T>
constexpr T & toy::operator|= (T &lhs, T rhs) noexcept
 Compound OR: lhs becomes lhs | rhs.
template<typename T>
constexpr T & toy::operator&= (T &lhs, T rhs) noexcept
 Compound AND: lhs becomes lhs & rhs.
template<typename T>
constexpr T & toy::operator^= (T &lhs, T rhs) noexcept
 Compound XOR: lhs becomes lhs ^ rhs.

Detailed Description

Opt-in bitwise operators for scoped enumerations used as flag sets.

Defines toy::EnableBitwiseOperators and constrained operator overloads.

Note
Included by core.hpp; do not include this file directly.

Macro Definition Documentation

◆ ENABLE_BITWISE_OPERATORS

#define ENABLE_BITWISE_OPERATORS ( T)
Value:
template <> \
static constexpr bool enable = true; \
};
Primary template: disables generic bitwise operators for T unless specialized.
Definition bitwise_enum.hpp:88

Specializes toy::EnableBitwiseOperators so that enable is true for the scoped enum T.

The macro expands to a full class template specialization in namespace toy. Place it in the global namespace after T is complete so the specialization is visible when instantiating the generic operators.

Parameters
TThe scoped enumeration type (may be qualified with its namespace).
Precondition
T names a complete enum class type intended for use as a bit-flag set.
See also
EnableBitwiseOperators