1#ifndef ENTT_CORE_ENUM_HPP
2#define ENTT_CORE_ENUM_HPP
4#include "../stl/concepts.hpp"
5#include "../stl/type_traits.hpp"
13template<
typename Type>
17template<
typename Type>
19 requires stl::is_enum_v<Type>;
20 { Type::_entt_enum_as_bitmask } -> stl::same_as<Type>;
28template<
typename Type>
35template<
typename Type>
49template<entt::enum_bitmask Type>
50[[nodiscard]]
constexpr Type operator|(
const Type lhs,
const Type rhs)
noexcept {
51 return static_cast<Type
>(
static_cast<entt::stl::underlying_type_t<Type>
>(lhs) |
static_cast<entt::stl::underlying_type_t<Type>
>(rhs));
55template<entt::enum_bitmask Type>
56[[nodiscard]]
constexpr Type operator&(
const Type lhs,
const Type rhs)
noexcept {
57 return static_cast<Type
>(
static_cast<entt::stl::underlying_type_t<Type>
>(lhs) &
static_cast<entt::stl::underlying_type_t<Type>
>(rhs));
61template<entt::enum_bitmask Type>
62[[nodiscard]]
constexpr Type operator^(
const Type lhs,
const Type rhs)
noexcept {
63 return static_cast<Type
>(
static_cast<entt::stl::underlying_type_t<Type>
>(lhs) ^
static_cast<entt::stl::underlying_type_t<Type>
>(rhs));
73template<entt::enum_bitmask Type>
74[[nodiscard]]
constexpr Type operator~(
const Type value)
noexcept {
75 return static_cast<Type
>(~static_cast<entt::stl::underlying_type_t<Type>>(value));
79template<entt::enum_bitmask Type>
80[[nodiscard]]
constexpr bool operator!(
const Type value)
noexcept {
81 return !
static_cast<entt::stl::underlying_type_t<Type>
>(value);
85template<entt::enum_bitmask Type>
86constexpr Type &operator|=(Type &lhs,
const Type rhs)
noexcept {
87 return (lhs = (lhs | rhs));
91template<entt::enum_bitmask Type>
92constexpr Type &operator&=(Type &lhs,
const Type rhs)
noexcept {
93 return (lhs = (lhs & rhs));
97template<entt::enum_bitmask Type>
98constexpr Type &operator^=(Type &lhs,
const Type rhs)
noexcept {
99 return (lhs = (lhs ^ rhs));
Specifies that an enum class supports bitmask operations.
constexpr bool enum_as_bitmask_v
Helper variable template.
Enable bitmask support for enum classes.