diff options
| author | Chun-wei Fan <fanchunwei@src.gnome.org> | 2021-03-10 16:34:00 +0800 |
|---|---|---|
| committer | Chun-wei Fan <fanchunwei@src.gnome.org> | 2021-03-10 16:41:17 +0800 |
| commit | 0fa62de53dd42d78f21081558b6e45a1a8cc24fc (patch) | |
| tree | 330f8e58b8f046688d60353b979de663c121e4bd | |
| parent | a82634d00f7aea805540225cb8d18ddad01e889c (diff) | |
| download | gjs-msvc.partial.fix.tar.gz | |
gjs/enum-utils.h: static_cast assignment to EnumTypemsvc.partial.fix
This avoid using macros, suggested by Philip Chimento, and allowed a unified
code base for different compilers.
| -rw-r--r-- | gjs/enum-utils.h | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/gjs/enum-utils.h b/gjs/enum-utils.h index 311cf931..2fc4524e 100644 --- a/gjs/enum-utils.h +++ b/gjs/enum-utils.h @@ -42,14 +42,6 @@ using Wrapper = #endif } // namespace GjsEnum -#if defined (__clang__) || defined (__GNUC__) -# define CAST_WRAPPED_ENUM_T(T, x) (x) -#else -# define CAST_WRAPPED_ENUM_T(T, x) static_cast<T>(x) -#endif - -#define CAST_WRAPPED_ENUM(x) CAST_WRAPPED_ENUM_T(EnumType, x) - template <class EnumType, class Wrapped = GjsEnum::Wrapper<EnumType>> constexpr std::enable_if_t<GjsEnum::is_class<EnumType>(), Wrapped> operator&( EnumType const& first, EnumType const& second) { @@ -75,7 +67,7 @@ template <class EnumType, class Wrapped = GjsEnum::Wrapper<EnumType>> constexpr std::enable_if_t<GjsEnum::is_class<EnumType>(), Wrapped&> operator|=( EnumType& first, // NOLINT(runtime/references) EnumType const& second) { - first = CAST_WRAPPED_ENUM(first | second); + first = static_cast<EnumType>(first | second); return reinterpret_cast<Wrapped&>(first); } @@ -83,7 +75,7 @@ template <class EnumType, class Wrapped = GjsEnum::Wrapper<EnumType>> constexpr std::enable_if_t<GjsEnum::is_class<EnumType>(), Wrapped&> operator&=( EnumType& first, // NOLINT(runtime/references) EnumType const& second) { - first = CAST_WRAPPED_ENUM(first & second); + first = static_cast<EnumType>(first & second); return reinterpret_cast<Wrapped&>(first); } |
