proxygen
folly::gen::detail::Sum Class Reference

#include <Base-inl.h>

Inheritance diagram for folly::gen::detail::Sum:
folly::gen::Operator< Sum > folly::gen::FBounded< Self >

Public Member Functions

 Sum ()=default
 
template<class Source , class Value , class StorageType = typename std::decay<Value>::type>
StorageType compose (const GenImpl< Value, Source > &source) const
 
- Public Member Functions inherited from folly::gen::Operator< Sum >
ResultGen compose (const GenImpl< Value, Source > &source) const
 
- Public Member Functions inherited from folly::gen::FBounded< Self >
const Self & self () const
 
Self & self ()
 

Additional Inherited Members

- Protected Member Functions inherited from folly::gen::Operator< Sum >
 Operator ()=default
 
 Operator (Operator &&) noexcept=default
 
 Operator (const Operator &)=default
 
Operatoroperator= (Operator &&) noexcept=default
 
Operatoroperator= (const Operator &)=default
 

Detailed Description

Sum - For simply summing up all the values from a source.

This type is usually used through its singleton, 'sum':

auto gaussSum = seq(1, 100) | sum;

Definition at line 2151 of file Base-inl.h.

Constructor & Destructor Documentation

folly::gen::detail::Sum::Sum ( )
default

Member Function Documentation

template<class Source , class Value , class StorageType = typename std::decay<Value>::type>
StorageType folly::gen::detail::Sum::compose ( const GenImpl< Value, Source > &  source) const
inline

Definition at line 2159 of file Base-inl.h.

References folly::gen::foldl(), folly::gen::move, and v.

2159  {
2160  static_assert(!Source::infinite, "Cannot sum infinite source");
2161  return foldl(
2162  StorageType(0),
2163  [](StorageType&& accum, Value v) {
2164  return std::move(accum) + std::forward<Value>(v);
2165  })
2166  .compose(source);
2167  }
auto v
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
FoldLeft foldl(Seed seed=Seed(), Fold fold=Fold())
Definition: Base.h:791
StorageType compose(const GenImpl< Value, Source > &source) const
Definition: Base-inl.h:2159
bool Value(const T &value, M matcher)

The documentation for this class was generated from the following file: