Skip to content

Commit 77cea94

Browse files
Don't require aggregate type for CountMembers<> and add a test for it
Signed-off-by: Christian Parpart <[email protected]>
1 parent 02484cd commit 77cea94

File tree

2 files changed

+1
-1
lines changed

2 files changed

+1
-1
lines changed

include/reflection-cpp/reflection.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ namespace detail
145145
} // namespace detail
146146

147147
template <class T, class... Args>
148-
requires(std::is_aggregate_v<std::remove_cvref_t<T>>)
149148
inline constexpr auto CountMembers = [] {
150149
using V = std::remove_cvref_t<T>;
151150
if constexpr (requires { V { Args {}..., detail::any_t {} }; })

test-reflection-cpp.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ name="John Doe" email="[email protected]" age=43
6565
TEST_CASE("nested", "[reflection]")
6666
{
6767
auto ts = TestStruct { 1, 2.0f, 3.0, "hello", { "John Doe", "[email protected]", 42 } };
68+
CHECK(Reflection::CountMembers<std::remove_reference_t<decltype(ts)>> == 5);
6869
auto const result = Reflection::Inspect(ts);
6970
CHECK(result == R"(a=1 b=2 c=3 d="hello" e={name="John Doe" email="[email protected]" age=42})");
7071
}

0 commit comments

Comments
 (0)