cpp/algorithm/accumulate

Computes the sum of the given value and the elements in the range.

@1@ Initializes the accumulator (of type ) with the initial value  and then modifies it with  for every iterator  in the range  in order.

@2@ Initializes the accumulator (of type ) with the initial value  and then modifies it with  for every iterator  in the range  in order.

@@ If invalidates any iterators (including the end iterators) or modifies any elements of the range involved, the behavior is undefined.

Return value
after all modifications.

Common mistakes
If left to type inference, operates on values of the same type as  which can result in unwanted casting of the iterator elements. For example, likely does not give the result one wishes for when  is of type.