aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2012-11-07 00:42:19 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2012-11-07 00:42:19 +0000
commit0611ce440a4e5a460b185cb2b64684bd51f94d51 (patch)
tree741a30909f4921e02c019708ac9d7d15e93ecafe /libstdc++-v3
parentbff0e5295af23c7947f7b4804a72e86aeca0ce56 (diff)
downloadgcc-0611ce440a4e5a460b185cb2b64684bd51f94d51.zip
gcc-0611ce440a4e5a460b185cb2b64684bd51f94d51.tar.gz
gcc-0611ce440a4e5a460b185cb2b64684bd51f94d51.tar.bz2
re PR libstdc++/51850 (debug mode for std::array and tr1::array)
2012-11-06 Paolo Carlini <paolo.carlini@oracle.com> PR libstdc++/51850 * include/debug/array: New, debug-mode implementation. * include/profile/array: New. * include/std/array: Adjust. * include/std/tuple: Just include <array>. * include/Makefile.am: Add. * include/Makefile.in: Regenerate. * testsuite/23_containers/array/debug/front1_neg.cc: New. * testsuite/23_containers/array/debug/ square_brackets_operator1_neg.cc: Likewise. * testsuite/23_containers/array/debug/front2_neg.cc: Likewise. * testsuite/23_containers/array/debug/ square_brackets_operator2_neg.cc: Likewise. * testsuite/23_containers/array/debug/back1_neg.cc: Likewise. * testsuite/23_containers/array/debug/back2_neg.cc: Likewise. * testsuite/23_containers/array/tuple_interface/get_neg.cc: Tweak to run only in normal-mode. * testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc: Likewise. * testsuite/23_containers/array/tuple_interface/get_debug_neg.cc: New. * testsuite/23_containers/array/tuple_interface/ tuple_element_debug_neg.cc: Likewise. From-SVN: r193278
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog25
-rw-r--r--libstdc++-v3/include/Makefile.am2
-rw-r--r--libstdc++-v3/include/Makefile.in2
-rw-r--r--libstdc++-v3/include/debug/array321
-rw-r--r--libstdc++-v3/include/profile/array273
-rw-r--r--libstdc++-v3/include/std/array26
-rw-r--r--libstdc++-v3/include/std/tuple16
-rw-r--r--libstdc++-v3/testsuite/23_containers/array/debug/back1_neg.cc34
-rw-r--r--libstdc++-v3/testsuite/23_containers/array/debug/back2_neg.cc34
-rw-r--r--libstdc++-v3/testsuite/23_containers/array/debug/front1_neg.cc34
-rw-r--r--libstdc++-v3/testsuite/23_containers/array/debug/front2_neg.cc34
-rw-r--r--libstdc++-v3/testsuite/23_containers/array/debug/square_brackets_operator1_neg.cc34
-rw-r--r--libstdc++-v3/testsuite/23_containers/array/debug/square_brackets_operator2_neg.cc34
-rw-r--r--libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_debug_neg.cc33
-rw-r--r--libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc7
-rw-r--r--libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_debug_neg.cc26
-rw-r--r--libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc3
17 files changed, 912 insertions, 26 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index d324c32..184efed 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,28 @@
+2012-11-06 Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR libstdc++/51850
+ * include/debug/array: New, debug-mode implementation.
+ * include/profile/array: New.
+ * include/std/array: Adjust.
+ * include/std/tuple: Just include <array>.
+ * include/Makefile.am: Add.
+ * include/Makefile.in: Regenerate.
+ * testsuite/23_containers/array/debug/front1_neg.cc: New.
+ * testsuite/23_containers/array/debug/
+ square_brackets_operator1_neg.cc: Likewise.
+ * testsuite/23_containers/array/debug/front2_neg.cc: Likewise.
+ * testsuite/23_containers/array/debug/
+ square_brackets_operator2_neg.cc: Likewise.
+ * testsuite/23_containers/array/debug/back1_neg.cc: Likewise.
+ * testsuite/23_containers/array/debug/back2_neg.cc: Likewise.
+ * testsuite/23_containers/array/tuple_interface/get_neg.cc: Tweak
+ to run only in normal-mode.
+ * testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc:
+ Likewise.
+ * testsuite/23_containers/array/tuple_interface/get_debug_neg.cc: New.
+ * testsuite/23_containers/array/tuple_interface/
+ tuple_element_debug_neg.cc: Likewise.
+
2012-11-06 Jonathan Wakely <jwakely.gcc@gmail.com>
* testsuite/20_util/shared_ptr/cons/55123.cc: Remove duplicate
diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index c2487d3..723fc72 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -705,6 +705,7 @@ endif
debug_srcdir = ${glibcxx_srcdir}/include/debug
debug_builddir = ./debug
debug_headers = \
+ ${debug_srcdir}/array \
${debug_srcdir}/bitset \
${debug_srcdir}/debug.h \
${debug_srcdir}/deque \
@@ -786,6 +787,7 @@ parallel_headers = \
profile_srcdir = ${glibcxx_srcdir}/include/profile
profile_builddir = ./profile
profile_headers = \
+ ${profile_srcdir}/array \
${profile_srcdir}/base.h \
${profile_srcdir}/unordered_map \
${profile_srcdir}/unordered_set \
diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in
index 666ed19..0b4e742 100644
--- a/libstdc++-v3/include/Makefile.in
+++ b/libstdc++-v3/include/Makefile.in
@@ -958,6 +958,7 @@ c_compatibility_builddir = .
debug_srcdir = ${glibcxx_srcdir}/include/debug
debug_builddir = ./debug
debug_headers = \
+ ${debug_srcdir}/array \
${debug_srcdir}/bitset \
${debug_srcdir}/debug.h \
${debug_srcdir}/deque \
@@ -1041,6 +1042,7 @@ parallel_headers = \
profile_srcdir = ${glibcxx_srcdir}/include/profile
profile_builddir = ./profile
profile_headers = \
+ ${profile_srcdir}/array \
${profile_srcdir}/base.h \
${profile_srcdir}/unordered_map \
${profile_srcdir}/unordered_set \
diff --git a/libstdc++-v3/include/debug/array b/libstdc++-v3/include/debug/array
new file mode 100644
index 0000000..1cde4e2
--- /dev/null
+++ b/libstdc++-v3/include/debug/array
@@ -0,0 +1,321 @@
+// Debugging array implementation -*- C++ -*-
+
+// Copyright (C) 2012 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 3, 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.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+/** @file debug/array
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_DEBUG_ARRAY
+#define _GLIBCXX_DEBUG_ARRAY 1
+
+#pragma GCC system_header
+
+#include <debug/safe_sequence.h>
+
+#ifndef _GLIBCXX_THROW_OR_ABORT
+# if __EXCEPTIONS
+# define _GLIBCXX_THROW_OR_ABORT(_Exc) (throw (_Exc))
+# else
+# define _GLIBCXX_THROW_OR_ABORT(_Exc) (__builtin_abort())
+# endif
+#endif
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace __debug
+{
+ template<typename _Tp, std::size_t _Nm>
+ struct array
+ {
+ typedef _Tp value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ 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;
+
+ // Support for zero-sized arrays mandatory.
+ typedef _GLIBCXX_STD_C::__array_traits<_Tp, _Nm> _AT_Type;
+ typename _AT_Type::_Type _M_elems;
+
+ template<std::size_t _Size>
+ struct _Array_check_subscript
+ {
+ std::size_t size() { return _Size; }
+
+ _Array_check_subscript(std::size_t __index)
+ { __glibcxx_check_subscript(__index); }
+ };
+
+ template<std::size_t _Size>
+ struct _Array_check_nonempty
+ {
+ bool empty() { return _Size == 0; }
+
+ _Array_check_nonempty()
+ { __glibcxx_check_nonempty(); }
+ };
+
+ // No explicit construct/copy/destroy for aggregate type.
+
+ // DR 776.
+ void
+ fill(const value_type& __u)
+ { std::fill_n(begin(), size(), __u); }
+
+ void
+ swap(array& __other)
+ noexcept(noexcept(swap(std::declval<_Tp&>(), std::declval<_Tp&>())))
+ { std::swap_ranges(begin(), end(), __other.begin()); }
+
+ // Iterators.
+ iterator
+ begin() noexcept
+ { return iterator(data()); }
+
+ const_iterator
+ begin() const noexcept
+ { return const_iterator(data()); }
+
+ iterator
+ end() noexcept
+ { return iterator(data() + _Nm); }
+
+ const_iterator
+ end() const noexcept
+ { return const_iterator(data() + _Nm); }
+
+ reverse_iterator
+ rbegin() noexcept
+ { return reverse_iterator(end()); }
+
+ const_reverse_iterator
+ rbegin() const noexcept
+ { return const_reverse_iterator(end()); }
+
+ reverse_iterator
+ rend() noexcept
+ { return reverse_iterator(begin()); }
+
+ const_reverse_iterator
+ rend() const noexcept
+ { return const_reverse_iterator(begin()); }
+
+ const_iterator
+ cbegin() const noexcept
+ { return const_iterator(data()); }
+
+ const_iterator
+ cend() const noexcept
+ { return const_iterator(data() + _Nm); }
+
+ const_reverse_iterator
+ crbegin() const noexcept
+ { return const_reverse_iterator(end()); }
+
+ const_reverse_iterator
+ crend() const noexcept
+ { return const_reverse_iterator(begin()); }
+
+ // Capacity.
+ constexpr size_type
+ size() const noexcept { return _Nm; }
+
+ constexpr size_type
+ max_size() const noexcept { return _Nm; }
+
+ constexpr bool
+ empty() const noexcept { return size() == 0; }
+
+ // Element access.
+ reference
+ operator[](size_type __n)
+ {
+ __glibcxx_check_subscript(__n);
+ return _AT_Type::_S_ref(_M_elems, __n);
+ }
+
+ constexpr const_reference
+ operator[](size_type __n) const noexcept
+ {
+ return __n < _Nm ? _AT_Type::_S_ref(_M_elems, __n)
+ : (_GLIBCXX_THROW_OR_ABORT (_Array_check_subscript<_Nm>(__n)),
+ _AT_Type::_S_ref(_M_elems, 0));
+ }
+
+ reference
+ at(size_type __n)
+ {
+ if (__n >= _Nm)
+ std::__throw_out_of_range(__N("array::at"));
+ return _AT_Type::_S_ref(_M_elems, __n);
+ }
+
+ constexpr const_reference
+ at(size_type __n) const
+ {
+ // Result of conditional expression must be an lvalue so use
+ // boolean ? lvalue : (throw-expr, lvalue)
+ return __n < _Nm ? _AT_Type::_S_ref(_M_elems, __n)
+ : (std::__throw_out_of_range(__N("array::at")),
+ _AT_Type::_S_ref(_M_elems, 0));
+ }
+
+ reference
+ front()
+ {
+ __glibcxx_check_nonempty();
+ return *begin();
+ }
+
+ constexpr const_reference
+ front() const
+ {
+ return _Nm ? _AT_Type::_S_ref(_M_elems, 0)
+ : (_GLIBCXX_THROW_OR_ABORT (_Array_check_nonempty<_Nm>()),
+ _AT_Type::_S_ref(_M_elems, 0));
+ }
+
+ reference
+ back()
+ {
+ __glibcxx_check_nonempty();
+ return _Nm ? *(end() - 1) : *end();
+ }
+
+ constexpr const_reference
+ back() const
+ {
+ return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1)
+ : (_GLIBCXX_THROW_OR_ABORT (_Array_check_nonempty<_Nm>()),
+ _AT_Type::_S_ref(_M_elems, 0));
+ }
+
+ pointer
+ data() noexcept
+ { return std::__addressof(_AT_Type::_S_ref(_M_elems, 0)); }
+
+ const_pointer
+ data() const noexcept
+ { return std::__addressof(_AT_Type::_S_ref(_M_elems, 0)); }
+ };
+
+ // Array comparisons.
+ template<typename _Tp, std::size_t _Nm>
+ 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>
+ inline bool
+ operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
+ { return !(__one == __two); }
+
+ template<typename _Tp, std::size_t _Nm>
+ inline bool
+ operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
+ {
+ return std::lexicographical_compare(__a.begin(), __a.end(),
+ __b.begin(), __b.end());
+ }
+
+ template<typename _Tp, std::size_t _Nm>
+ inline bool
+ operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
+ { return __two < __one; }
+
+ template<typename _Tp, std::size_t _Nm>
+ inline bool
+ operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
+ { return !(__one > __two); }
+
+ template<typename _Tp, std::size_t _Nm>
+ inline bool
+ operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
+ { return !(__one < __two); }
+
+ // Specialized algorithms.
+ template<typename _Tp, std::size_t _Nm>
+ inline void
+ swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
+ noexcept(noexcept(__one.swap(__two)))
+ { __one.swap(__two); }
+
+ template<std::size_t _Int, typename _Tp, std::size_t _Nm>
+ constexpr _Tp&
+ get(array<_Tp, _Nm>& __arr) noexcept
+ {
+ static_assert(_Int < _Nm, "index is out of bounds");
+ return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::
+ _S_ref(__arr._M_elems, _Int);
+ }
+
+ template<std::size_t _Int, typename _Tp, std::size_t _Nm>
+ constexpr _Tp&&
+ get(array<_Tp, _Nm>&& __arr) noexcept
+ {
+ static_assert(_Int < _Nm, "index is out of bounds");
+ return std::move(get<_Int>(__arr));
+ }
+
+ template<std::size_t _Int, typename _Tp, std::size_t _Nm>
+ constexpr const _Tp&
+ get(const array<_Tp, _Nm>& __arr) noexcept
+ {
+ static_assert(_Int < _Nm, "index is out of bounds");
+ return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::
+ _S_ref(__arr._M_elems, _Int);
+ }
+} // namespace __debug
+
+ // Tuple interface to class template array.
+
+ /// tuple_size
+ template<typename _Tp>
+ class tuple_size;
+
+ template<typename _Tp, std::size_t _Nm>
+ struct tuple_size<__debug::array<_Tp, _Nm>>
+ : public integral_constant<std::size_t, _Nm> { };
+
+ /// tuple_element
+ template<std::size_t _Int, typename _Tp>
+ class tuple_element;
+
+ template<std::size_t _Int, typename _Tp, std::size_t _Nm>
+ struct tuple_element<_Int, __debug::array<_Tp, _Nm>>
+ {
+ static_assert(_Int < _Nm, "index is out of bounds");
+ typedef _Tp type;
+ };
+} // namespace std
+
+#undef _GLIBCXX_THROW_OR_ABORT
+
+#endif // _GLIBCXX_DEBUG_ARRAY
diff --git a/libstdc++-v3/include/profile/array b/libstdc++-v3/include/profile/array
new file mode 100644
index 0000000..895d65b
--- /dev/null
+++ b/libstdc++-v3/include/profile/array
@@ -0,0 +1,273 @@
+// Profile array implementation -*- C++ -*-
+
+// Copyright (C) 2012 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 3, 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.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+/** @file profile/array
+ * This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_PROFILE_ARRAY
+#define _GLIBCXX_PROFILE_ARRAY 1
+
+#pragma GCC system_header
+
+namespace std _GLIBCXX_VISIBILITY(default)
+{
+namespace __profile
+{
+ template<typename _Tp, std::size_t _Nm>
+ struct array
+ {
+ typedef _Tp value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ 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;
+
+ // Support for zero-sized arrays mandatory.
+ typedef _GLIBCXX_STD_C::__array_traits<_Tp, _Nm> _AT_Type;
+ typename _AT_Type::_Type _M_elems;
+
+ // No explicit construct/copy/destroy for aggregate type.
+
+ // DR 776.
+ void
+ fill(const value_type& __u)
+ { std::fill_n(begin(), size(), __u); }
+
+ void
+ swap(array& __other)
+ noexcept(noexcept(swap(std::declval<_Tp&>(), std::declval<_Tp&>())))
+ { std::swap_ranges(begin(), end(), __other.begin()); }
+
+ // Iterators.
+ iterator
+ begin() noexcept
+ { return iterator(data()); }
+
+ const_iterator
+ begin() const noexcept
+ { return const_iterator(data()); }
+
+ iterator
+ end() noexcept
+ { return iterator(data() + _Nm); }
+
+ const_iterator
+ end() const noexcept
+ { return const_iterator(data() + _Nm); }
+
+ reverse_iterator
+ rbegin() noexcept
+ { return reverse_iterator(end()); }
+
+ const_reverse_iterator
+ rbegin() const noexcept
+ { return const_reverse_iterator(end()); }
+
+ reverse_iterator
+ rend() noexcept
+ { return reverse_iterator(begin()); }
+
+ const_reverse_iterator
+ rend() const noexcept
+ { return const_reverse_iterator(begin()); }
+
+ const_iterator
+ cbegin() const noexcept
+ { return const_iterator(data()); }
+
+ const_iterator
+ cend() const noexcept
+ { return const_iterator(data() + _Nm); }
+
+ const_reverse_iterator
+ crbegin() const noexcept
+ { return const_reverse_iterator(end()); }
+
+ const_reverse_iterator
+ crend() const noexcept
+ { return const_reverse_iterator(begin()); }
+
+ // Capacity.
+ constexpr size_type
+ size() const noexcept { return _Nm; }
+
+ constexpr size_type
+ max_size() const noexcept { return _Nm; }
+
+ constexpr bool
+ empty() const noexcept { return size() == 0; }
+
+ // Element access.
+ reference
+ operator[](size_type __n)
+ { return _AT_Type::_S_ref(_M_elems, __n); }
+
+ constexpr const_reference
+ operator[](size_type __n) const noexcept
+ { return _AT_Type::_S_ref(_M_elems, __n); }
+
+ reference
+ at(size_type __n)
+ {
+ if (__n >= _Nm)
+ std::__throw_out_of_range(__N("array::at"));
+ return _AT_Type::_S_ref(_M_elems, __n);
+ }
+
+ constexpr const_reference
+ at(size_type __n) const
+ {
+ // Result of conditional expression must be an lvalue so use
+ // boolean ? lvalue : (throw-expr, lvalue)
+ return __n < _Nm ? _AT_Type::_S_ref(_M_elems, __n)
+ : (std::__throw_out_of_range(__N("array::at")),
+ _AT_Type::_S_ref(_M_elems, 0));
+ }
+
+ reference
+ front()
+ { return *begin(); }
+
+ constexpr const_reference
+ front() const
+ { return _AT_Type::_S_ref(_M_elems, 0); }
+
+ reference
+ back()
+ { return _Nm ? *(end() - 1) : *end(); }
+
+ constexpr const_reference
+ back() const
+ {
+ return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1)
+ : _AT_Type::_S_ref(_M_elems, 0);
+ }
+
+ pointer
+ data() noexcept
+ { return std::__addressof(_AT_Type::_S_ref(_M_elems, 0)); }
+
+ const_pointer
+ data() const noexcept
+ { return std::__addressof(_AT_Type::_S_ref(_M_elems, 0)); }
+ };
+
+ // Array comparisons.
+ template<typename _Tp, std::size_t _Nm>
+ 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>
+ inline bool
+ operator!=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
+ { return !(__one == __two); }
+
+ template<typename _Tp, std::size_t _Nm>
+ inline bool
+ operator<(const array<_Tp, _Nm>& __a, const array<_Tp, _Nm>& __b)
+ {
+ return std::lexicographical_compare(__a.begin(), __a.end(),
+ __b.begin(), __b.end());
+ }
+
+ template<typename _Tp, std::size_t _Nm>
+ inline bool
+ operator>(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
+ { return __two < __one; }
+
+ template<typename _Tp, std::size_t _Nm>
+ inline bool
+ operator<=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
+ { return !(__one > __two); }
+
+ template<typename _Tp, std::size_t _Nm>
+ inline bool
+ operator>=(const array<_Tp, _Nm>& __one, const array<_Tp, _Nm>& __two)
+ { return !(__one < __two); }
+
+ // Specialized algorithms.
+ template<typename _Tp, std::size_t _Nm>
+ inline void
+ swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
+ noexcept(noexcept(__one.swap(__two)))
+ { __one.swap(__two); }
+
+ template<std::size_t _Int, typename _Tp, std::size_t _Nm>
+ constexpr _Tp&
+ get(array<_Tp, _Nm>& __arr) noexcept
+ {
+ static_assert(_Int < _Nm, "index is out of bounds");
+ return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::
+ _S_ref(__arr._M_elems, _Int);
+ }
+
+ template<std::size_t _Int, typename _Tp, std::size_t _Nm>
+ constexpr _Tp&&
+ get(array<_Tp, _Nm>&& __arr) noexcept
+ {
+ static_assert(_Int < _Nm, "index is out of bounds");
+ return std::move(get<_Int>(__arr));
+ }
+
+ template<std::size_t _Int, typename _Tp, std::size_t _Nm>
+ constexpr const _Tp&
+ get(const array<_Tp, _Nm>& __arr) noexcept
+ {
+ static_assert(_Int < _Nm, "index is out of bounds");
+ return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::
+ _S_ref(__arr._M_elems, _Int);
+ }
+} // namespace __profile
+
+ // Tuple interface to class template array.
+
+ /// tuple_size
+ template<typename _Tp>
+ class tuple_size;
+
+ template<typename _Tp, std::size_t _Nm>
+ struct tuple_size<__profile::array<_Tp, _Nm>>
+ : public integral_constant<std::size_t, _Nm> { };
+
+ /// tuple_element
+ template<std::size_t _Int, typename _Tp>
+ class tuple_element;
+
+ template<std::size_t _Int, typename _Tp, std::size_t _Nm>
+ struct tuple_element<_Int, __profile::array<_Tp, _Nm>>
+ {
+ static_assert(_Int < _Nm, "index is out of bounds");
+ typedef _Tp type;
+ };
+} // namespace std
+
+#endif // _GLIBCXX_PROFILE_ARRAY
diff --git a/libstdc++-v3/include/std/array b/libstdc++-v3/include/std/array
index 15dd6c1..f83baa7 100644
--- a/libstdc++-v3/include/std/array
+++ b/libstdc++-v3/include/std/array
@@ -41,7 +41,7 @@
namespace std _GLIBCXX_VISIBILITY(default)
{
-_GLIBCXX_BEGIN_NAMESPACE_VERSION
+_GLIBCXX_BEGIN_NAMESPACE_CONTAINER
template<typename _Tp, std::size_t _Nm>
struct __array_traits
@@ -93,8 +93,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
// Support for zero-sized arrays mandatory.
- typedef std::__array_traits<_Tp, _Nm> _AT_Type;
- typename _AT_Type::_Type _M_elems;
+ typedef _GLIBCXX_STD_C::__array_traits<_Tp, _Nm> _AT_Type;
+ typename _AT_Type::_Type _M_elems;
// No explicit construct/copy/destroy for aggregate type.
@@ -210,7 +210,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
back() const
{
return _Nm ? _AT_Type::_S_ref(_M_elems, _Nm - 1)
- : _AT_Type::_S_ref(_M_elems, _Nm);
+ : _AT_Type::_S_ref(_M_elems, 0);
}
pointer
@@ -289,7 +289,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
get(array<_Tp, _Nm>& __arr) noexcept
{
static_assert(_Int < _Nm, "index is out of bounds");
- return std::__array_traits<_Tp, _Nm>::_S_ref(__arr._M_elems, _Int);
+ return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::
+ _S_ref(__arr._M_elems, _Int);
}
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
@@ -305,11 +306,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
get(const array<_Tp, _Nm>& __arr) noexcept
{
static_assert(_Int < _Nm, "index is out of bounds");
- return std::__array_traits<_Tp, _Nm>::_S_ref(__arr._M_elems, _Int);
+ return _GLIBCXX_STD_C::__array_traits<_Tp, _Nm>::
+ _S_ref(__arr._M_elems, _Int);
}
-_GLIBCXX_END_NAMESPACE_VERSION
-} // namespace
+_GLIBCXX_END_NAMESPACE_CONTAINER
+} // namespace std
+
+#ifdef _GLIBCXX_DEBUG
+# include <debug/array>
+#endif
+
+#ifdef _GLIBCXX_PROFILE
+# include <profile/array>
+#endif
#endif // __GXX_EXPERIMENTAL_CXX0X__
diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
index b4985d2..1e3cc7e 100644
--- a/libstdc++-v3/include/std/tuple
+++ b/libstdc++-v3/include/std/tuple
@@ -1,7 +1,6 @@
// <tuple> -*- C++ -*-
-// Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012
-// Free Software Foundation, Inc.
+// Copyright (C) 2007-2012 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
@@ -37,6 +36,7 @@
#else
#include <utility>
+#include <array>
#include <bits/uses_allocator.h>
namespace std _GLIBCXX_VISIBILITY(default)
@@ -862,18 +862,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
forward_as_tuple(_Elements&&... __args) noexcept
{ return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
-
- template<typename, std::size_t> struct array;
-
- template<std::size_t _Int, typename _Tp, std::size_t _Nm>
- constexpr _Tp& get(array<_Tp, _Nm>&) noexcept;
-
- template<std::size_t _Int, typename _Tp, std::size_t _Nm>
- constexpr _Tp&& get(array<_Tp, _Nm>&&) noexcept;
-
- template<std::size_t _Int, typename _Tp, std::size_t _Nm>
- constexpr const _Tp& get(const array<_Tp, _Nm>&) noexcept;
-
template<typename>
struct __is_tuple_like_impl : false_type
{ };
diff --git a/libstdc++-v3/testsuite/23_containers/array/debug/back1_neg.cc b/libstdc++-v3/testsuite/23_containers/array/debug/back1_neg.cc
new file mode 100644
index 0000000..82adca4
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/array/debug/back1_neg.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2012 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-do run { xfail *-*-* } }
+// { dg-options "-std=gnu++11" }
+// { dg-require-debug-mode "" }
+
+#include <array>
+
+void test01()
+{
+ std::array<int, 0> a;
+ a.back();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/array/debug/back2_neg.cc b/libstdc++-v3/testsuite/23_containers/array/debug/back2_neg.cc
new file mode 100644
index 0000000..15b6ce8
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/array/debug/back2_neg.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2012 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-do run { xfail *-*-* } }
+// { dg-options "-std=gnu++11" }
+// { dg-require-debug-mode "" }
+
+#include <array>
+
+void test01()
+{
+ constexpr std::array<int, 0> a;
+ a.back();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/array/debug/front1_neg.cc b/libstdc++-v3/testsuite/23_containers/array/debug/front1_neg.cc
new file mode 100644
index 0000000..03a11c8
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/array/debug/front1_neg.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2012 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-do run { xfail *-*-* } }
+// { dg-options "-std=gnu++11" }
+// { dg-require-debug-mode "" }
+
+#include <array>
+
+void test01()
+{
+ std::array<int, 0> a;
+ a.front();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/array/debug/front2_neg.cc b/libstdc++-v3/testsuite/23_containers/array/debug/front2_neg.cc
new file mode 100644
index 0000000..f4c104d
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/array/debug/front2_neg.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2012 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-do run { xfail *-*-* } }
+// { dg-options "-std=gnu++11" }
+// { dg-require-debug-mode "" }
+
+#include <array>
+
+void test01()
+{
+ constexpr std::array<int, 0> a;
+ a.front();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/array/debug/square_brackets_operator1_neg.cc b/libstdc++-v3/testsuite/23_containers/array/debug/square_brackets_operator1_neg.cc
new file mode 100644
index 0000000..05766db
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/array/debug/square_brackets_operator1_neg.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2012 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-do run { xfail *-*-* } }
+// { dg-options "-std=gnu++11" }
+// { dg-require-debug-mode "" }
+
+#include <array>
+
+void test01()
+{
+ std::array<int, 0> a;
+ a[0];
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/array/debug/square_brackets_operator2_neg.cc b/libstdc++-v3/testsuite/23_containers/array/debug/square_brackets_operator2_neg.cc
new file mode 100644
index 0000000..823837f
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/array/debug/square_brackets_operator2_neg.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2012 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+//
+// { dg-do run { xfail *-*-* } }
+// { dg-options "-std=gnu++11" }
+// { dg-require-debug-mode "" }
+
+#include <array>
+
+void test01()
+{
+ constexpr std::array<int, 0> a;
+ a[0];
+}
+
+int main()
+{
+ test01();
+ return 0;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_debug_neg.cc b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_debug_neg.cc
new file mode 100644
index 0000000..a19ca72
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_debug_neg.cc
@@ -0,0 +1,33 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++11" }
+// { dg-require-debug-mode "" }
+
+// Copyright (C) 2012 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <array>
+
+std::array<int, 1> a{};
+const std::array<int, 1> ca{};
+
+int n1 = std::get<1>(a);
+int n2 = std::get<1>(std::move(a));
+int n3 = std::get<1>(ca);
+
+// { dg-error "static assertion failed" "" { target *-*-* } 274 }
+// { dg-error "static assertion failed" "" { target *-*-* } 283 }
+// { dg-error "static assertion failed" "" { target *-*-* } 291 }
diff --git a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc
index 7c7a365..5df2f0f 100644
--- a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc
@@ -1,5 +1,6 @@
-// { dg-options "-std=gnu++11" }
// { dg-do compile }
+// { dg-options "-std=gnu++11" }
+// { dg-require-normal-mode "" }
// Copyright (C) 2012 Free Software Foundation, Inc.
//
@@ -28,5 +29,5 @@ int n2 = std::get<1>(std::move(a));
int n3 = std::get<1>(ca);
// { dg-error "static assertion failed" "" { target *-*-* } 291 }
-// { dg-error "static assertion failed" "" { target *-*-* } 299 }
-// { dg-error "static assertion failed" "" { target *-*-* } 307 }
+// { dg-error "static assertion failed" "" { target *-*-* } 300 }
+// { dg-error "static assertion failed" "" { target *-*-* } 308 }
diff --git a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_debug_neg.cc b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_debug_neg.cc
new file mode 100644
index 0000000..c5f6f65
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_debug_neg.cc
@@ -0,0 +1,26 @@
+// { dg-do compile }
+// { dg-options "-std=gnu++11" }
+// { dg-require-debug-mode "" }
+
+// Copyright (C) 2012 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 3, 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 COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <array>
+
+typedef std::tuple_element<1, std::array<int, 1>>::type type;
+
+// { dg-error "static assertion failed" "" { target *-*-* } 314 }
diff --git a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc
index 3c642c8..33c6090b 100644
--- a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc
+++ b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/tuple_element_neg.cc
@@ -1,5 +1,6 @@
-// { dg-options "-std=gnu++11" }
// { dg-do compile }
+// { dg-options "-std=gnu++11" }
+// { dg-require-normal-mode "" }
// Copyright (C) 2012 Free Software Foundation, Inc.
//