diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2021-07-22 14:48:27 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2021-07-27 12:04:18 +0100 |
commit | 16158c96496b537194111526d25e19f268d613b6 (patch) | |
tree | 4b77042b0fb21913b7a7e550b24390a5940b8aae | |
parent | 261d5a4a459bd49942e53bc83334ccc7154a09d5 (diff) | |
download | gcc-16158c96496b537194111526d25e19f268d613b6.zip gcc-16158c96496b537194111526d25e19f268d613b6.tar.gz gcc-16158c96496b537194111526d25e19f268d613b6.tar.bz2 |
libstdc++: Remove unnecessary uses of <utility>
The <algorithm> header includes <utility>, with a comment referring to
UK-300, a National Body comment on the C++11 draft. That comment
proposed to move std::swap to <utility> and then require <algorithm> to
include <utility>. The comment was rejected, so we do not need to
implement the suggestion. For backwards compatibility with C++03 we do
want <algorithm> to define std::swap, but it does so anyway via
<bits/move.h>. We don't need the whole of <utility> to do that.
A few other headers that need std::swap can include <bits/move.h> to
get it, instead of <utility>.
There are several headers that include <utility> to get std::pair, but
they can use <bits/stl_pair.h> to get it without also including the
rel_ops namespace and other contents of <utility>.
Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:
* include/std/algorithm: Do not include <utility>.
* include/std/functional: Likewise.
* include/std/regex: Include <bits/stl_pair.h> instead of
<utility>.
* include/debug/map.h: Likewise.
* include/debug/multimap.h: Likewise.
* include/debug/multiset.h: Likewise.
* include/debug/set.h: Likewise.
* include/debug/vector: Likewise.
* include/bits/fs_path.h: Likewise.
* include/bits/unique_ptr.h: Do not include <utility>.
* include/experimental/any: Likewise.
* include/experimental/executor: Likewise.
* include/experimental/memory: Likewise.
* include/experimental/optional: Likewise.
* include/experimental/socket: Use __exchange instead
of std::exchange.
* src/filesystem/ops-common.h: Likewise.
* testsuite/20_util/default_delete/48631_neg.cc: Adjust expected
errors to not use a hardcoded line number.
* testsuite/20_util/default_delete/void_neg.cc: Likewise.
* testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc:
Include <utility> for std::as_const.
* testsuite/20_util/specialized_algorithms/uninitialized_default_construct/constrained.cc:
Likewise.
* testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc:
Likewise.
* testsuite/20_util/specialized_algorithms/uninitialized_value_construct/constrained.cc:
Likewise.
* testsuite/23_containers/vector/cons/destructible_debug_neg.cc:
Adjust dg-error line number.
23 files changed, 22 insertions, 23 deletions
diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h index 4fcd1de..3151af1 100644 --- a/libstdc++-v3/include/bits/fs_path.h +++ b/libstdc++-v3/include/bits/fs_path.h @@ -32,7 +32,6 @@ #if __cplusplus >= 201703L -#include <utility> #include <type_traits> #include <locale> #include <iosfwd> @@ -41,6 +40,7 @@ #include <string_view> #include <system_error> #include <bits/stl_algobase.h> +#include <bits/stl_pair.h> #include <bits/locale_conv.h> #include <ext/concurrence.h> #include <bits/shared_ptr.h> diff --git a/libstdc++-v3/include/bits/unique_ptr.h b/libstdc++-v3/include/bits/unique_ptr.h index 0a0667a..2d8b9ed 100644 --- a/libstdc++-v3/include/bits/unique_ptr.h +++ b/libstdc++-v3/include/bits/unique_ptr.h @@ -33,7 +33,6 @@ #include <bits/c++config.h> #include <debug/assertions.h> #include <type_traits> -#include <utility> #include <tuple> #include <bits/stl_function.h> #include <bits/functional_hash.h> diff --git a/libstdc++-v3/include/debug/map.h b/libstdc++-v3/include/debug/map.h index ab34b2a..c0153d0 100644 --- a/libstdc++-v3/include/debug/map.h +++ b/libstdc++-v3/include/debug/map.h @@ -32,7 +32,7 @@ #include <debug/safe_sequence.h> #include <debug/safe_container.h> #include <debug/safe_iterator.h> -#include <utility> +#include <bits/stl_pair.h> namespace std _GLIBCXX_VISIBILITY(default) { diff --git a/libstdc++-v3/include/debug/multimap.h b/libstdc++-v3/include/debug/multimap.h index 96a44f4..9492934 100644 --- a/libstdc++-v3/include/debug/multimap.h +++ b/libstdc++-v3/include/debug/multimap.h @@ -32,7 +32,7 @@ #include <debug/safe_sequence.h> #include <debug/safe_container.h> #include <debug/safe_iterator.h> -#include <utility> +#include <bits/stl_pair.h> namespace std _GLIBCXX_VISIBILITY(default) { diff --git a/libstdc++-v3/include/debug/multiset.h b/libstdc++-v3/include/debug/multiset.h index 0e76c5f..bb68d8c 100644 --- a/libstdc++-v3/include/debug/multiset.h +++ b/libstdc++-v3/include/debug/multiset.h @@ -32,7 +32,7 @@ #include <debug/safe_sequence.h> #include <debug/safe_container.h> #include <debug/safe_iterator.h> -#include <utility> +#include <bits/stl_pair.h> namespace std _GLIBCXX_VISIBILITY(default) { diff --git a/libstdc++-v3/include/debug/set.h b/libstdc++-v3/include/debug/set.h index c579de7..cdf35ea 100644 --- a/libstdc++-v3/include/debug/set.h +++ b/libstdc++-v3/include/debug/set.h @@ -32,7 +32,7 @@ #include <debug/safe_sequence.h> #include <debug/safe_container.h> #include <debug/safe_iterator.h> -#include <utility> +#include <bits/stl_pair.h> namespace std _GLIBCXX_VISIBILITY(default) { diff --git a/libstdc++-v3/include/debug/vector b/libstdc++-v3/include/debug/vector index 987bba1..79ccf52 100644 --- a/libstdc++-v3/include/debug/vector +++ b/libstdc++-v3/include/debug/vector @@ -37,7 +37,6 @@ namespace std _GLIBCXX_VISIBILITY(default) { namespace __debug { } } // namespace std::__debug #include <vector> -#include <utility> #include <debug/safe_sequence.h> #include <debug/safe_container.h> #include <debug/safe_iterator.h> diff --git a/libstdc++-v3/include/experimental/any b/libstdc++-v3/include/experimental/any index 3bb3e8c..7d18f26 100644 --- a/libstdc++-v3/include/experimental/any +++ b/libstdc++-v3/include/experimental/any @@ -36,8 +36,8 @@ #include <typeinfo> #include <new> -#include <utility> #include <type_traits> +#include <bits/move.h> #include <experimental/bits/lfts_config.h> namespace std _GLIBCXX_VISIBILITY(default) diff --git a/libstdc++-v3/include/experimental/executor b/libstdc++-v3/include/experimental/executor index c670f27..4322a7f 100644 --- a/libstdc++-v3/include/experimental/executor +++ b/libstdc++-v3/include/experimental/executor @@ -43,7 +43,6 @@ #include <thread> #include <tuple> #include <unordered_map> -#include <utility> #include <experimental/netfwd> #include <bits/unique_ptr.h> #include <experimental/bits/net.h> diff --git a/libstdc++-v3/include/experimental/memory b/libstdc++-v3/include/experimental/memory index a74b240..a89a5ec 100644 --- a/libstdc++-v3/include/experimental/memory +++ b/libstdc++-v3/include/experimental/memory @@ -40,7 +40,6 @@ #include <memory> #include <type_traits> -#include <utility> #include <experimental/bits/shared_ptr.h> #include <bits/functional_hash.h> diff --git a/libstdc++-v3/include/experimental/optional b/libstdc++-v3/include/experimental/optional index ae2418f..431d236 100644 --- a/libstdc++-v3/include/experimental/optional +++ b/libstdc++-v3/include/experimental/optional @@ -32,7 +32,6 @@ #if __cplusplus >= 201402L -#include <utility> #include <type_traits> #include <stdexcept> #include <new> @@ -40,6 +39,7 @@ #include <bits/functexcept.h> #include <bits/functional_hash.h> #include <bits/enable_special_members.h> +#include <bits/move.h> #include <experimental/bits/lfts_config.h> namespace std _GLIBCXX_VISIBILITY(default) diff --git a/libstdc++-v3/include/experimental/socket b/libstdc++-v3/include/experimental/socket index 9db4a24..6d1c114 100644 --- a/libstdc++-v3/include/experimental/socket +++ b/libstdc++-v3/include/experimental/socket @@ -429,16 +429,16 @@ inline namespace v1 __socket_impl(__socket_impl&& __rhs) : _M_ctx(__rhs._M_ctx), - _M_sockfd(std::exchange(__rhs._M_sockfd, -1)), - _M_bits(std::exchange(__rhs._M_bits, {})) + _M_sockfd(std::__exchange(__rhs._M_sockfd, -1)), + _M_bits(std::__exchange(__rhs._M_bits, {})) { } __socket_impl& operator=(__socket_impl&& __rhs) { _M_ctx = __rhs._M_ctx; - _M_sockfd = std::exchange(__rhs._M_sockfd, -1); - _M_bits = std::exchange(__rhs._M_bits, {}); + _M_sockfd = std::__exchange(__rhs._M_sockfd, -1); + _M_bits = std::__exchange(__rhs._M_bits, {}); return *this; } @@ -615,7 +615,7 @@ inline namespace v1 { __glibcxx_assert(is_open()); cancel(__ec); - return std::exchange(_M_sockfd, -1); + return std::__exchange(_M_sockfd, -1); } template<typename _SettableSocketOption> diff --git a/libstdc++-v3/include/std/algorithm b/libstdc++-v3/include/std/algorithm index 9ce4aa8..c9df7ea 100644 --- a/libstdc++-v3/include/std/algorithm +++ b/libstdc++-v3/include/std/algorithm @@ -57,7 +57,6 @@ #pragma GCC system_header -#include <utility> // UK-300. #include <bits/stl_algobase.h> #include <bits/stl_algo.h> #if __cplusplus > 201703L diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index f61f2ac..131e662 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -61,7 +61,6 @@ # include <unordered_map> # include <vector> # include <array> -# include <utility> # include <bits/stl_algo.h> #endif #if __cplusplus > 201703L diff --git a/libstdc++-v3/include/std/regex b/libstdc++-v3/include/std/regex index cd33f26..e623a6e 100644 --- a/libstdc++-v3/include/std/regex +++ b/libstdc++-v3/include/std/regex @@ -47,7 +47,6 @@ #include <stack> #include <stdexcept> #include <string> -#include <utility> #include <vector> #include <map> #include <cstring> @@ -55,6 +54,7 @@ #include <ext/aligned_buffer.h> #include <ext/numeric_traits.h> #include <bits/std_function.h> +#include <bits/stl_pair.h> #include <bits/regex_constants.h> #include <bits/regex_error.h> #include <bits/regex_automaton.h> diff --git a/libstdc++-v3/src/filesystem/ops-common.h b/libstdc++-v3/src/filesystem/ops-common.h index 529d4e0..43311e6 100644 --- a/libstdc++-v3/src/filesystem/ops-common.h +++ b/libstdc++-v3/src/filesystem/ops-common.h @@ -26,6 +26,7 @@ #define _GLIBCXX_OPS_COMMON_H 1 #include <chrono> +#include <bits/move.h> // std::__exchange #ifdef _GLIBCXX_HAVE_UNISTD_H # include <unistd.h> @@ -407,7 +408,7 @@ _GLIBCXX_BEGIN_NAMESPACE_FILESYSTEM struct CloseFD { ~CloseFD() { if (fd != -1) posix::close(fd); } - bool close() { return posix::close(std::exchange(fd, -1)) == 0; } + bool close() { return posix::close(std::__exchange(fd, -1)) == 0; } int fd; }; diff --git a/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc b/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc index 5de9816..3e80b73 100644 --- a/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc +++ b/libstdc++-v3/testsuite/20_util/default_delete/48631_neg.cc @@ -26,4 +26,4 @@ struct D : B { }; D d; std::default_delete<B[]> db; typedef decltype(db(&d)) type; // { dg-error "no match" } -// { dg-error "no type" "" { target *-*-* } 116 } +// { dg-prune-output "no type named 'type' in 'struct std::enable_if" } diff --git a/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc b/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc index 217c39b..ac4eabc 100644 --- a/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc +++ b/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc @@ -25,5 +25,5 @@ void test01() { std::default_delete<void> d; d(nullptr); // { dg-error "here" } - // { dg-error "incomplete" "" { target *-*-* } 81 } + // { dg-error "delete pointer to incomplete type" "" { target *-*-* } 0 } } diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc index ac9128e..7946eff 100644 --- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/constrained.cc @@ -25,6 +25,7 @@ #include <span> #include <string> #include <vector> +#include <utility> #include <testsuite_hooks.h> #include <testsuite_iterators.h> diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default_construct/constrained.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default_construct/constrained.cc index 05824c0..7267738 100644 --- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default_construct/constrained.cc +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default_construct/constrained.cc @@ -25,6 +25,7 @@ #include <span> #include <string> #include <vector> +#include <utility> #include <testsuite_hooks.h> #include <testsuite_iterators.h> diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc index cc8cf0b..8759d04 100644 --- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_move/constrained.cc @@ -25,6 +25,7 @@ #include <span> #include <string> #include <vector> +#include <utility> #include <testsuite_hooks.h> #include <testsuite_iterators.h> diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct/constrained.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct/constrained.cc index efcf138..164d9ca 100644 --- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct/constrained.cc +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct/constrained.cc @@ -25,6 +25,7 @@ #include <span> #include <string> #include <vector> +#include <utility> #include <testsuite_hooks.h> #include <testsuite_iterators.h> diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/destructible_debug_neg.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/destructible_debug_neg.cc index 2283d99..b85199e 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/cons/destructible_debug_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/cons/destructible_debug_neg.cc @@ -46,7 +46,7 @@ test02() // { dg-error "value type is destructible" "" { target *-*-* } 0 } // In Debug Mode the "required from here" errors come from <debug/vector> -// { dg-error "required from here" "" { target *-*-* } 173 } +// { dg-error "required from here" "" { target *-*-* } 172 } // Needed because of PR c++/92193 // { dg-prune-output "deleted function" } |