OXY-SYNC-CONTAINER 1.0
OXY-SYNC-CONTAINER Library Documentation
Loading...
Searching...
No Matches
merge_map.hpp File Reference

Three-way merge functionality for std::map with conflict resolution. More...

Namespaces

namespace  oxy::sync
 This namespace contains synchronization-related functionality for the oxy library.

Functions

template<typename K, typename V>
std::map< K, V > oxy::sync::merge_maps (const std::map< K, V > &ancestor, const std::map< K, V > &left, const std::map< K, V > &right, std::function< V(const K &, const std::optional< V > &ancestor_val, const std::optional< V > &left_val, const std::optional< V > &right_val)> conflict_callback)
 Performs a three-way merge of three maps using an ancestor (base) version to detect and resolve conflicts.

Detailed Description

Three-way merge functionality for std::map with conflict resolution.

This header defines a template function merge_maps that performs a three-way merge of three std::map<K, V> instances (ancestor, left, and right) with conflict resolution. The function uses a callback to resolve conflicts when both left and right branches have modified the same key differently. The merge logic is based on comparing values from the ancestor, left, and right maps to determine which value to use in the merged result.