|
|
@@ -144,6 +144,13 @@ namespace stream {
|
|
|
value_type accumulate(F && fold, value_type const & accum) const {
|
|
|
return std::accumulate(begin(), end(), accum, fold);
|
|
|
}
|
|
|
+
|
|
|
+ template <typename F>
|
|
|
+ std::optional<value_type> accumulate(F && fold) const {
|
|
|
+ if (empty()) { return std::nullopt; }
|
|
|
+ value_type first = *begin();
|
|
|
+ return std::accumulate(++begin(), end(), first, fold);
|
|
|
+ }
|
|
|
|
|
|
value_type accumulate(value_type const & accum) const {
|
|
|
return std::accumulate(begin(), end(), accum);
|