[gjs/msvc.partial.fix] gjs/enum-utils.h: static_cast assignment to EnumType



commit 6dd7273f30515c4b7652333f5594da5faaa5b864
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Mar 10 16:34:00 2021 +0800

    gjs/enum-utils.h: static_cast assignment to EnumType
    
    This avoid using macros, suggested by Philip Chimento, and allowed a unified
    code base for different compilers.

 gjs/enum-utils.h | 12 ++----------
 1 file 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);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]