diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2021-11-04 09:31:50 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2021-11-04 18:14:50 +0000 |
commit | 09aab7e699dcbd79fd64959cf259567bdca94022 (patch) | |
tree | 7467ae1110fb0c821837196d25106ab817c28c67 /libstdc++-v3/testsuite | |
parent | 1b4a63593bc6b9770789816b205039fdf3cfd3fc (diff) | |
download | gcc-09aab7e699dcbd79fd64959cf259567bdca94022.zip gcc-09aab7e699dcbd79fd64959cf259567bdca94022.tar.gz gcc-09aab7e699dcbd79fd64959cf259567bdca94022.tar.bz2 |
libstdc++: Optimize std::tuple_element and std::tuple_size_v
This reduces the number of class template instantiations needed for code
using tuples, by reusing _Nth_type in tuple_element and specializing
tuple_size_v for tuple, pair and array (and const-qualified versions of
them).
Also define the _Nth_type primary template as a complete type (but with
no nested 'type' member). This avoids "invalid use of incomplete type"
errors for out-of-range specializations of tuple_element. Those errors
would probably be confusing and unhelpful for users. We already have
a user-friendly static assert in tuple_element itself.
Also ensure that tuple_size_v is available whenever tuple_size is (as
proposed by LWG 3387). We already do that for tuple_element_t.
libstdc++-v3/ChangeLog:
* include/bits/stl_pair.h (tuple_size_v): Define partial
specializations for std::pair.
* include/bits/utility.h (_Nth_type): Move definition here
and define primary template.
(tuple_size_v): Move definition here.
* include/std/array (tuple_size_v): Define partial
specializations for std::array.
* include/std/tuple (tuple_size_v): Move primary template to
<bits/utility.h>. Define partial specializations for
std::tuple.
(tuple_element): Change definition to use _Nth_type.
* include/std/variant (_Nth_type): Move to <bits/utility.h>.
(variant_alternative, variant): Adjust qualification of
_Nth_type.
* testsuite/20_util/tuple/element_access/get_neg.cc: Prune
additional errors from _Nth_type.
Diffstat (limited to 'libstdc++-v3/testsuite')
-rw-r--r-- | libstdc++-v3/testsuite/20_util/tuple/element_access/get_neg.cc | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/libstdc++-v3/testsuite/20_util/tuple/element_access/get_neg.cc b/libstdc++-v3/testsuite/20_util/tuple/element_access/get_neg.cc index 225bb62..113a7fd 100644 --- a/libstdc++-v3/testsuite/20_util/tuple/element_access/get_neg.cc +++ b/libstdc++-v3/testsuite/20_util/tuple/element_access/get_neg.cc @@ -60,3 +60,4 @@ test03() } // { dg-error "tuple index must be in range" "" { target *-*-* } 0 } +// { dg-prune-output "no type named 'type' in .*_Nth_type" } |