[libcxx-commits] [libcxx] [libc++] Implement `ranges::fold_right_last` (PR #195580)

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Sun May 10 04:20:30 PDT 2026


================
@@ -968,6 +968,16 @@ namespace ranges {
           indirectly-binary-right-foldable<T, iterator_t<R>> F>
     constexpr auto ranges::fold_right(R&& r, T init, F f);
 
+  template<bidirectional_iterator I, sentinel_for<I> S,
+          indirectly-binary-right-foldable<iter_value_t<I>, I> F>
+    requires constructible_from<iter_value_t<I>, iter_reference_t<I>>
+    constexpr auto ranges::fold_right_last(I first, S last, F f);
+
+  template<bidirectional_range R,
+          indirectly-binary-right-foldable<range_value_t<R>, iterator_t<R>> F>
+    requires constructible_from<range_value_t<R>, range_reference_t<R>>
+    constexpr auto ranges::fold_right_last(R&& r, F f);
----------------
Zingam wrote:

```suggestion
    constexpr auto ranges::fold_right_last(R&& r, F f);      // since C++23
```

Please update the synopsis.

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


More information about the libcxx-commits mailing list