summaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2022-08-14 11:36:36 +0200
committerFernando Sahmkow <fsahmkow27@gmail.com>2022-10-06 21:00:53 +0200
commitf5fd6b5c8674fcf64a3e70809ee0a34d3a95beb6 (patch)
tree5156a04816d6556b8babe7d69301f18098b8dd1d /src/common
parentMaxwell3D: Add small_index_2 (diff)
downloadyuzu-f5fd6b5c8674fcf64a3e70809ee0a34d3a95beb6.tar
yuzu-f5fd6b5c8674fcf64a3e70809ee0a34d3a95beb6.tar.gz
yuzu-f5fd6b5c8674fcf64a3e70809ee0a34d3a95beb6.tar.bz2
yuzu-f5fd6b5c8674fcf64a3e70809ee0a34d3a95beb6.tar.lz
yuzu-f5fd6b5c8674fcf64a3e70809ee0a34d3a95beb6.tar.xz
yuzu-f5fd6b5c8674fcf64a3e70809ee0a34d3a95beb6.tar.zst
yuzu-f5fd6b5c8674fcf64a3e70809ee0a34d3a95beb6.zip
Diffstat (limited to 'src/common')
-rw-r--r--src/common/algorithm.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/common/algorithm.h b/src/common/algorithm.h
index 9ddfd637b..055dca142 100644
--- a/src/common/algorithm.h
+++ b/src/common/algorithm.h
@@ -24,4 +24,12 @@ template <class ForwardIt, class T, class Compare = std::less<>>
return first != last && !comp(value, *first) ? first : last;
}
+template <typename T, typename Func, typename... Args>
+T FoldRight(T initial_value, Func&& func, Args&&... args) {
+ T value{initial_value};
+ const auto high_func = [&value, &func]<typename T>(T x) { value = func(value, x); };
+ (std::invoke(high_func, std::forward<Args>(args)), ...);
+ return value;
+}
+
} // namespace Common