[llvm] [ADT] Wrapper for `std::accumulate` accepting a `range`. (PR #158702)

Jakub Kuderski via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 15 13:49:02 PDT 2025


================
@@ -1694,6 +1695,12 @@ template <typename R> constexpr size_t range_size(R &&Range) {
     return static_cast<size_t>(std::distance(adl_begin(Range), adl_end(Range)));
 }
 
+/// Wrapper for std::accumulate.
+template <typename R, typename E> E accumulate(R &&Range, E &&Init) {
----------------
kuhar wrote:

Err, I think one corner case is that if `Init` is a const ref, this will return a const type -- not sure if this is desired. Maybe leave the return type as `auto`?

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


More information about the llvm-commits mailing list