From fd44e4f960b616f1280da9d1a7c1dd91e3352c10 Mon Sep 17 00:00:00 2001 From: DH Date: Wed, 20 Nov 2024 23:12:34 +0300 Subject: [PATCH] refl: accept enums without valid 0 members --- rx/include/rx/refl.hpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/rx/include/rx/refl.hpp b/rx/include/rx/refl.hpp index e829fea..1341bd3 100644 --- a/rx/include/rx/refl.hpp +++ b/rx/include/rx/refl.hpp @@ -133,18 +133,17 @@ namespace detail { template requires std::is_enum_v constexpr auto calcFieldCount() { - - if constexpr (!requires { getNameOf()[0]; }) { + if constexpr (requires { EnumT::Count; }) { + return static_cast(EnumT::Count); + } else if constexpr (requires { EnumT::_count; }) { + return static_cast(EnumT::_count); + } else if constexpr (requires { EnumT::count; }) { + return static_cast(EnumT::count); + } else if constexpr (!requires { getNameOf()[0]; }) { return N; } else { constexpr auto c = getNameOf()[0]; - if constexpr (requires { EnumT::Count; }) { - return static_cast(EnumT::Count); - } else if constexpr (requires { EnumT::_count; }) { - return static_cast(EnumT::_count); - } else if constexpr (requires { EnumT::count; }) { - return static_cast(EnumT::count); - } else if constexpr (!requires { getNameOf()[0]; }) { + if constexpr (!requires { getNameOf()[0]; }) { return N; } else if constexpr (c >= '0' && c <= '9') { return N;