| 1234567891011121314151617181920212223 |
- //
- // fold.hpp
- // stream
- //
- // Created by Sam Jaffe on 8/14/16.
- //
- #pragma once
- #include <numeric>
- namespace stream {
- template <typename L, typename R>
- struct fold_left_t {
- L init;
- std::function<L(const L&, const R&)> fold;
- };
- }
- template <typename L, typename R, bool B>
- L operator >(stream::detail::stream_base<R, B> const &s, stream::fold_left_t<L, R> && f) {
- return std::accumulate(s.begin(), s.end(), f.fold, f.init);
- }
|