aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2022-08-31 15:00:07 +0100
committerJonathan Wakely <jwakely@redhat.com>2022-09-01 10:22:07 +0100
commit0e1b1222af5e5346df9431df817f2e7dca01bee6 (patch)
tree7457f84773265393ceeacfe8ba85473e7c5f6422 /gcc
parent953e08fde44a596e4ec2491efd15cd645e1ddc48 (diff)
downloadgcc-0e1b1222af5e5346df9431df817f2e7dca01bee6.zip
gcc-0e1b1222af5e5346df9431df817f2e7dca01bee6.tar.gz
gcc-0e1b1222af5e5346df9431df817f2e7dca01bee6.tar.bz2
libstdc++: Optimize array traits
Improve compile times by avoiding unnecessary class template instantiations. __is_array_known_bounds and __is_array_unknown_bounds can be defined without instantiating extent, by providing partial specializations for the true cases. std::extent can avoid recursing down through a multidimensional array, so it stops after providing the result. Previously extent<T[n][m], 0> would instantiate extent<T[n], -1u> and extent<T, -2u> as well. std::is_array_v can use partial specializations to avoid instantiating std::is_array, and similarly for std::rank_v and std::extent_v. std::is_bounded_array_v and std::is_unbounded_array_v can also use partial specializations, and then the class templates can be defined in terms of the variable templates. This makes sense for these traits, because they are new in C++20 and so the variable templates are always available, which isn't true in general for C++11 and C++14 traits. libstdc++-v3/ChangeLog: * include/std/type_traits (__is_array_known_bounds): Add partial specialization instead of using std::extent. (__is_array_unknown_bounds): Likewise. (extent): Add partial specializations to stop recursion after the result is found. (is_array_v): Add partial specializations instead of instantiating the class template. (rank_v, extent_v): Likewise. (is_bounded_array_v, is_unbounded_array_v): Likewise. (is_bounded_array, is_unbounded_array): Define in terms of the variable templates.
Diffstat (limited to 'gcc')
0 files changed, 0 insertions, 0 deletions