[libcxx-commits] [libcxx] 47405ba - [libc++] fix incorrect definition of __indirectly_binary_right_foldable (#219957)
via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Aug 31 08:03:08 PDT 2026
Author: Connector Switch
Date: 2026-08-31T23:03:03+08:00
New Revision: 47405bae765c9ac34cd91636a31d5fb5212b49e3
URL: https://github.com/llvm/llvm-project/commit/47405bae765c9ac34cd91636a31d5fb5212b49e3
DIFF: https://github.com/llvm/llvm-project/commit/47405bae765c9ac34cd91636a31d5fb5212b49e3.diff
LOG: [libc++] fix incorrect definition of __indirectly_binary_right_foldable (#219957)
Fixes https://github.com/llvm/llvm-project/issues/219618.
Added:
Modified:
libcxx/include/__algorithm/ranges_fold.h
libcxx/test/std/algorithms/alg.nonmodifying/alg.fold/ranges.fold_left.pass.cpp
libcxx/test/std/algorithms/alg.nonmodifying/alg.fold/ranges.fold_right.pass.cpp
Removed:
################################################################################
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