[libcxx-commits] [libcxx] [libc++] Add `ranges::fold_left_first` and `ranges::fold_left_first_with_iter` (PR #121558)

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Tue Dec 30 22:42:33 PST 2025


================
@@ -0,0 +1,162 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// <algorithm>
+
+// template<input_iterator I, sentinel_for<I> S,
+//          indirectly-binary-left-foldable<T, I> F>
+//     requires constructible_from<iter_value_t<I>, iter_reference_t<I>>
+//     constexpr see below fold_left_first(I first, S last, F f);                               // since C++23
+
+//   template<input_range R, indirectly-binary-left-foldable<T, iterator_t<R>> F>
+//     requires constructible_from<range_value_t<R>, range_reference_t<R>>
+//     constexpr see below fold_left_first(R&& r, F f);                                         // since C++23
+
+// REQUIRES: std-at-least-c++23
----------------
Zingam wrote:

```suggestion
//===----------------------------------------------------------------------===//

// REQUIRES: std-at-least-c++23

// <algorithm>

// template<input_iterator I, sentinel_for<I> S,
//          indirectly-binary-left-foldable<T, I> F>
//     requires constructible_from<iter_value_t<I>, iter_reference_t<I>>
//     constexpr see below fold_left_first(I first, S last, F f);                               // since C++23

//   template<input_range R, indirectly-binary-left-foldable<T, iterator_t<R>> F>
//     requires constructible_from<range_value_t<R>, range_reference_t<R>>
//     constexpr see below fold_left_first(R&& r, F f);                                         // since C++23


```

Nit: We put the requirements first usually.

https://github.com/llvm/llvm-project/pull/121558


More information about the libcxx-commits mailing list