57#define _STL_NUMERIC_H 1
64namespace std _GLIBCXX_VISIBILITY(default)
66_GLIBCXX_BEGIN_NAMESPACE_VERSION
72#if __cplusplus >= 201103L
84 template<
typename _ForwardIterator,
typename _Tp>
87 iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
90 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
92 __glibcxx_function_requires(_ConvertibleConcept<_Tp,
94 __glibcxx_requires_valid_range(__first, __last);
96 for (; __first != __last; ++__first)
104_GLIBCXX_END_NAMESPACE_VERSION
106_GLIBCXX_BEGIN_NAMESPACE_ALGO
108#if __cplusplus > 201703L
111# define _GLIBCXX_MOVE_IF_20(_E) std::move(_E)
113# define _GLIBCXX_MOVE_IF_20(_E) _E
130 template<
typename _InputIterator,
typename _Tp>
133 accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
136 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
137 __glibcxx_requires_valid_range(__first, __last);
139 for (; __first != __last; ++__first)
140 __init = _GLIBCXX_MOVE_IF_20(__init) + *__first;
157 template<
typename _InputIterator,
typename _Tp,
typename _BinaryOperation>
160 accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
161 _BinaryOperation __binary_op)
164 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
165 __glibcxx_requires_valid_range(__first, __last);
167 for (; __first != __last; ++__first)
168 __init = __binary_op(_GLIBCXX_MOVE_IF_20(__init), *__first);
186 template<
typename _InputIterator1,
typename _InputIterator2,
typename _Tp>
190 _InputIterator2 __first2, _Tp __init)
193 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
194 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
195 __glibcxx_requires_valid_range(__first1, __last1);
197 for (; __first1 != __last1; ++__first1, (void)++__first2)
198 __init = _GLIBCXX_MOVE_IF_20(__init) + (*__first1 * *__first2);
218 template<
typename _InputIterator1,
typename _InputIterator2,
typename _Tp,
219 typename _BinaryOperation1,
typename _BinaryOperation2>
223 _InputIterator2 __first2, _Tp __init,
224 _BinaryOperation1 __binary_op1,
225 _BinaryOperation2 __binary_op2)
228 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
229 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
230 __glibcxx_requires_valid_range(__first1, __last1);
232 for (; __first1 != __last1; ++__first1, (void)++__first2)
233 __init = __binary_op1(_GLIBCXX_MOVE_IF_20(__init),
234 __binary_op2(*__first1, *__first2));
252 template<
typename _InputIterator,
typename _OutputIterator>
256 _OutputIterator __result)
261 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
262 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
264 __glibcxx_requires_valid_range(__first, __last);
266 if (__first == __last)
268 _ValueType __value = *__first;
270 while (++__first != __last)
272 __value = _GLIBCXX_MOVE_IF_20(__value) + *__first;
273 *++__result = __value;
293 template<
typename _InputIterator,
typename _OutputIterator,
294 typename _BinaryOperation>
298 _OutputIterator __result, _BinaryOperation __binary_op)
303 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
304 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
306 __glibcxx_requires_valid_range(__first, __last);
308 if (__first == __last)
310 _ValueType __value = *__first;
312 while (++__first != __last)
314 __value = __binary_op(_GLIBCXX_MOVE_IF_20(__value), *__first);
315 *++__result = __value;
333 template<
typename _InputIterator,
typename _OutputIterator>
337 _InputIterator __last, _OutputIterator __result)
342 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
343 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
345 __glibcxx_requires_valid_range(__first, __last);
347 if (__first == __last)
349 _ValueType __value = *__first;
351 while (++__first != __last)
353 _ValueType __tmp = *__first;
354 *++__result = __tmp - _GLIBCXX_MOVE_IF_20(__value);
355 __value = _GLIBCXX_MOVE(__tmp);
375 template<
typename _InputIterator,
typename _OutputIterator,
376 typename _BinaryOperation>
380 _OutputIterator __result, _BinaryOperation __binary_op)
385 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
386 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
388 __glibcxx_requires_valid_range(__first, __last);
390 if (__first == __last)
392 _ValueType __value = *__first;
394 while (++__first != __last)
396 _ValueType __tmp = *__first;
397 *++__result = __binary_op(__tmp, _GLIBCXX_MOVE_IF_20(__value));
398 __value = _GLIBCXX_MOVE(__tmp);
405#undef _GLIBCXX_MOVE_IF_20
407_GLIBCXX_END_NAMESPACE_ALGO
constexpr _Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
Accumulate values in a range.
constexpr _OutputIterator adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
Return differences between adjacent values.
constexpr void iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
Create a range of sequentially increasing values.
constexpr _OutputIterator partial_sum(_InputIterator __first, _InputIterator __last, _OutputIterator __result)
Return list of partial sums.
constexpr _Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _Tp __init)
Compute inner product of two ranges.
ISO C++ entities toplevel namespace is std.
Traits class for iterators.