57 #ifndef _STL_NUMERIC_H
58 #define _STL_NUMERIC_H 1
64 #ifdef __GXX_EXPERIMENTAL_CXX0X__
66 namespace std _GLIBCXX_VISIBILITY(default)
68 _GLIBCXX_BEGIN_NAMESPACE_VERSION
81 template<
typename _ForwardIterator,
typename _Tp>
83 iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
86 __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
88 __glibcxx_function_requires(_ConvertibleConcept<_Tp,
89 typename iterator_traits<_ForwardIterator>::value_type>)
90 __glibcxx_requires_valid_range(__first, __last);
92 for (; __first != __last; ++__first)
99 _GLIBCXX_END_NAMESPACE_VERSION
104 namespace std _GLIBCXX_VISIBILITY(default)
106 _GLIBCXX_BEGIN_NAMESPACE_ALGO
119 template<
typename _InputIterator,
typename _Tp>
121 accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
124 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
125 __glibcxx_requires_valid_range(__first, __last);
127 for (; __first != __last; ++__first)
128 __init = __init + *__first;
145 template<
typename _InputIterator,
typename _Tp,
typename _BinaryOperation>
147 accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
148 _BinaryOperation __binary_op)
151 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
152 __glibcxx_requires_valid_range(__first, __last);
154 for (; __first != __last; ++__first)
155 __init = __binary_op(__init, *__first);
173 template<
typename _InputIterator1,
typename _InputIterator2,
typename _Tp>
176 _InputIterator2 __first2, _Tp __init)
179 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
180 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
181 __glibcxx_requires_valid_range(__first1, __last1);
183 for (; __first1 != __last1; ++__first1, ++__first2)
184 __init = __init + (*__first1 * *__first2);
204 template<
typename _InputIterator1,
typename _InputIterator2,
typename _Tp,
205 typename _BinaryOperation1,
typename _BinaryOperation2>
208 _InputIterator2 __first2, _Tp __init,
209 _BinaryOperation1 __binary_op1,
210 _BinaryOperation2 __binary_op2)
213 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator1>)
214 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator2>)
215 __glibcxx_requires_valid_range(__first1, __last1);
217 for (; __first1 != __last1; ++__first1, ++__first2)
218 __init = __binary_op1(__init, __binary_op2(*__first1, *__first2));
236 template<
typename _InputIterator,
typename _OutputIterator>
239 _OutputIterator __result)
241 typedef typename iterator_traits<_InputIterator>::value_type _ValueType;
244 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
245 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
247 __glibcxx_requires_valid_range(__first, __last);
249 if (__first == __last)
251 _ValueType __value = *__first;
253 while (++__first != __last)
255 __value = __value + *__first;
256 *++__result = __value;
276 template<
typename _InputIterator,
typename _OutputIterator,
277 typename _BinaryOperation>
280 _OutputIterator __result, _BinaryOperation __binary_op)
282 typedef typename iterator_traits<_InputIterator>::value_type _ValueType;
285 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
286 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
288 __glibcxx_requires_valid_range(__first, __last);
290 if (__first == __last)
292 _ValueType __value = *__first;
294 while (++__first != __last)
296 __value = __binary_op(__value, *__first);
297 *++__result = __value;
316 template<
typename _InputIterator,
typename _OutputIterator>
319 _InputIterator __last, _OutputIterator __result)
321 typedef typename iterator_traits<_InputIterator>::value_type _ValueType;
324 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
325 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
327 __glibcxx_requires_valid_range(__first, __last);
329 if (__first == __last)
331 _ValueType __value = *__first;
333 while (++__first != __last)
335 _ValueType __tmp = *__first;
336 *++__result = __tmp - __value;
337 __value = _GLIBCXX_MOVE(__tmp);
357 template<
typename _InputIterator,
typename _OutputIterator,
358 typename _BinaryOperation>
361 _OutputIterator __result, _BinaryOperation __binary_op)
363 typedef typename iterator_traits<_InputIterator>::value_type _ValueType;
366 __glibcxx_function_requires(_InputIteratorConcept<_InputIterator>)
367 __glibcxx_function_requires(_OutputIteratorConcept<_OutputIterator,
369 __glibcxx_requires_valid_range(__first, __last);
371 if (__first == __last)
373 _ValueType __value = *__first;
375 while (++__first != __last)
377 _ValueType __tmp = *__first;
378 *++__result = __binary_op(__tmp, __value);
379 __value = _GLIBCXX_MOVE(__tmp);
384 _GLIBCXX_END_NAMESPACE_ALGO