4#include <reflection-cpp/reflection.hpp>
9template <
typename Record>
13 DifferenceView(
const Record* lhs,
const Record* rhs)
noexcept:
19 template <
typename Callback>
20 void iterate(Callback&& callback)
noexcept
22 Reflection::template_for<0, Reflection::CountMembers<Record>>([&]<
auto I>() {
23 if (std::find(indexes.begin(), indexes.end(), I) != indexes.end())
25 callback(Reflection::GetMemberAt<I>(*lhs), Reflection::GetMemberAt<I>(*rhs));
30 void push_back(
size_t ind)
noexcept
32 indexes.push_back(ind);
35 std::vector<size_t> indexes;
40template <
typename Record>
41DifferenceView<Record> CollectDifferences(Record
const& left, Record
const& right)
noexcept
44 DifferenceView<Record> view { &left, &right };
46 Reflection::CollectDifferences(
47 left, right, [&](
size_t ind, [[maybe_unused]]
auto const& left_elem, [[maybe_unused]]
auto const& right_elem) { view.push_back(ind); });