[gjs/msvc.partial.fix] enum-utils.h: Fix `iwyu` CI
- From: Chun-wei Fan <fanchunwei src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs/msvc.partial.fix] enum-utils.h: Fix `iwyu` CI
- Date: Wed, 10 Mar 2021 08:00:58 +0000 (UTC)
commit d027c055bafb3bf97bc439ef3c2a75acde418660
Author: Chun-wei Fan <fanchunwei src gnome org>
Date: Wed Mar 10 16:00:06 2021 +0800
enum-utils.h: Fix `iwyu` CI
gjs/enum-utils.h | 30 +++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
---
diff --git a/gjs/enum-utils.h b/gjs/enum-utils.h
index 4f38a80e..e247f322 100644
--- a/gjs/enum-utils.h
+++ b/gjs/enum-utils.h
@@ -6,18 +6,6 @@
#include <type_traits>
-#ifdef _MSC_VER
-#define CAST_ENUM_WRAPPER \
- std::conditional_t<is_class<EnumType>(), std::underlying_type_t<EnumType>, void>
-
-#define CAST_WRAPPED_ENUM(x) static_cast<EnumType>(x)
-#define CAST_WRAPPED_ENUM_T(T, x) static_cast<T>(x)
-#else
-#define CAST_ENUM_WRAPPER std::conditional_t<is_class<EnumType>(), WrapperImpl<EnumType>, void>
-#define CAST_WRAPPED_ENUM(x) (x)
-#define CAST_WRAPPED_ENUM_T(T, x) (x)
-#endif
-
namespace GjsEnum {
template <typename T>
@@ -42,10 +30,26 @@ struct WrapperImpl {
}
};
+
+#if defined (__clang__) || defined (__GNUC__)
template <class EnumType>
-using Wrapper = CAST_ENUM_WRAPPER;
+using Wrapper =
+ std::conditional_t<is_class<EnumType>(), WrapperImpl<EnumType>, void>;
+#else
+template <class EnumType>
+using Wrapper =
+ std::conditional_t<is_class<EnumType>(), std::underlying_type_t<EnumType>, void>;
+#endif
} // namespace GjsEnum
+#if defined (__clang__) || defined (__GNUC__)
+# define CAST_WRAPPED_ENUM(x) (x)
+# define CAST_WRAPPED_ENUM_T(T, x) (x)
+#else
+# define CAST_WRAPPED_ENUM(x) static_cast<EnumType>(x)
+# define CAST_WRAPPED_ENUM_T(T, x) static_cast<T>(x)
+#endif
+
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) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]