@@ -101,32 +101,10 @@ inline constexpr auto JoinStringLiterals = detail::join<Strs...>();
101101
102102namespace detail
103103{
104- struct any_t final
104+ struct AnyType final
105105 {
106- #if defined(__clang__)
107- #pragma clang diagnostic push
108- #pragma clang diagnostic ignored "-Weverything"
109- template <class T >
110- requires (!std::same_as<T, const char *> && !std::same_as<T, std::nullptr_t >)
111- [[maybe_unused]] constexpr operator T() const ;
112- #pragma clang diagnostic pop
113- #elif defined(_MSC_VER)
114- template <class T >
115- requires (!std::same_as<T, const char *> && !std::same_as<T, std::nullptr_t >)
116- [[maybe_unused]] constexpr operator T() const ;
117- #else
118- #pragma GCC diagnostic push
119- #pragma GCC diagnostic ignored "-Wmissing-declarations"
120106 template <class T >
121- requires (!std::same_as<T, const char *> && !std::same_as<T, std::nullptr_t >)
122107 [[maybe_unused]] constexpr operator T () const ;
123- #pragma GCC diagnostic pop
124- #endif
125-
126- [[maybe_unused]] constexpr operator std::string_view () const
127- {
128- return {};
129- }
130108 };
131109
132110 template <auto Ptr>
@@ -142,21 +120,21 @@ namespace detail
142120 // return std::source_location::current().function_name();
143121 return REFLECTION_PRETTY_FUNCTION;
144122 }
123+
124+ template <class T , class ... Args>
125+ requires (std::is_aggregate_v<std::remove_cvref_t <T>>)
126+ constexpr inline auto CountMembers = []() constexpr {
127+ using AggregateType = std::remove_cvref_t <T>;
128+ if constexpr (requires { AggregateType { Args {}..., AnyType {} }; })
129+ return CountMembers<AggregateType, Args..., AnyType>;
130+ else
131+ return sizeof ...(Args);
132+ }();
133+
145134} // namespace detail
146135
147- template <class T , class ... Args>
148- requires (std::is_aggregate_v<std::remove_cvref_t <T>>)
149- inline constexpr auto CountMembers = []() constexpr {
150- using V = std::remove_cvref_t <T>;
151- if constexpr (requires { V { Args {}..., detail::any_t {} }; })
152- {
153- return CountMembers<V, Args..., detail::any_t >;
154- }
155- else
156- {
157- return sizeof ...(Args);
158- }
159- }();
136+ template <class T >
137+ constexpr inline auto CountMembers = detail::CountMembers<T>;
160138
161139constexpr size_t MaxReflectionMemerCount = 50 ; // should go as high as 256, I guess? for now 30 is enough
162140
0 commit comments