aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2006-02-24 19:13:49 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2006-02-24 19:13:49 +0000
commitffe7d885e0372313c064da69a2f6cee229aa0448 (patch)
treebc13bd7d1a6b37817db97204a8932a276fd9db5f
parente26ec0bb0662b03b4b5b96c035abe26f1351a433 (diff)
downloadgcc-ffe7d885e0372313c064da69a2f6cee229aa0448.zip
gcc-ffe7d885e0372313c064da69a2f6cee229aa0448.tar.gz
gcc-ffe7d885e0372313c064da69a2f6cee229aa0448.tar.bz2
array (array<>::swap, assign): Implement.
2006-02-24 Paolo Carlini <pcarlini@suse.de> * include/tr1/array (array<>::swap, assign): Implement. * include/tr1/array (operator==, operator!=, operator<, operator>, operator>=, operator<=, swap, get): Inline. * testsuite/tr1/6_containers/array/requirements/member_swap.cc: New. * testsuite/tr1/6_containers/array/requirements/assign.cc: Likewise. * testsuite/tr1/6_containers/array/specialized_algorithms/swap.cc: Likewise. From-SVN: r111424
-rw-r--r--libstdc++-v3/ChangeLog10
-rw-r--r--libstdc++-v3/include/tr1/array44
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/array/requirements/assign.cc47
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/array/requirements/member_swap.cc49
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/array/specialized_algorithms/swap.cc49
5 files changed, 178 insertions, 21 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index cc8b6b2..66f57c7 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,13 @@
+2006-02-24 Paolo Carlini <pcarlini@suse.de>
+
+ * include/tr1/array (array<>::swap, assign): Implement.
+ * include/tr1/array (operator==, operator!=, operator<,
+ operator>, operator>=, operator<=, swap, get): Inline.
+ * testsuite/tr1/6_containers/array/requirements/member_swap.cc: New.
+ * testsuite/tr1/6_containers/array/requirements/assign.cc: Likewise.
+ * testsuite/tr1/6_containers/array/specialized_algorithms/swap.cc:
+ Likewise.
+
2006-02-23 Benjamin Kosnik <bkoz@redhat.com>
* testsuite/22_locale/codecvt/in/wchar_t/1.cc (test01): Change int
diff --git a/libstdc++-v3/include/tr1/array b/libstdc++-v3/include/tr1/array
index 5f50485..9332efe 100644
--- a/libstdc++-v3/include/tr1/array
+++ b/libstdc++-v3/include/tr1/array
@@ -50,15 +50,15 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
template<typename _Tp, std::size_t _Nm = 1>
struct array
{
- typedef _Tp value_type;
- typedef value_type& reference;
- typedef const value_type& const_reference;
- typedef value_type* iterator;
- typedef const value_type* const_iterator;
- typedef std::size_t size_type;
- typedef std::ptrdiff_t difference_type;
- typedef std::reverse_iterator<iterator> reverse_iterator;
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+ typedef _Tp value_type;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef value_type* iterator;
+ typedef const value_type* const_iterator;
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
// Compile time constant without other dependencies.
enum { _S_index = _Nm };
@@ -69,10 +69,12 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
// No explicit construct/copy/destroy for aggregate type.
void
- assign(const value_type& u);
+ assign(const value_type& __u)
+ { std::fill_n(begin(), size(), __u); }
void
- swap(array&);
+ swap(array& __other)
+ { std::swap_ranges(begin(), end(), __other.begin()); }
// Iterators.
iterator
@@ -169,17 +171,17 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
// Array comparisons.
template<typename _Tp, std::size_t _Nm>
- bool
+ inline bool
operator==(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
{ return std::equal(__one.begin(), __one.end(), __two.begin()); }
template<typename _Tp, std::size_t _Nm>
- bool
+ inline bool
operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
{ return !(__one == __two); }
template<typename _Tp, std::size_t _Nm>
- bool
+ inline bool
operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
{
return std::lexicographical_compare(__a.begin(), __a.end(),
@@ -187,25 +189,25 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
}
template<typename _Tp, std::size_t _Nm>
- bool
+ inline bool
operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
{ return __two < __one; }
template<typename _Tp, std::size_t _Nm>
- bool
+ inline bool
operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
{ return !(__one > __two); }
template<typename _Tp, std::size_t _Nm>
- bool
+ inline bool
operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
{ return !(__one < __two); }
// Specialized algorithms [6.2.2.2].
template<typename _Tp, std::size_t _Nm>
- void
+ inline void
swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
- { swap_ranges(__one.begin(), __one.end(), __two.begin()); }
+ { std::swap_ranges(__one.begin(), __one.end(), __two.begin()); }
// Tuple interface to class template array [6.2.2.5].
template<typename _Tp> class tuple_size;
@@ -220,12 +222,12 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
{ typedef _Tp type; };
template<int _Int, typename _Tp, std::size_t _Nm>
- _Tp&
+ inline _Tp&
get(array<_Tp, _Nm>& __arr)
{ return __arr[_Int]; }
template<int _Int, typename _Tp, std::size_t _Nm>
- const _Tp&
+ inline const _Tp&
get(const array<_Tp, _Nm>& __arr)
{ return __arr[_Int]; }
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/assign.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/assign.cc
new file mode 100644
index 0000000..e65c54e
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/assign.cc
@@ -0,0 +1,47 @@
+// 2006-02-24 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2006 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.
+
+// 6.2.2 Class template array
+
+#include <tr1/array>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ const size_t len = 3;
+ typedef std::tr1::array<int, len> array_type;
+
+ array_type a = { 0, 1, 2 };
+ const int value = 5;
+
+ a.assign(value);
+ VERIFY( a[0] == value );
+ VERIFY( a[1] == value );
+ VERIFY( a[2] == value );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/member_swap.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/member_swap.cc
new file mode 100644
index 0000000..3baa3cb
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/6_containers/array/requirements/member_swap.cc
@@ -0,0 +1,49 @@
+// 2006-02-24 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2006 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.
+
+// 6.2.2 Class template array
+
+#include <tr1/array>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ const size_t len = 5;
+ typedef std::tr1::array<int, len> array_type;
+
+ array_type a = { 0, 1, 2, 3, 4 };
+ const array_type a_ref = a;
+
+ array_type b = { 4, 3, 2, 1, 0 };
+ const array_type b_ref = b;
+
+ a.swap(b);
+ VERIFY( a == b_ref );
+ VERIFY( b == a_ref );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/array/specialized_algorithms/swap.cc b/libstdc++-v3/testsuite/tr1/6_containers/array/specialized_algorithms/swap.cc
new file mode 100644
index 0000000..6ec9968
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/6_containers/array/specialized_algorithms/swap.cc
@@ -0,0 +1,49 @@
+// 2006-02-24 Paolo Carlini <pcarlini@suse.de>
+//
+// Copyright (C) 2006 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.
+
+// 6.2.2.2 array specialized algorithms
+
+#include <tr1/array>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+ bool test __attribute__((unused)) = true;
+
+ const size_t len = 5;
+ typedef std::tr1::array<int, len> array_type;
+
+ array_type a = { 0, 1, 2, 3, 4 };
+ const array_type a_ref = a;
+
+ array_type b = { 4, 3, 2, 1, 0 };
+ const array_type b_ref = b;
+
+ std::tr1::swap(a, b);
+ VERIFY( a == b_ref );
+ VERIFY( b == a_ref );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}