3 // Copyright (C) 2007-2023 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
22 #if __cplusplus > 201703L
23 #define CONSTEXPR constexpr
29 template <class InputIterator
, class T
>
31 T
accumulate(InputIterator first
, InputIterator last
, T init
);
33 template <class InputIterator
, class T
, class BinaryOperation
>
35 T
accumulate(InputIterator first
, InputIterator last
, T init
,
36 BinaryOperation binary_op
);
38 template <class InputIterator1
, class InputIterator2
, class T
>
40 T
inner_product(InputIterator1 first1
, InputIterator1 last1
,
41 InputIterator2 first2
, T init
);
43 template <class InputIterator1
, class InputIterator2
, class T
,
44 class BinaryOperation1
, class BinaryOperation2
>
46 T
inner_product(InputIterator1 first1
, InputIterator1 last1
,
47 InputIterator2 first2
, T init
,
48 BinaryOperation1 binary_op1
,
49 BinaryOperation2 binary_op2
);
51 template <class InputIterator
, class OutputIterator
>
53 OutputIterator
partial_sum(InputIterator first
,
55 OutputIterator result
);
57 template <class InputIterator
, class OutputIterator
,
58 class BinaryOperation
>
60 OutputIterator
partial_sum(InputIterator first
,
62 OutputIterator result
,
63 BinaryOperation binary_op
);
65 template <class InputIterator
, class OutputIterator
>
67 OutputIterator
adjacent_difference(InputIterator first
,
69 OutputIterator result
);
71 template <class InputIterator
, class OutputIterator
,
72 class BinaryOperation
>
74 OutputIterator
adjacent_difference(InputIterator first
,
76 OutputIterator result
,
77 BinaryOperation binary_op
);
78 #if __cplusplus >= 201103L
79 template<class ForwardIterator
, class T
>
80 CONSTEXPR
void iota(ForwardIterator first
, ForwardIterator last
, T value
);
83 #if __cplusplus >= 201703L
84 template<class InputIterator
>
85 CONSTEXPR typename iterator_traits
<InputIterator
>::value_type
86 reduce(InputIterator first
, InputIterator last
);
88 template<class InputIterator
, class T
>
89 CONSTEXPR T
reduce(InputIterator first
, InputIterator last
, T init
);
91 template<class InputIterator
, class T
, class BinaryOperation
>
92 CONSTEXPR T
reduce(InputIterator first
, InputIterator last
, T init
,
93 BinaryOperation binary_op
);
95 template<class InputIterator
, class OutputIterator
, class T
>
96 CONSTEXPR OutputIterator
97 exclusive_scan(InputIterator first
, InputIterator last
,
98 OutputIterator result
, T init
);
100 template<class InputIterator
, class OutputIterator
, class T
,
101 class BinaryOperation
>
102 CONSTEXPR OutputIterator
103 exclusive_scan(InputIterator first
, InputIterator last
,
104 OutputIterator result
, T init
, BinaryOperation binary_op
);
106 template<class InputIterator
, class OutputIterator
>
107 CONSTEXPR OutputIterator
108 inclusive_scan(InputIterator first
, InputIterator last
,
109 OutputIterator result
);
111 template<class InputIterator
, class OutputIterator
, class BinaryOperation
>
112 CONSTEXPR OutputIterator
113 inclusive_scan(InputIterator first
, InputIterator last
,
114 OutputIterator result
, BinaryOperation binary_op
);
116 template<class InputIterator
, class OutputIterator
, class BinaryOperation
,
118 CONSTEXPR OutputIterator
119 inclusive_scan(InputIterator first
, InputIterator last
,
120 OutputIterator result
, BinaryOperation binary_op
, T init
);
122 template<class InputIterator1
, class InputIterator2
, class T
>
123 CONSTEXPR T
transform_reduce(InputIterator1 first1
, InputIterator1 last1
,
124 InputIterator2 first2
, T init
);
126 template<class InputIterator1
, class InputIterator2
, class T
,
127 class BinaryOperation1
, class BinaryOperation2
>
128 CONSTEXPR T
transform_reduce(InputIterator1 first1
, InputIterator1 last1
,
129 InputIterator2 first2
, T init
,
130 BinaryOperation1 binary_op1
,
131 BinaryOperation2 binary_op2
);
133 template<class InputIterator
, class T
,
134 class BinaryOperation
, class UnaryOperation
>
135 CONSTEXPR T
transform_reduce(InputIterator first
, InputIterator last
, T init
,
136 BinaryOperation binary_op
,
137 UnaryOperation unary_op
);
139 template<class InputIterator
, class OutputIterator
, class T
,
140 class BinaryOperation
, class UnaryOperation
>
141 CONSTEXPR OutputIterator
142 transform_exclusive_scan(InputIterator first
, InputIterator last
,
143 OutputIterator result
, T init
,
144 BinaryOperation binary_op
, UnaryOperation unary_op
);
146 template<class InputIterator
, class OutputIterator
,
147 class BinaryOperation
, class UnaryOperation
>
148 CONSTEXPR OutputIterator
149 transform_inclusive_scan(InputIterator first
, InputIterator last
,
150 OutputIterator result
,
151 BinaryOperation binary_op
, UnaryOperation unary_op
);
153 template<class InputIterator
, class OutputIterator
,
154 class BinaryOperation
, class UnaryOperation
, class T
>
155 CONSTEXPR OutputIterator
156 transform_inclusive_scan(InputIterator first
, InputIterator last
,
157 OutputIterator result
,
158 BinaryOperation binary_op
, UnaryOperation unary_op
,
162 #if __cplusplus > 201703L
163 template<class M
, class N
>
164 constexpr common_type_t
<M
,N
> gcd(M m
, N n
);
166 template<class M
, class N
>
167 constexpr common_type_t
<M
,N
> lcm(M m
, N n
);
170 constexpr T
midpoint(T a
, T b
) noexcept
;
173 constexpr T
* midpoint(T
* a
, T
* b
);