partial_sum

| Home | Libraries | People | FAQ | More

##### partial_sum

###### Prototype

    template<class SinglePassRange,
             class OutputIterator>
    OutputIterator partial_sum(const SinglePassRange& rng,
                               OutputIterator out_it);

    template<class SinglePassRange,
             class OutputIterator,
             class BinaryOperation>
    OutputIterator partial_sum(const SinglePassRange& rng,
                               OutputIterator out_it,
                               BinaryOperation op);

###### Description

`partial_sum` calculates a generalised partial sum of `rng` in the same manner as `std::partial_sum(boost::begin(rng), boost::end(rng), out_it)`. See partial_sum.

###### Definition

Defined in the header file `boost/range/numeric.hpp`

###### Requirements

###### For the first version

1. `SinglePassRange` is a model of the Single Pass Range Concept.
2. `OutputIterator` is a model of the `OutputIteratorConcept`.
3. If `x` and `y` are objects of `SinglePassRange`'s value type, then `x + y` is defined.
4. The return type of `x + y` is convertible to the value type of `SinglePassRange`.
5. The value type of `SinglePassRange` is convertible to a type in `OutputIterator`'s set of value types.

###### For the second version

1. `SinglePassRange` is a model of the Single Pass Range Concept.
2. `OutputIterator` is a model of the `OutputIteratorConcept`.
3. `BinaryOperation` is a model of the `BinaryFunctionConcept`.
4. The result type of `BinaryOperation` is convertible to the value type of `SinglePassRange`.
5. The value type of `SinglePassRange` is convertible to a type in `OutputIterator`'s set of value types.

###### Precondition:

`[result, result + distance(rng))` is a valid range.

###### Complexity

Linear. If `empty(rng)` then zero applications, otherwise `distance(rng) - 1` applications are performed.