Contents
1
Parameters
2
Return value
3
Complexity
4
Exceptions
5
Notes
6
Example
7
See also
[
edit
]
Parameters
|
binary
FunctionObject
that will be applied in unspecified order to the result of dereferencing the input iterators, the results of other
op
and
init
.
|
Type requirements
|
-
|
-
ForwardIt
must meet the requirements of
LegacyForwardIterator
.
[
edit
]
Return value
1-4)
The generalized sum of
init
and the elements of
[
first
,
last
)
over
std::
plus
<>
(
)
.
5,6)
The generalized sum of
init
and the elements of
[
first
,
last
)
over
op
.
The
generalized sum
of a group of elements over an binary operation
binary_op
is defined as follows:
-
If the group only has one element, the sum is the value of the element.
-
Otherwise, performs the following operations in order:
-
Takes any two elements
elem1
and
elem2
from the group.
-
Calculates
binary_op
(
elem1, elem2
)
and puts the result back to the group.
-
Repeats steps 1 and 2 until there is only one element in the group.
[
edit
]
Complexity
Given
\(\scriptsize N\)
N
as
std::
distance
(
first, last
)
:
1-4)
\(\scriptsize O(N)\)
O(N)
applications of
std::
plus
<>
(
)
.
5,6)
\(\scriptsize O(N)\)
O(N)
applications of
op
.
[
edit
]
Exceptions
The overloads with a template parameter named
ExecutionPolicy
report errors as follows:
|
|
sums up or folds a range of elements
(function template)
[edit]
|
|
applies a function to a range of elements, storing results in a destination range
(function template)
[edit]
|
|
applies an invocable, then reduces out of order
(function template)
[edit]
|
|
left-folds a range of elements
(niebloid)
[edit]
Toolbox
What links here
Related changes
Upload file
Special pages
Printable version
Permanent link
Page information
Deutsch
Español
Français
Italiano
日本語
Português
Русский
中文
|