accumulate.qbk 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. [/
  2. Copyright 2010 Neil Groves
  3. Distributed under the Boost Software License, Version 1.0.
  4. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. /]
  6. [section:accumulate accumulate]
  7. [heading Prototype]
  8. ``
  9. template<
  10. class SinglePassRange,
  11. class Value
  12. >
  13. Value accumulate(const SinglePassRange& source_rng,
  14. Value init);
  15. template<
  16. class SinglePassRange,
  17. class Value,
  18. class BinaryOperation
  19. >
  20. Value accumulate(const SinglePassRange& source_rng,
  21. Value init,
  22. BinaryOperation op);
  23. ``
  24. [heading Description]
  25. `accumulate` is a generalisation of summation. It computes a binary operation (`operator+`
  26. in the non-predicate version) of `init` and all of the elements in `rng`.
  27. The return value is the resultant value of the above algorithm.
  28. [heading Definition]
  29. Defined in the header file `boost/range/numeric.hpp`
  30. [heading Requirements]
  31. [heading For the first version]
  32. # `SinglePassRange` is a model of the __single_pass_range__ Concept.
  33. # `Value` is a model of the `AssignableConcept`.
  34. # An `operator+` is defined for a left-hand operand of type `Value` and a right-hand operand of the `SinglePassRange` value type.
  35. # The return type of the above operator is convertible to `Value`.
  36. [heading For the second version]
  37. # `SinglePassRange` is a model of the __single_pass_range__ Concept.
  38. # `Value` is a model of the `AssignableConcept`.
  39. # `BinaryOperation` is a model of the `BinaryFunctionConcept`.
  40. # `Value` is convertible to `BinaryOperation`'s first argument type.
  41. # `SinglePassRange`'s value type is convertible to `BinaryOperation`'s second argument type.
  42. # The return type of `BinaryOperation` is convertible to `Value`.
  43. [heading Complexity]
  44. Linear. Exactly `distance(source_rng)`.
  45. [endsect]