summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2008-06-27 10:47:27 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2008-06-27 10:47:27 +0000
commit6e48a8d02f9025fb6de6a08b01d24c62ff658100 (patch)
tree7268855da81f3e3081198a9735a8844ca3bbd850
parentdeb74db2d98b0e59d053e268412fc6a49f6a7e7f (diff)
downloadgcc-6e48a8d02f9025fb6de6a08b01d24c62ff658100.tar.gz
2008-06-27 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/stl_numeric.h (iota): Add in C++0x mode. * testsuite/util/testsuite_character.h (pod_int): Add operator++ in C++0x mode. * testsuite/util/testsuite_api.h (NonDefaultConstructible): Likewise. * testsuite/26_numerics/iota/1.cc: New. * testsuite/26_numerics/iota/requirements/explicit_instantiation/ 2.cc: Likewise. * testsuite/26_numerics/iota/requirements/explicit_instantiation/ pod.cc: Likewise. * include/ext/algorithm: Do not fiddle with the legacy headers. * testsuite/26_numerics/partial_sum/1.cc: Minor changes, comments, style. * testsuite/26_numerics/accumulate/1.cc: Likewise. * testsuite/26_numerics/adjacent_difference/1.cc: Likewise. * testsuite/26_numerics/inner_product/1.cc: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@137174 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libstdc++-v3/ChangeLog20
-rw-r--r--libstdc++-v3/include/bits/stl_numeric.h41
-rw-r--r--libstdc++-v3/include/ext/algorithm7
-rw-r--r--libstdc++-v3/testsuite/26_numerics/accumulate/1.cc9
-rw-r--r--libstdc++-v3/testsuite/26_numerics/adjacent_difference/1.cc8
-rw-r--r--libstdc++-v3/testsuite/26_numerics/inner_product/1.cc9
-rw-r--r--libstdc++-v3/testsuite/26_numerics/iota/1.cc49
-rw-r--r--libstdc++-v3/testsuite/26_numerics/iota/requirements/explicit_instantiation/2.cc42
-rw-r--r--libstdc++-v3/testsuite/26_numerics/iota/requirements/explicit_instantiation/pod.cc42
-rw-r--r--libstdc++-v3/testsuite/26_numerics/partial_sum/1.cc4
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_api.h7
-rw-r--r--libstdc++-v3/testsuite/util/testsuite_character.h15
12 files changed, 229 insertions, 24 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 87331b9b56e..b5191e8385a 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,23 @@
+2008-06-27 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * include/bits/stl_numeric.h (iota): Add in C++0x mode.
+ * testsuite/util/testsuite_character.h (pod_int): Add operator++
+ in C++0x mode.
+ * testsuite/util/testsuite_api.h (NonDefaultConstructible): Likewise.
+ * testsuite/26_numerics/iota/1.cc: New.
+ * testsuite/26_numerics/iota/requirements/explicit_instantiation/
+ 2.cc: Likewise.
+ * testsuite/26_numerics/iota/requirements/explicit_instantiation/
+ pod.cc: Likewise.
+
+ * include/ext/algorithm: Do not fiddle with the legacy headers.
+
+ * testsuite/26_numerics/partial_sum/1.cc: Minor changes, comments,
+ style.
+ * testsuite/26_numerics/accumulate/1.cc: Likewise.
+ * testsuite/26_numerics/adjacent_difference/1.cc: Likewise.
+ * testsuite/26_numerics/inner_product/1.cc: Likewise.
+
2008-06-26 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/stl_algo.h (partition_copy): Add in C++0x mode.
diff --git a/libstdc++-v3/include/bits/stl_numeric.h b/libstdc++-v3/include/bits/stl_numeric.h
index 3940e4aa970..c86122679da 100644
--- a/libstdc++-v3/include/bits/stl_numeric.h
+++ b/libstdc++-v3/include/bits/stl_numeric.h
@@ -1,6 +1,6 @@
// Numeric functions implementation -*- C++ -*-
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -65,6 +65,43 @@
#include <bits/concept_check.h>
#include <debug/debug.h>
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+
+_GLIBCXX_BEGIN_NAMESPACE(std)
+
+ /**
+ * @brief Create a range of sequentially increasing values.
+ *
+ * For each element in the range @p [first,last) assigns @p value and
+ * increments @p value as if by @p ++value.
+ *
+ * @param first Start of range.
+ * @param last End of range.
+ * @param value Starting value.
+ * @return Nothing.
+ */
+ template<typename _ForwardIterator, typename _Tp>
+ void
+ iota(_ForwardIterator __first, _ForwardIterator __last, _Tp __value)
+ {
+ // concept requirements
+ __glibcxx_function_requires(_Mutable_ForwardIteratorConcept<
+ _ForwardIterator>)
+ __glibcxx_function_requires(_ConvertibleConcept<_Tp,
+ typename iterator_traits<_ForwardIterator>::value_type>)
+ __glibcxx_requires_valid_range(__first, __last);
+
+ for (; __first != __last; ++__first)
+ {
+ *__first = __value;
+ ++__value;
+ }
+ }
+
+_GLIBCXX_END_NAMESPACE
+
+#endif
+
_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_P)
/**
@@ -164,7 +201,7 @@ _GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_P)
* @return The final inner product.
*/
template<typename _InputIterator1, typename _InputIterator2, typename _Tp,
- typename _BinaryOperation1, typename _BinaryOperation2>
+ typename _BinaryOperation1, typename _BinaryOperation2>
inline _Tp
inner_product(_InputIterator1 __first1, _InputIterator1 __last1,
_InputIterator2 __first2, _Tp __init,
diff --git a/libstdc++-v3/include/ext/algorithm b/libstdc++-v3/include/ext/algorithm
index 5a24b7e6f48..2af2cb1cb36 100644
--- a/libstdc++-v3/include/ext/algorithm
+++ b/libstdc++-v3/include/ext/algorithm
@@ -1,6 +1,6 @@
// Algorithm extensions -*- C++ -*-
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
@@ -428,10 +428,6 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
__out_last - __out_first);
}
-#ifdef __GXX_EXPERIMENTAL_CXX0X__
- using std::is_heap;
- using std::is_sorted;
-#else
/**
* This is an SGI extension.
* @ingroup SGIextensions
@@ -527,7 +523,6 @@ _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
return false;
return true;
}
-#endif
_GLIBCXX_END_NAMESPACE
diff --git a/libstdc++-v3/testsuite/26_numerics/accumulate/1.cc b/libstdc++-v3/testsuite/26_numerics/accumulate/1.cc
index 046532debef..22a67fe8fea 100644
--- a/libstdc++-v3/testsuite/26_numerics/accumulate/1.cc
+++ b/libstdc++-v3/testsuite/26_numerics/accumulate/1.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2001, 2004 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+// 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
@@ -48,7 +49,7 @@ test02()
int
main()
{
- test01();
- test02();
- return 0;
+ test01();
+ test02();
+ return 0;
}
diff --git a/libstdc++-v3/testsuite/26_numerics/adjacent_difference/1.cc b/libstdc++-v3/testsuite/26_numerics/adjacent_difference/1.cc
index 5501f3f9fa6..e53e279cf27 100644
--- a/libstdc++-v3/testsuite/26_numerics/adjacent_difference/1.cc
+++ b/libstdc++-v3/testsuite/26_numerics/adjacent_difference/1.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2001, 2004 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+// 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
@@ -16,7 +17,6 @@
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
// USA.
-// 26.4.3 [lib.partial.sum]
// 26.4.4 [lib.adjacent.difference]
#include <algorithm>
@@ -41,6 +41,6 @@ test01()
int
main()
{
- test01();
- return 0;
+ test01();
+ return 0;
}
diff --git a/libstdc++-v3/testsuite/26_numerics/inner_product/1.cc b/libstdc++-v3/testsuite/26_numerics/inner_product/1.cc
index d63c1d91099..6c44fae3c88 100644
--- a/libstdc++-v3/testsuite/26_numerics/inner_product/1.cc
+++ b/libstdc++-v3/testsuite/26_numerics/inner_product/1.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2001, 2004 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+// 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
@@ -50,7 +51,7 @@ test02()
int
main()
{
- test01();
- test02();
- return 0;
+ test01();
+ test02();
+ return 0;
}
diff --git a/libstdc++-v3/testsuite/26_numerics/iota/1.cc b/libstdc++-v3/testsuite/26_numerics/iota/1.cc
new file mode 100644
index 00000000000..2c747c13e96
--- /dev/null
+++ b/libstdc++-v3/testsuite/26_numerics/iota/1.cc
@@ -0,0 +1,49 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2008-06-27 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+#include <numeric>
+#include <algorithm>
+#include <testsuite_hooks.h>
+
+int A[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
+int B[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
+int C[] = {-9, -8, -7, -6, -5, -4, -3, -2, -1};
+const int N = sizeof(A) / sizeof(int);
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ std::iota(A, A + N, 1);
+ VERIFY( std::equal(A, A + N, B) );
+
+ std::iota(A, A + N, -9);
+ VERIFY( std::equal(A, A + N, C) );
+}
+
+int
+main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/26_numerics/iota/requirements/explicit_instantiation/2.cc b/libstdc++-v3/testsuite/26_numerics/iota/requirements/explicit_instantiation/2.cc
new file mode 100644
index 00000000000..fd0eba869a6
--- /dev/null
+++ b/libstdc++-v3/testsuite/26_numerics/iota/requirements/explicit_instantiation/2.cc
@@ -0,0 +1,42 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// 2008-06-27 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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.
+
+#include <numeric>
+#include <testsuite_api.h>
+
+namespace std
+{
+ typedef __gnu_test::NonDefaultConstructible value_type;
+ typedef value_type* iterator_type;
+
+ template void iota(iterator_type, iterator_type, value_type);
+}
diff --git a/libstdc++-v3/testsuite/26_numerics/iota/requirements/explicit_instantiation/pod.cc b/libstdc++-v3/testsuite/26_numerics/iota/requirements/explicit_instantiation/pod.cc
new file mode 100644
index 00000000000..a24ac95c894
--- /dev/null
+++ b/libstdc++-v3/testsuite/26_numerics/iota/requirements/explicit_instantiation/pod.cc
@@ -0,0 +1,42 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++0x" }
+
+// 2008-06-27 Paolo Carlini <paolo.carlini@oracle.com>
+
+// Copyright (C) 2008 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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// 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.
+
+#include <numeric>
+#include <testsuite_character.h>
+
+namespace std
+{
+ typedef __gnu_test::pod_int value_type;
+ typedef value_type* iterator_type;
+
+ template void iota(iterator_type, iterator_type, value_type);
+}
diff --git a/libstdc++-v3/testsuite/26_numerics/partial_sum/1.cc b/libstdc++-v3/testsuite/26_numerics/partial_sum/1.cc
index ac336916656..c972b31651a 100644
--- a/libstdc++-v3/testsuite/26_numerics/partial_sum/1.cc
+++ b/libstdc++-v3/testsuite/26_numerics/partial_sum/1.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2001, 2004 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+// 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
@@ -17,7 +18,6 @@
// USA.
// 26.4.3 [lib.partial.sum]
-// 26.4.4 [lib.adjacent.difference]
#include <algorithm>
#include <numeric>
diff --git a/libstdc++-v3/testsuite/util/testsuite_api.h b/libstdc++-v3/testsuite/util/testsuite_api.h
index 658e2ad168c..cbb606c42a8 100644
--- a/libstdc++-v3/testsuite/util/testsuite_api.h
+++ b/libstdc++-v3/testsuite/util/testsuite_api.h
@@ -84,6 +84,13 @@ namespace __gnu_test
{
NonDefaultConstructible(int) { }
NonDefaultConstructible(const NonDefaultConstructible&) { }
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ // For std::iota.
+ NonDefaultConstructible&
+ operator++()
+ { return *this; }
+#endif
};
// See: 20.1.1 Template argument requirements.
diff --git a/libstdc++-v3/testsuite/util/testsuite_character.h b/libstdc++-v3/testsuite/util/testsuite_character.h
index e9dde65c2f3..2aa0bc72e53 100644
--- a/libstdc++-v3/testsuite/util/testsuite_character.h
+++ b/libstdc++-v3/testsuite/util/testsuite_character.h
@@ -3,7 +3,8 @@
// Testing character type and state type with char_traits and codecvt
// specializations for the C++ library testsuite.
//
-// Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+// Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
+// 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
@@ -44,8 +45,18 @@ namespace __gnu_test
struct pod_int
{
int value;
+
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ // For std::iota.
+ pod_int&
+ operator++()
+ {
+ ++value;
+ return *this;
+ }
+#endif
};
-
+
// For 20.1 requirements for instantiable type: equality comparable
// and less than comparable.
inline bool