Nested by design
Walk registered structures, vectors, maps, arrays and optionals. Follow a change all the way to its leaf.
A small C++20 library for comparing objects, tracking fields and restoring state. One header. Just the changes that matter.
// Item fields are registered with schema<Item>.
const std::vector<Item> before{
{1, 10}, {2, 20}, {3, 30}
};
const std::vector<Item> after{
{2, 20}, {3, 30}, {1, 12}
};
auto changes = vardiff::deep_diff(
before, after,
vardiff::key(&Item::id)
);
Matched by id. Only one move.
struct Player { int hp = 100; };
Player player;
auto watcher = vardiff::track(
player,
vardiff::field("hp", &Player::hp)
);
player.hp = 75;
auto changes = watcher.diff();
Your object stays yours. Read changes when you need them.
Exact paths. Typed values. A clear picture of before and after.
Read the contractsWalk registered structures, vectors, maps, arrays and optionals. Follow a change all the way to its leaf.
Match elements by your own key. Detect moves, additions and removals, with predictable handling of duplicate keys.
Keep bounded snapshot history. Restore a saved state with undo, redo and rollback.
Copy the header into your include path, or add VarDiff to your CMake project and link its target.
Read the documentationadd_subdirectory(vardiff)
target_link_libraries(app PRIVATE vardiff::vardiff)
#include <vardiff/vardiff.hpp>Get the header