aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2021-11-04 09:31:50 +0000
committerJonathan Wakely <jwakely@redhat.com>2021-11-04 18:14:50 +0000
commit09aab7e699dcbd79fd64959cf259567bdca94022 (patch)
tree7467ae1110fb0c821837196d25106ab817c28c67 /gcc
parent1b4a63593bc6b9770789816b205039fdf3cfd3fc (diff)
downloadgcc-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 'gcc')
0 files changed, 0 insertions, 0 deletions