Skip to content

Commit

Permalink
std::forward diff argument in apply_diff()
Browse files Browse the repository at this point in the history
  • Loading branch information
linh2931 committed Sep 10, 2024
1 parent 1f6be3e commit 2f18e3c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions libraries/libfc/include/fc/container/ordered_diff.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,14 @@ class ordered_diff {
return result;
}

/// @param diff the diff_result created from diff(source, target), apply_diff(std::move(source), diff_result) => target
/// @param diff_in (input) the diff_result created from diff(source, target), apply_diff(std::move(source), diff_result) => target
/// @param container the source of diff(source, target) to modify using the diff_result to produce original target
/// @return the modified container now equal to original target
template <typename X>
requires std::same_as<std::decay_t<X>, diff_result>
static Container<T> apply_diff(Container<T>&& container, X&& diff) {
static Container<T> apply_diff(Container<T>&& container, X&& diff_in) {
X diff = std::forward<X>(diff_in);

// Remove from the source based on diff.remove_indexes
for (container_size_type i = 0; i < diff.remove_indexes.size(); ++i) {
FC_ASSERT(i == 0 || diff.remove_indexes[i] > diff.remove_indexes[i-1],
Expand Down

0 comments on commit 2f18e3c

Please sign in to comment.