coveo::linq
Implementation of .NET-like LINQ operators in C++
|
Computes sum of a sequence of values. More...
Functions | |
template<typename F > | |
auto | coveo::linq::sum (const F &num_f) -> detail::sum_impl< F > |
Computes sum using numerical function. More... | |
The sum
operator computes the sum of all values in a sequence. To achieve this, it needs a numerical function to extract a numeric value from each sequence element.
This is a terminal operator.
.NET equivalent: Sum
auto coveo::linq::sum | ( | const F & | num_f | ) | -> detail::sum_impl<F> |
Computes the sum of all elements in a sequence by repeatedly calling a numerical function. The function receives an element as parameter and must return a numerical value for the element. The final result is the sum of all such numerical values.
Does not work on empty sequences.
Use like this:
num_f | Function to get numerical value for each element. |
coveo::linq::empty_sequence | The sequence contains no elements. |