summaryrefslogtreecommitdiff
path: root/src/common/algorithm.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/algorithm.h')
-rw-r--r--src/common/algorithm.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/common/algorithm.h b/src/common/algorithm.h
index 4804a3421..c27c9241d 100644
--- a/src/common/algorithm.h
+++ b/src/common/algorithm.h
@@ -1,6 +1,5 @@
1// Copyright 2019 yuzu emulator team 1// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
2// Licensed under GPLv2 or any later version 2// SPDX-License-Identifier: GPL-2.0-or-later
3// Refer to the license.txt file included.
4 3
5#pragma once 4#pragma once
6 5
@@ -25,4 +24,12 @@ template <class ForwardIt, class T, class Compare = std::less<>>
25 return first != last && !comp(value, *first) ? first : last; 24 return first != last && !comp(value, *first) ? first : last;
26} 25}
27 26
27template <typename T, typename Func, typename... Args>
28T FoldRight(T initial_value, Func&& func, Args&&... args) {
29 T value{initial_value};
30 const auto high_func = [&value, &func]<typename U>(U x) { value = func(value, x); };
31 (std::invoke(high_func, std::forward<Args>(args)), ...);
32 return value;
33}
34
28} // namespace Common 35} // namespace Common