array: Include <array>.

2015-06-23  François Dumont  <fdumont@gcc.gnu.org>

	* include/debug/array: Include <array>. Add version namespace when
	specializing tuple interface to array. Add specialization for
	__is_tuple_like_impl.
	* include/profile/array: Likewise.
	* include/std/array: Include <utility>. Add specialization for
	__is_tuple_like_impl.
	* include/std/tuple
	(__is_tuple_like_impl<>, __is_tuple_like_impl<pair>): Move...
	* include/std/utility: ... here. Include <type_traits>.
	* testsuite/23_containers/array/tuple_interface/get_debug_neg.cc: Adjust
	dg-error line number.
	* testsuite/23_containers/array/tuple_interface/
	tuple_element_debug_neg.cc: Likewise.

From-SVN: r224857
This commit is contained in:
François Dumont 2015-06-23 19:51:02 +00:00
parent 0fa16060ed
commit 7d17de7f73
8 changed files with 58 additions and 21 deletions

View File

@ -1,3 +1,19 @@
2015-06-23 François Dumont <fdumont@gcc.gnu.org>
* include/debug/array: Include <array>. Add version namespace when
specializing tuple interface to array. Add specialization for
__is_tuple_like_impl.
* include/profile/array: Likewise.
* include/std/array: Include <utility>. Add specialization for
__is_tuple_like_impl.
* include/std/tuple
(__is_tuple_like_impl<>, __is_tuple_like_impl<pair>): Move...
* include/std/utility: ... here. Include <type_traits>.
* testsuite/23_containers/array/tuple_interface/get_debug_neg.cc: Adjust
dg-error line number.
* testsuite/23_containers/array/tuple_interface/
tuple_element_debug_neg.cc: Likewise.
2015-06-22 Jonathan Wakely <jwakely@redhat.com>
* testsuite/26_numerics/complex/value_operations/1.cc: Use

View File

@ -31,6 +31,8 @@
#pragma GCC system_header
#include <array>
#include <debug/formatter.h>
#include <debug/macros.h>
@ -292,20 +294,27 @@ namespace __debug
}
} // namespace __debug
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Tuple interface to class template array.
/// tuple_size
template<typename _Tp, std::size_t _Nm>
struct tuple_size<__debug::array<_Tp, _Nm>>
struct tuple_size<std::__debug::array<_Tp, _Nm>>
: public integral_constant<std::size_t, _Nm> { };
/// tuple_element
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
struct tuple_element<_Int, __debug::array<_Tp, _Nm>>
struct tuple_element<_Int, std::__debug::array<_Tp, _Nm>>
{
static_assert(_Int < _Nm, "index is out of bounds");
typedef _Tp type;
};
template<typename _Tp, std::size_t _Nm>
struct __is_tuple_like_impl<std::__debug::array<_Tp, _Nm>> : true_type
{ };
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // _GLIBCXX_DEBUG_ARRAY

View File

@ -31,6 +31,8 @@
#pragma GCC system_header
#include <array>
namespace std _GLIBCXX_VISIBILITY(default)
{
namespace __profile
@ -253,20 +255,27 @@ namespace __profile
}
} // namespace __profile
_GLIBCXX_BEGIN_NAMESPACE_VERSION
// Tuple interface to class template array.
/// tuple_size
template<typename _Tp, std::size_t _Nm>
struct tuple_size<__profile::array<_Tp, _Nm>>
struct tuple_size<std::__profile::array<_Tp, _Nm>>
: public integral_constant<std::size_t, _Nm> { };
/// tuple_element
template<std::size_t _Int, typename _Tp, std::size_t _Nm>
struct tuple_element<_Int, __profile::array<_Tp, _Nm>>
struct tuple_element<_Int, std::__profile::array<_Tp, _Nm>>
{
static_assert(_Int < _Nm, "index is out of bounds");
typedef _Tp type;
};
template<typename _Tp, std::size_t _Nm>
struct __is_tuple_like_impl<std::__profile::array<_Tp, _Nm>> : true_type
{ };
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std
#endif // _GLIBCXX_PROFILE_ARRAY

View File

@ -35,6 +35,7 @@
# include <bits/c++0x_warning.h>
#else
#include <utility>
#include <stdexcept>
#include <bits/stl_algobase.h>
#include <bits/range_access.h>
@ -331,6 +332,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
typedef _Tp type;
};
template<typename _Tp, std::size_t _Nm>
struct __is_tuple_like_impl<_GLIBCXX_STD_C::array<_Tp, _Nm>> : true_type
{ };
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace std

View File

@ -976,22 +976,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
forward_as_tuple(_Elements&&... __args) noexcept
{ return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); }
template<typename>
struct __is_tuple_like_impl : false_type
{ };
template<typename... _Tps>
struct __is_tuple_like_impl<tuple<_Tps...>> : true_type
{ };
template<typename _T1, typename _T2>
struct __is_tuple_like_impl<pair<_T1, _T2>> : true_type
{ };
template<typename _Tp, std::size_t _Nm>
struct __is_tuple_like_impl<_GLIBCXX_STD_C::array<_Tp, _Nm>> : true_type
{ };
// Internal type trait that allows us to sfinae-protect tuple_cat.
template<typename _Tp>
struct __is_tuple_like

View File

@ -71,6 +71,7 @@
#if __cplusplus >= 201103L
#include <type_traits>
#include <bits/move.h>
#include <initializer_list>
@ -84,7 +85,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<std::size_t _Int, class _Tp>
class tuple_element;
// Various functions which give std::pair a tuple-like interface.
template<typename>
struct __is_tuple_like_impl : false_type
{ };
// Various functions which give std::pair a tuple-like interface.
/// Partial specialization for std::pair
template<typename _T1, typename _T2>
struct __is_tuple_like_impl<std::pair<_T1, _T2>> : true_type
{ };
/// Partial specialization for std::pair
template<class _Tp1, class _Tp2>

View File

@ -28,6 +28,6 @@ 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 *-*-* } 272 }
// { dg-error "static assertion failed" "" { target *-*-* } 281 }
// { dg-error "static assertion failed" "" { target *-*-* } 289 }
// { dg-error "static assertion failed" "" { target *-*-* } 274 }
// { dg-error "static assertion failed" "" { target *-*-* } 283 }
// { dg-error "static assertion failed" "" { target *-*-* } 291 }

View File

@ -23,4 +23,4 @@
typedef std::tuple_element<1, std::array<int, 1>>::type type;
// { dg-error "static assertion failed" "" { target *-*-* } 306 }
// { dg-error "static assertion failed" "" { target *-*-* } 309 }