[libcxx-commits] [libcxx] [libc++] fix incorrect definition of __indirectly_binary_right_foldable (PR #219957)
Connector Switch via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Aug 31 05:11:28 PDT 2026
https://github.com/c8ef created https://github.com/llvm/llvm-project/pull/219957
None
>From a98a56a4032965ffd77edd28ff8b968654d8834a Mon Sep 17 00:00:00 2001
From: c8ef <c8ef at outlook.com>
Date: Mon, 31 Aug 2026 20:11:03 +0800
Subject: [PATCH] [libc++] fix incorrect definition of
__indirectly_binary_right_foldable
---
libcxx/include/__algorithm/ranges_fold.h | 6 +-----
.../alg.nonmodifying/alg.fold/ranges.fold_left.pass.cpp | 6 ++++++
.../alg.nonmodifying/alg.fold/ranges.fold_right.pass.cpp | 6 ++++++
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/libcxx/include/__algorithm/ranges_fold.h b/libcxx/include/__algorithm/ranges_fold.h
index 27e042395dad0..286d7c436412f 100644
--- a/libcxx/include/__algorithm/ranges_fold.h
+++ b/libcxx/include/__algorithm/ranges_fold.h
@@ -96,11 +96,7 @@ struct __flipped {
};
template <class _Func, class _Tp, class _Iter>
-concept __indirectly_binary_right_foldable =
- __indirectly_binary_left_foldable_impl<__flipped<_Func>,
- _Tp,
- _Iter,
- invoke_result_t<_Func&, _Tp, iter_reference_t<_Iter>>>;
+concept __indirectly_binary_right_foldable = __indirectly_binary_left_foldable<__flipped<_Func>, _Tp, _Iter>;
struct __fold_left_with_iter {
template <input_iterator _Ip, sentinel_for<_Ip> _Sp, class _Tp, __indirectly_binary_left_foldable<_Tp, _Ip> _Fp>
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.fold/ranges.fold_left.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.fold/ranges.fold_left.pass.cpp
index e08d54c597853..d9a325a83872b 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.fold/ranges.fold_left.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.fold/ranges.fold_left.pass.cpp
@@ -330,6 +330,12 @@ void runtime_only_test_case() {
auto const expected = triangular_sum(data);
check(data, 0, std::plus<long>(), static_cast<long>(expected));
}
+
+ {
+ auto const data = std::vector<int>{1, 2, 3, 4};
+ auto concat = [](std::string s, int x) { return s + ':' + std::to_string(x); };
+ check(data, "A", concat, std::string{"A:1:2:3:4"});
+ }
}
int main(int, char**) {
diff --git a/libcxx/test/std/algorithms/alg.nonmodifying/alg.fold/ranges.fold_right.pass.cpp b/libcxx/test/std/algorithms/alg.nonmodifying/alg.fold/ranges.fold_right.pass.cpp
index 26437884c55b6..51a10864d0734 100644
--- a/libcxx/test/std/algorithms/alg.nonmodifying/alg.fold/ranges.fold_right.pass.cpp
+++ b/libcxx/test/std/algorithms/alg.nonmodifying/alg.fold/ranges.fold_right.pass.cpp
@@ -186,6 +186,12 @@ void runtime_only_test_case() {
auto const expected = triangular_sum(data);
check(data, 0, std::plus<long>(), static_cast<long>(expected));
}
+
+ {
+ auto const data = std::vector<int>{1, 2, 3, 4};
+ auto concat = [](int x, std::string s) { return s + ':' + std::to_string(x); };
+ check(data, "A", concat, std::string{"A:4:3:2:1"});
+ }
}
int main(int, char**) {
More information about the libcxx-commits
mailing list