// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once #include #define DECLARE_ENUM_FLAG_OPERATORS(type) \ [[nodiscard]] constexpr type operator|(type a, type b) noexcept { \ using T = std::underlying_type_t; \ return static_cast(static_cast(a) | static_cast(b)); \ } \ [[nodiscard]] constexpr type operator&(type a, type b) noexcept { \ using T = std::underlying_type_t; \ return static_cast(static_cast(a) & static_cast(b)); \ } \ [[nodiscard]] constexpr type operator^(type a, type b) noexcept { \ using T = std::underlying_type_t; \ return static_cast(static_cast(a) ^ static_cast(b)); \ } \ [[nodiscard]] constexpr type operator<<(type a, type b) noexcept { \ using T = std::underlying_type_t; \ return static_cast(static_cast(a) << static_cast(b)); \ } \ [[nodiscard]] constexpr type operator>>(type a, type b) noexcept { \ using T = std::underlying_type_t; \ return static_cast(static_cast(a) >> static_cast(b)); \ } \ constexpr type& operator|=(type& a, type b) noexcept { \ a = a | b; \ return a; \ } \ constexpr type& operator&=(type& a, type b) noexcept { \ a = a & b; \ return a; \ } \ constexpr type& operator^=(type& a, type b) noexcept { \ a = a ^ b; \ return a; \ } \ constexpr type& operator<<=(type& a, type b) noexcept { \ a = a << b; \ return a; \ } \ constexpr type& operator>>=(type& a, type b) noexcept { \ a = a >> b; \ return a; \ } \ [[nodiscard]] constexpr type operator~(type key) noexcept { \ using T = std::underlying_type_t; \ return static_cast(~static_cast(key)); \ } \ [[nodiscard]] constexpr bool True(type key) noexcept { \ using T = std::underlying_type_t; \ return static_cast(key) != 0; \ } \ [[nodiscard]] constexpr bool False(type key) noexcept { \ using T = std::underlying_type_t; \ return static_cast(key) == 0; \ }