]> gcc.gnu.org Git - gcc.git/commit
libstdc++: Reduce header dependencies on <array> and <utility>
authorJonathan Wakely <jwakely@redhat.com>
Thu, 22 Jul 2021 13:48:27 +0000 (14:48 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Tue, 27 Jul 2021 11:04:18 +0000 (12:04 +0100)
commit261d5a4a459bd49942e53bc83334ccc7154a09d5
treedab5b16472ae1f39f8fc6b508b67333dd7c11c16
parentfcc7c6369f7fbf293f502d3d207a90b76cc2c62f
libstdc++: Reduce header dependencies on <array> and <utility>

This refactoring reduces the memory usage and compilation time to parse
a number of headers that depend on std::pair, std::tuple or std::array.
Previously the headers for these class templates were all intertwined,
due to the common dependency on std::tuple_size, std::tuple_element and
their std::get overloads. This decouples the headers by moving some
parts of <utility> into a new <bits/utility.h> header. This means that
<array> and <tuple> no longer need to include the whole of <utility>,
and <tuple> no longer needs to include <array>.

This decoupling benefits headers such as <thread> and <scoped_allocator>
which only need std::tuple, and so no longer have to parse std::array.

Some other headers such as <any>, <optional> and <variant> no longer
need to include <utility> just for the std::in_place tag types, so
do not have to parse the std::pair definitions.

Removing direct uses of <utility> also means that the std::rel_ops
namespace is not transitively declared by other headers.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

* include/Makefile.am: Add bits/utility.h header.
* include/Makefile.in: Regenerate.
* include/bits/utility.h: New file.
* include/std/utility (tuple_size, tuple_element): Move
to new header.
* include/std/type_traits (__is_tuple_like_impl<tuple<T...>>):
Move to <tuple>.
(_Index_tuple, _Build_index_tuple, integer_sequence): Likewise.
(in_place_t, in_place_index_t, in_place_type_t): Likewise.
* include/bits/ranges_util.h: Include new header instead of
<utility>.
* include/bits/stl_pair.h (tuple_size, tuple_element): Move
partial specializations for std::pair here.
(get): Move overloads for std::pair here.
* include/std/any: Include new header instead of <utility>.
* include/std/array: Likewise.
* include/std/memory_resource: Likewise.
* include/std/optional: Likewise.
* include/std/variant: Likewise.
* include/std/tuple: Likewise.
(__is_tuple_like_impl<tuple<T...>>): Move here.
(get) Declare overloads for std::array.
* include/std/version (__cpp_lib_tuples_by_type): Change type
to long.
* testsuite/20_util/optional/84601.cc: Include <utility>.
* testsuite/20_util/specialized_algorithms/uninitialized_fill/constrained.cc:
Likewise.
* testsuite/23_containers/array/tuple_interface/get_neg.cc:
Adjust dg-error line numbers.
* testsuite/std/ranges/access/cbegin.cc: Include <utility>.
* testsuite/std/ranges/access/cend.cc: Likewise.
* testsuite/std/ranges/access/end.cc: Likewise.
* testsuite/std/ranges/single_view.cc: Likewise.
21 files changed:
libstdc++-v3/include/Makefile.am
libstdc++-v3/include/Makefile.in
libstdc++-v3/include/bits/ranges_util.h
libstdc++-v3/include/bits/stl_pair.h
libstdc++-v3/include/bits/utility.h [new file with mode: 0644]
libstdc++-v3/include/std/any
libstdc++-v3/include/std/array
libstdc++-v3/include/std/memory_resource
libstdc++-v3/include/std/optional
libstdc++-v3/include/std/tuple
libstdc++-v3/include/std/type_traits
libstdc++-v3/include/std/utility
libstdc++-v3/include/std/variant
libstdc++-v3/include/std/version
libstdc++-v3/testsuite/20_util/optional/84601.cc
libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/constrained.cc
libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc
libstdc++-v3/testsuite/std/ranges/access/cbegin.cc
libstdc++-v3/testsuite/std/ranges/access/cend.cc
libstdc++-v3/testsuite/std/ranges/access/end.cc
libstdc++-v3/testsuite/std/ranges/single_view.cc
This page took 0.062628 seconds and 6 git commands to generate.