aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/include/bits/stl_numeric.h
diff options
context:
space:
mode:
Diffstat (limited to 'libstdc++-v3/include/bits/stl_numeric.h')
-rw-r--r--libstdc++-v3/include/bits/stl_numeric.h97
1 files changed, 75 insertions, 22 deletions
diff --git a/libstdc++-v3/include/bits/stl_numeric.h b/libstdc++-v3/include/bits/stl_numeric.h
index 0b1742bc9d9..500a2653c6b 100644
--- a/libstdc++-v3/include/bits/stl_numeric.h
+++ b/libstdc++-v3/include/bits/stl_numeric.h
@@ -1,3 +1,32 @@
+// Numeric functions implementation -*- C++ -*-
+
+// Copyright (C) 2001 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+// As a special exception, you may use this file as part of a free software
+// library without restriction. Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License. This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
/*
*
* Copyright (c) 1994
@@ -32,12 +61,15 @@
#ifndef _CPP_BITS_STL_NUMERIC_H
#define _CPP_BITS_STL_NUMERIC_H 1
-__STL_BEGIN_NAMESPACE
+namespace std
+{
template <class _InputIterator, class _Tp>
_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
{
- __STL_REQUIRES(_InputIterator, _InputIterator);
+ // concept requirements
+ __glibcpp_function_requires(_InputIteratorConcept<_InputIterator>);
+
for ( ; __first != __last; ++__first)
__init = __init + *__first;
return __init;
@@ -47,7 +79,9 @@ template <class _InputIterator, class _Tp, class _BinaryOperation>
_Tp accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
_BinaryOperation __binary_op)
{
- __STL_REQUIRES(_InputIterator, _InputIterator);
+ // concept requirements
+ __glibcpp_function_requires(_InputIteratorConcept<_InputIterator>);
+
for ( ; __first != __last; ++__first)
__init = __binary_op(__init, *__first);
return __init;
@@ -57,8 +91,10 @@ template <class _InputIterator1, class _InputIterator2, class _Tp>
_Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _Tp __init)
{
- __STL_REQUIRES(_InputIterator2, _InputIterator);
- __STL_REQUIRES(_InputIterator2, _InputIterator);
+ // concept requirements
+ __glibcpp_function_requires(_InputIteratorConcept<_InputIterator1>);
+ __glibcpp_function_requires(_InputIteratorConcept<_InputIterator2>);
+
for ( ; __first1 != __last1; ++__first1, ++__first2)
__init = __init + (*__first1 * *__first2);
return __init;
@@ -71,8 +107,10 @@ _Tp inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
_BinaryOperation1 __binary_op1,
_BinaryOperation2 __binary_op2)
{
- __STL_REQUIRES(_InputIterator2, _InputIterator);
- __STL_REQUIRES(_InputIterator2, _InputIterator);
+ // concept requirements
+ __glibcpp_function_requires(_InputIteratorConcept<_InputIterator1>);
+ __glibcpp_function_requires(_InputIteratorConcept<_InputIterator2>);
+
for ( ; __first1 != __last1; ++__first1, ++__first2)
__init = __binary_op1(__init, __binary_op2(*__first1, *__first2));
return __init;
@@ -96,11 +134,14 @@ _OutputIterator
partial_sum(_InputIterator __first, _InputIterator __last,
_OutputIterator __result)
{
- __STL_REQUIRES(_InputIterator, _InputIterator);
- __STL_REQUIRES(_OutputIterator, _OutputIterator);
+ // concept requirements
+ __glibcpp_function_requires(_InputIteratorConcept<_InputIterator>);
+ __glibcpp_function_requires(_OutputIteratorConcept<_OutputIterator,
+ typename iterator_traits<_InputIterator>::value_type>);
+
if (__first == __last) return __result;
*__result = *__first;
- return __partial_sum(__first, __last, __result, __VALUE_TYPE(__first));
+ return __partial_sum(__first, __last, __result, __value_type(__first));
}
template <class _InputIterator, class _OutputIterator, class _Tp,
@@ -122,11 +163,14 @@ _OutputIterator
partial_sum(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _BinaryOperation __binary_op)
{
- __STL_REQUIRES(_InputIterator, _InputIterator);
- __STL_REQUIRES(_OutputIterator, _OutputIterator);
+ // concept requirements
+ __glibcpp_function_requires(_InputIteratorConcept<_InputIterator>);
+ __glibcpp_function_requires(_OutputIteratorConcept<_OutputIterator,
+ typename iterator_traits<_InputIterator>::value_type>);
+
if (__first == __last) return __result;
*__result = *__first;
- return __partial_sum(__first, __last, __result, __VALUE_TYPE(__first),
+ return __partial_sum(__first, __last, __result, __value_type(__first),
__binary_op);
}
@@ -149,12 +193,15 @@ _OutputIterator
adjacent_difference(_InputIterator __first,
_InputIterator __last, _OutputIterator __result)
{
- __STL_REQUIRES(_InputIterator, _InputIterator);
- __STL_REQUIRES(_OutputIterator, _OutputIterator);
+ // concept requirements
+ __glibcpp_function_requires(_InputIteratorConcept<_InputIterator>);
+ __glibcpp_function_requires(_OutputIteratorConcept<_OutputIterator,
+ typename iterator_traits<_InputIterator>::value_type>);
+
if (__first == __last) return __result;
*__result = *__first;
return __adjacent_difference(__first, __last, __result,
- __VALUE_TYPE(__first));
+ __value_type(__first));
}
template <class _InputIterator, class _OutputIterator, class _Tp,
@@ -177,12 +224,15 @@ _OutputIterator
adjacent_difference(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _BinaryOperation __binary_op)
{
- __STL_REQUIRES(_InputIterator, _InputIterator);
- __STL_REQUIRES(_OutputIterator, _OutputIterator);
+ // concept requirements
+ __glibcpp_function_requires(_InputIteratorConcept<_InputIterator>);
+ __glibcpp_function_requires(_OutputIteratorConcept<_OutputIterator,
+ typename iterator_traits<_InputIterator>::value_type>);
+
if (__first == __last) return __result;
*__result = *__first;
return __adjacent_difference(__first, __last, __result,
- __VALUE_TYPE(__first),
+ __value_type(__first),
__binary_op);
}
@@ -240,13 +290,16 @@ template <class _ForwardIter, class _Tp>
void
iota(_ForwardIter __first, _ForwardIter __last, _Tp __value)
{
- __STL_REQUIRES(_ForwardIter, _Mutable_ForwardIterator);
- __STL_CONVERTIBLE(_Tp, typename iterator_traits<_ForwardIter>::value_type);
+ // concept requirements
+ __glibcpp_function_requires(_Mutable_ForwardIteratorConcept<_ForwardIter>);
+ __glibcpp_function_requires(_ConvertibleConcept<_Tp,
+ typename iterator_traits<_ForwardIter>::value_type>);
+
while (__first != __last)
*__first++ = __value++;
}
-__STL_END_NAMESPACE
+} // namespace std
#endif /* _CPP_BITS_STL_NUMERIC_H */