Small library. Deep diffs.

Every change.In plain sight.

A small C++20 library for comparing objects, tracking fields and restoring state. One header. Just the changes that matter.

C++20Header-onlyNo dependencies

A closer look

Full example
example.cpp
// 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)
);
Changes2 changes
moved
[0]→[2]
modified
[2].count
10→12

Matched by id. Only one move.

Exact paths. Typed values. A clear picture of before and after.

Read the contracts

Nested by design

Walk registered structures, vectors, maps, arrays and optionals. Follow a change all the way to its leaf.

Identity over position

Match elements by your own key. Detect moves, additions and removals, with predictable handling of duplicate keys.

A way back

Keep bounded snapshot history. Restore a saved state with undo, redo and rollback.

Ready when you are

One header.Straight into your project.

Copy the header into your include path, or add VarDiff to your CMake project and link its target.

Read the documentation
CMakeLists.txt
add_subdirectory(vardiff)
target_link_libraries(app PRIVATE vardiff::vardiff)
#include <vardiff/vardiff.hpp>Get the header