Skip to content

Commit

Permalink
[WIP] testing r-values
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkaratarakis committed Dec 17, 2024
1 parent 55347ba commit 7864783
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/fixed_containers/reflection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ constexpr void for_each_field(T&& instance, Func&& func)
{
constexpr const auto& FIELD_NAMES = field_names_of<T>();
struct_decomposition::to_parameter_pack<FIELD_NAMES.size()>(
std::forward<T>(instance),
instance,
[&func]<typename... Args>(Args&&... args) -> bool
{
variadic_templates::for_each_entry(
Expand Down
14 changes: 14 additions & 0 deletions test/reflection_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,20 @@ TEST(Reflection, ForEachFieldEmptyStruct)
static_assert(COUNTER == 0);
}

TEST(Reflection, RValue)
{
constexpr auto RESULT = []()
{
std::size_t counter = 0;
reflection::for_each_field(FieldCount100{},
[&]<typename T>(const std::string_view& /*name*/, const T&)
{ counter++; });
return counter;
}();

static_assert(100 == RESULT);
}

TEST(Reflection, MockFailingAddressOfOperator)
{
MockFailingAddressOfOperator instance{};
Expand Down

0 comments on commit 7864783

Please sign in to comment.