diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 5aad2456912..ea6dc8833eb 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,19 @@ +2015-06-23 François Dumont + + * include/debug/array: Include . Add version namespace when + specializing tuple interface to array. Add specialization for + __is_tuple_like_impl. + * include/profile/array: Likewise. + * include/std/array: Include . Add specialization for + __is_tuple_like_impl. + * include/std/tuple + (__is_tuple_like_impl<>, __is_tuple_like_impl): Move... + * include/std/utility: ... here. Include . + * 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 * testsuite/26_numerics/complex/value_operations/1.cc: Use diff --git a/libstdc++-v3/include/debug/array b/libstdc++-v3/include/debug/array index 34e6281da5a..a1c7d408bee 100644 --- a/libstdc++-v3/include/debug/array +++ b/libstdc++-v3/include/debug/array @@ -31,6 +31,8 @@ #pragma GCC system_header +#include + #include #include @@ -292,20 +294,27 @@ namespace __debug } } // namespace __debug +_GLIBCXX_BEGIN_NAMESPACE_VERSION // Tuple interface to class template array. /// tuple_size template - struct tuple_size<__debug::array<_Tp, _Nm>> + struct tuple_size> : public integral_constant { }; /// tuple_element template - 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 + struct __is_tuple_like_impl> : true_type + { }; + +_GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // _GLIBCXX_DEBUG_ARRAY diff --git a/libstdc++-v3/include/profile/array b/libstdc++-v3/include/profile/array index 434ca968d84..687c0525357 100644 --- a/libstdc++-v3/include/profile/array +++ b/libstdc++-v3/include/profile/array @@ -31,6 +31,8 @@ #pragma GCC system_header +#include + 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 - struct tuple_size<__profile::array<_Tp, _Nm>> + struct tuple_size> : public integral_constant { }; /// tuple_element template - 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 + struct __is_tuple_like_impl> : true_type + { }; + +_GLIBCXX_END_NAMESPACE_VERSION } // namespace std #endif // _GLIBCXX_PROFILE_ARRAY diff --git a/libstdc++-v3/include/std/array b/libstdc++-v3/include/std/array index 40fbd46c559..d1b5e6db347 100644 --- a/libstdc++-v3/include/std/array +++ b/libstdc++-v3/include/std/array @@ -35,6 +35,7 @@ # include #else +#include #include #include #include @@ -331,6 +332,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef _Tp type; }; + template + struct __is_tuple_like_impl<_GLIBCXX_STD_C::array<_Tp, _Nm>> : true_type + { }; + _GLIBCXX_END_NAMESPACE_VERSION } // namespace std diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index 953d16b73b1..0504012cbd1 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -976,22 +976,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION forward_as_tuple(_Elements&&... __args) noexcept { return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); } - template - struct __is_tuple_like_impl : false_type - { }; - template struct __is_tuple_like_impl> : true_type { }; - template - struct __is_tuple_like_impl> : true_type - { }; - - template - 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 struct __is_tuple_like diff --git a/libstdc++-v3/include/std/utility b/libstdc++-v3/include/std/utility index 1aac77c10cb..89b68522ddf 100644 --- a/libstdc++-v3/include/std/utility +++ b/libstdc++-v3/include/std/utility @@ -71,6 +71,7 @@ #if __cplusplus >= 201103L +#include #include #include @@ -84,7 +85,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template class tuple_element; - // Various functions which give std::pair a tuple-like interface. + template + struct __is_tuple_like_impl : false_type + { }; + + // Various functions which give std::pair a tuple-like interface. + + /// Partial specialization for std::pair + template + struct __is_tuple_like_impl> : true_type + { }; /// Partial specialization for std::pair template 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 index 3e197fd3f31..bc5c726b836 100644 --- 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 @@ -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 } 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 index b7472a23a52..a27f3e23846 100644 --- 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 @@ -23,4 +23,4 @@ typedef std::tuple_element<1, std::array>::type type; -// { dg-error "static assertion failed" "" { target *-*-* } 306 } +// { dg-error "static assertion failed" "" { target *-*-* } 309 }