57#define _STL_NUMERIC_H 1
64namespace std _GLIBCXX_VISIBILITY(default)
66_GLIBCXX_BEGIN_NAMESPACE_VERSION
72#if __cplusplus >= 201103L
85 template<
typename _ForwardIterator,
typename _Tp>
88 iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
91 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
93 __glibcxx_function_requires(_ConvertibleConcept<_Tp,
95 __glibcxx_requires_valid_range(__first, __last);
97 for (; __first != __last; ++__first)
105_GLIBCXX_END_NAMESPACE_VERSION
107_GLIBCXX_BEGIN_NAMESPACE_ALGO
109#if __cplusplus > 201703L
112# define _GLIBCXX_MOVE_IF_20(_E) std::move(_E)
114# define _GLIBCXX_MOVE_IF_20(_E) _E
131 template<
typename _InputIterator,
typename _Tp>
134 accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
137 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
138 __glibcxx_requires_valid_range(__first, __last);
140 for (; __first != __last; ++__first)
141 __init = _GLIBCXX_MOVE_IF_20(__init) + *__first;
158 template<
typename _InputIterator,
typename _Tp,
typename _BinaryOperation>
161 accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
162 _BinaryOperation __binary_op)
165 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
166 __glibcxx_requires_valid_range(__first, __last);
168 for (; __first != __last; ++__first)
169 __init = __binary_op(_GLIBCXX_MOVE_IF_20(__init), *__first);
187 template<
typename _InputIterator1,
typename _InputIterator2,
typename _Tp>
191 _InputIterator2 __first2, _Tp __init)
194 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
195 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
196 __glibcxx_requires_valid_range(__first1, __last1);
198 for (; __first1 != __last1; ++__first1, (void)++__first2)
199 __init = _GLIBCXX_MOVE_IF_20(__init) + (*__first1 * *__first2);
219 template<
typename _InputIterator1,
typename _InputIterator2,
typename _Tp,
220 typename _BinaryOperation1,
typename _BinaryOperation2>
224 _InputIterator2 __first2, _Tp __init,
225 _BinaryOperation1 __binary_op1,
226 _BinaryOperation2 __binary_op2)
229 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
230 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
231 __glibcxx_requires_valid_range(__first1, __last1);
233 for (; __first1 != __last1; ++__first1, (void)++__first2)
234 __init = __binary_op1(_GLIBCXX_MOVE_IF_20(__init),
235 __binary_op2(*__first1, *__first2));
253 template<
typename _InputIterator,
typename _OutputIterator>
257 _OutputIterator __result)
262 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
263 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
265 __glibcxx_requires_valid_range(__first, __last);
267 if (__first == __last)
269 _ValueType __value = *__first;
271 while (++__first != __last)
273 __value = _GLIBCXX_MOVE_IF_20(__value) + *__first;
274 *++__result = __value;
294 template<
typename _InputIterator,
typename _OutputIterator,
295 typename _BinaryOperation>
299 _OutputIterator __result, _BinaryOperation __binary_op)
304 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
305 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
307 __glibcxx_requires_valid_range(__first, __last);
309 if (__first == __last)
311 _ValueType __value = *__first;
313 while (++__first != __last)
315 __value = __binary_op(_GLIBCXX_MOVE_IF_20(__value), *__first);
316 *++__result = __value;
335 template<
typename _InputIterator,
typename _OutputIterator>
339 _InputIterator __last, _OutputIterator __result)
344 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
345 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
347 __glibcxx_requires_valid_range(__first, __last);
349 if (__first == __last)
351 _ValueType __value = *__first;
353 while (++__first != __last)
355 _ValueType __tmp = *__first;
356 *++__result = __tmp - _GLIBCXX_MOVE_IF_20(__value);
357 __value = _GLIBCXX_MOVE(__tmp);
378 template<
typename _InputIterator,
typename _OutputIterator,
379 typename _BinaryOperation>
383 _OutputIterator __result, _BinaryOperation __binary_op)
388 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
389 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
391 __glibcxx_requires_valid_range(__first, __last);
393 if (__first == __last)
395 _ValueType __value = *__first;
397 while (++__first != __last)
399 _ValueType __tmp = *__first;
400 *++__result = __binary_op(__tmp, _GLIBCXX_MOVE_IF_20(__value));
401 __value = _GLIBCXX_MOVE(__tmp);
408#undef _GLIBCXX_MOVE_IF_20
410_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 _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.