From patchwork Tue Jul 27 12:15:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1510480 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=X+DZoak8; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GYwkw6YZdz9sWX for ; Tue, 27 Jul 2021 22:16:39 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7EB03398306F for ; Tue, 27 Jul 2021 12:16:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7EB03398306F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627388195; bh=oTHlWiwEpP7Fg1q+tXyIUrLU5jEXS4PZ6r5ex4pDEBM=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=X+DZoak8NeuLPuUrei8vHSBJkUsK1Cssgnv6YjpyZp14X2m5deCc0red2YcSGPIEJ jRtk7dBUwrhhFsi8wcvOxBPJxfvDpHimaQyug8jWrunJg1AbiXG746OErY5U3OnHEY /J3009mnHAPT9+lQ2Fnr2SGiKUPfOlOMpYMMA64s= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 31BE4398243D for ; Tue, 27 Jul 2021 12:15:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 31BE4398243D Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-111-KpGgjOWKNSKmvWxMPK6csw-1; Tue, 27 Jul 2021 08:15:34 -0400 X-MC-Unique: KpGgjOWKNSKmvWxMPK6csw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D809C92503; Tue, 27 Jul 2021 12:15:33 +0000 (UTC) Received: from localhost (ovpn-113-85.ams2.redhat.com [10.36.113.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DCF75E279; Tue, 27 Jul 2021 12:15:32 +0000 (UTC) Date: Tue, 27 Jul 2021 13:15:30 +0100 To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] [1/2] libstdc++: Reduce header dependencies on and Message-ID: MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-14.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" 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 into a new header. This means that and no longer need to include the whole of , and no longer needs to include . This decoupling benefits headers such as and which only need std::tuple, and so no longer have to parse std::array. Some other headers such as , and no longer need to include just for the std::in_place tag types, so do not have to parse the std::pair definitions. Removing direct uses of also means that the std::rel_ops namespace is not transitively declared by other headers. Signed-off-by: Jonathan Wakely 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>): Move to . (_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 . * 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 . * 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>): 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 . * 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 . * testsuite/std/ranges/access/cend.cc: Likewise. * testsuite/std/ranges/access/end.cc: Likewise. * testsuite/std/ranges/single_view.cc: Likewise. Tested powerpc64le-linux. Committed to trunk. commit 261d5a4a459bd49942e53bc83334ccc7154a09d5 Author: Jonathan Wakely Date: Thu Jul 22 14:48:27 2021 libstdc++: Reduce header dependencies on and 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 into a new header. This means that and no longer need to include the whole of , and no longer needs to include . This decoupling benefits headers such as and which only need std::tuple, and so no longer have to parse std::array. Some other headers such as , and no longer need to include just for the std::in_place tag types, so do not have to parse the std::pair definitions. Removing direct uses of also means that the std::rel_ops namespace is not transitively declared by other headers. Signed-off-by: Jonathan Wakely 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>): Move to . (_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 . * 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 . * 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>): 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 . * 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 . * testsuite/std/ranges/access/cend.cc: Likewise. * testsuite/std/ranges/access/end.cc: Likewise. * testsuite/std/ranges/single_view.cc: Likewise. diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index 40a41ef2a1c..99eec558116 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -233,6 +233,7 @@ bits_headers = \ ${bits_srcdir}/unordered_set.h \ ${bits_srcdir}/uses_allocator.h \ ${bits_srcdir}/uses_allocator_args.h \ + ${bits_srcdir}/utility.h \ ${bits_srcdir}/valarray_array.h \ ${bits_srcdir}/valarray_array.tcc \ ${bits_srcdir}/valarray_before.h \ diff --git a/libstdc++-v3/include/bits/ranges_util.h b/libstdc++-v3/include/bits/ranges_util.h index 9a07079ac13..0ca203dd4b0 100644 --- a/libstdc++-v3/include/bits/ranges_util.h +++ b/libstdc++-v3/include/bits/ranges_util.h @@ -32,6 +32,7 @@ #if __cplusplus > 201703L # include +# include #ifdef __cpp_lib_ranges namespace std _GLIBCXX_VISIBILITY(default) diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h index c89f377fddc..329485ce3b2 100644 --- a/libstdc++-v3/include/bits/stl_pair.h +++ b/libstdc++-v3/include/bits/stl_pair.h @@ -56,12 +56,12 @@ #ifndef _STL_PAIR_H #define _STL_PAIR_H 1 -#include // for std::move / std::forward, and std::swap - #if __cplusplus >= 201103L -# include // for std::__decay_and_strip, std::is_reference_v +# include // for std::__decay_and_strip +# include // for std::move / std::forward, and std::swap +# include // for std::tuple_element, std::tuple_size #endif -#if __cplusplus > 201703L +#if __cplusplus >= 202002L # include # define __cpp_lib_constexpr_utility 201811L #endif @@ -752,6 +752,153 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// @} +#if __cplusplus >= 201103L + // Various functions which give std::pair a tuple-like interface. + + template + struct __is_tuple_like_impl> : true_type + { }; + + /// Partial specialization for std::pair + template + struct tuple_size> + : public integral_constant { }; + + /// Partial specialization for std::pair + template + struct tuple_element<0, pair<_Tp1, _Tp2>> + { typedef _Tp1 type; }; + + /// Partial specialization for std::pair + template + struct tuple_element<1, pair<_Tp1, _Tp2>> + { typedef _Tp2 type; }; + + /// @cond undocumented + template + struct __pair_get; + + template<> + struct __pair_get<0> + { + template + static constexpr _Tp1& + __get(pair<_Tp1, _Tp2>& __pair) noexcept + { return __pair.first; } + + template + static constexpr _Tp1&& + __move_get(pair<_Tp1, _Tp2>&& __pair) noexcept + { return std::forward<_Tp1>(__pair.first); } + + template + static constexpr const _Tp1& + __const_get(const pair<_Tp1, _Tp2>& __pair) noexcept + { return __pair.first; } + + template + static constexpr const _Tp1&& + __const_move_get(const pair<_Tp1, _Tp2>&& __pair) noexcept + { return std::forward(__pair.first); } + }; + + template<> + struct __pair_get<1> + { + template + static constexpr _Tp2& + __get(pair<_Tp1, _Tp2>& __pair) noexcept + { return __pair.second; } + + template + static constexpr _Tp2&& + __move_get(pair<_Tp1, _Tp2>&& __pair) noexcept + { return std::forward<_Tp2>(__pair.second); } + + template + static constexpr const _Tp2& + __const_get(const pair<_Tp1, _Tp2>& __pair) noexcept + { return __pair.second; } + + template + static constexpr const _Tp2&& + __const_move_get(const pair<_Tp1, _Tp2>&& __pair) noexcept + { return std::forward(__pair.second); } + }; + /// @endcond + + /** @{ + * std::get overloads for accessing members of std::pair + */ + + template + constexpr typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type& + get(pair<_Tp1, _Tp2>& __in) noexcept + { return __pair_get<_Int>::__get(__in); } + + template + constexpr typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&& + get(pair<_Tp1, _Tp2>&& __in) noexcept + { return __pair_get<_Int>::__move_get(std::move(__in)); } + + template + constexpr const typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type& + get(const pair<_Tp1, _Tp2>& __in) noexcept + { return __pair_get<_Int>::__const_get(__in); } + + template + constexpr const typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&& + get(const pair<_Tp1, _Tp2>&& __in) noexcept + { return __pair_get<_Int>::__const_move_get(std::move(__in)); } + +#if __cplusplus >= 201402L + +#define __cpp_lib_tuples_by_type 201304L + + template + constexpr _Tp& + get(pair<_Tp, _Up>& __p) noexcept + { return __p.first; } + + template + constexpr const _Tp& + get(const pair<_Tp, _Up>& __p) noexcept + { return __p.first; } + + template + constexpr _Tp&& + get(pair<_Tp, _Up>&& __p) noexcept + { return std::move(__p.first); } + + template + constexpr const _Tp&& + get(const pair<_Tp, _Up>&& __p) noexcept + { return std::move(__p.first); } + + template + constexpr _Tp& + get(pair<_Up, _Tp>& __p) noexcept + { return __p.second; } + + template + constexpr const _Tp& + get(const pair<_Up, _Tp>& __p) noexcept + { return __p.second; } + + template + constexpr _Tp&& + get(pair<_Up, _Tp>&& __p) noexcept + { return std::move(__p.second); } + + template + constexpr const _Tp&& + get(const pair<_Up, _Tp>&& __p) noexcept + { return std::move(__p.second); } + +#endif // C++14 + /// @} +#endif // C++11 + _GLIBCXX_END_NAMESPACE_VERSION } // namespace std diff --git a/libstdc++-v3/include/bits/utility.h b/libstdc++-v3/include/bits/utility.h new file mode 100644 index 00000000000..96d350874d9 --- /dev/null +++ b/libstdc++-v3/include/bits/utility.h @@ -0,0 +1,205 @@ +// Utilities used throughout the library -*- C++ -*- + +// Copyright (C) 2004-2021 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see +// . + +/** @file include/bits/utility.h + * This is an internal header file, included by other library headers. + * Do not attempt to use it directly. @headername{utility} + * + * This file contains the parts of `` needed by other headers, + * so they don't need to include the whole of ``. + */ + +#ifndef _GLIBCXX_UTILITY_H +#define _GLIBCXX_UTILITY_H 1 + +#pragma GCC system_header + +#if __cplusplus >= 201103L + +#include +#include + +namespace std _GLIBCXX_VISIBILITY(default) +{ +_GLIBCXX_BEGIN_NAMESPACE_VERSION + + /// Finds the size of a given tuple type. + template + struct tuple_size; + + // _GLIBCXX_RESOLVE_LIB_DEFECTS + // 2313. tuple_size should always derive from integral_constant + // 2770. tuple_size specialization is not SFINAE compatible + + template::type, + typename = typename enable_if::value>::type, + size_t = tuple_size<_Tp>::value> + using __enable_if_has_tuple_size = _Tp; + + template + struct tuple_size> + : public tuple_size<_Tp> { }; + + template + struct tuple_size> + : public tuple_size<_Tp> { }; + + template + struct tuple_size> + : public tuple_size<_Tp> { }; + + /// Gives the type of the ith element of a given tuple type. + template + struct tuple_element; + + // Duplicate of C++14's tuple_element_t for internal use in C++11 mode + template + using __tuple_element_t = typename tuple_element<__i, _Tp>::type; + + template + struct tuple_element<__i, const _Tp> + { + typedef typename add_const<__tuple_element_t<__i, _Tp>>::type type; + }; + + template + struct tuple_element<__i, volatile _Tp> + { + typedef typename add_volatile<__tuple_element_t<__i, _Tp>>::type type; + }; + + template + struct tuple_element<__i, const volatile _Tp> + { + typedef typename add_cv<__tuple_element_t<__i, _Tp>>::type type; + }; + +#if __cplusplus >= 201402L +// The standard says this macro and alias template should be in +// but we define them here, to be available in and too. +#define __cpp_lib_tuple_element_t 201402L + + template + using tuple_element_t = typename tuple_element<__i, _Tp>::type; +#endif // C++14 + + // Stores a tuple of indices. Used by tuple and pair, and by bind() to + // extract the elements in a tuple. + template struct _Index_tuple { }; + + // Builds an _Index_tuple<0, 1, 2, ..., _Num-1>. + template + struct _Build_index_tuple + { +#if __has_builtin(__make_integer_seq) + template + using _IdxTuple = _Index_tuple<_Indices...>; + + // Clang defines __make_integer_seq for this purpose. + using __type = __make_integer_seq<_IdxTuple, size_t, _Num>; +#else + // For GCC and other compilers, use __integer_pack instead. + using __type = _Index_tuple<__integer_pack(_Num)...>; +#endif + }; + +#if __cplusplus >= 201402L + +#define __cpp_lib_integer_sequence 201304L + + /// Class template integer_sequence + template + struct integer_sequence + { + typedef _Tp value_type; + static constexpr size_t size() noexcept { return sizeof...(_Idx); } + }; + + /// Alias template make_integer_sequence + template + using make_integer_sequence +#if __has_builtin(__make_integer_seq) + = __make_integer_seq; +#else + = integer_sequence<_Tp, __integer_pack(_Num)...>; +#endif + + /// Alias template index_sequence + template + using index_sequence = integer_sequence; + + /// Alias template make_index_sequence + template + using make_index_sequence = make_integer_sequence; + + /// Alias template index_sequence_for + template + using index_sequence_for = make_index_sequence; + +#if __cplusplus >= 201703L + + // + struct in_place_t { + explicit in_place_t() = default; + }; + + inline constexpr in_place_t in_place{}; + + template struct in_place_type_t + { + explicit in_place_type_t() = default; + }; + + template + inline constexpr in_place_type_t<_Tp> in_place_type{}; + + template struct in_place_index_t + { + explicit in_place_index_t() = default; + }; + + template + inline constexpr in_place_index_t<_Idx> in_place_index{}; + + template + struct __is_in_place_type_impl : false_type + { }; + + template + struct __is_in_place_type_impl> : true_type + { }; + + template + struct __is_in_place_type + : public __is_in_place_type_impl<_Tp> + { }; +#endif // C++17 +#endif // C++14 + +_GLIBCXX_END_NAMESPACE_VERSION +} // namespace + +#endif // C++11 +#endif /* _GLIBCXX_UTILITY_H */ diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any index a6995b79c43..1fce95730ea 100644 --- a/libstdc++-v3/include/std/any +++ b/libstdc++-v3/include/std/any @@ -33,10 +33,11 @@ #if __cplusplus >= 201703L +#include #include #include -#include #include +#include // in_place_type_t namespace std _GLIBCXX_VISIBILITY(default) { diff --git a/libstdc++-v3/include/std/array b/libstdc++-v3/include/std/array index 0c6f33e3276..ea8d3cb5f2e 100644 --- a/libstdc++-v3/include/std/array +++ b/libstdc++-v3/include/std/array @@ -35,10 +35,14 @@ # include #else -#include +#include +#include + +#include #include #include -#include +#include // std::begin, std::end etc. +#include // std::index_sequence, std::tuple_size #include namespace std _GLIBCXX_VISIBILITY(default) @@ -428,28 +432,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Tuple interface to class template array. - /// tuple_size - template - struct tuple_size; - /// Partial specialization for std::array - template + template struct tuple_size> - : public integral_constant { }; - - /// tuple_element - template - struct tuple_element; + : public integral_constant { }; /// Partial specialization for std::array - template - struct tuple_element<_Int, array<_Tp, _Nm>> + template + struct tuple_element<_Ind, array<_Tp, _Nm>> { - static_assert(_Int < _Nm, "index is out of bounds"); - typedef _Tp type; + static_assert(_Ind < _Nm, "array index is in range"); + using type = _Tp; }; - template + template struct __is_tuple_like_impl> : true_type { }; diff --git a/libstdc++-v3/include/std/memory_resource b/libstdc++-v3/include/std/memory_resource index df4e806f814..cdc5e5d98b1 100644 --- a/libstdc++-v3/include/std/memory_resource +++ b/libstdc++-v3/include/std/memory_resource @@ -38,13 +38,13 @@ #include // shared_mutex #include // align #include // __throw_bad_array_new_length -#include // __use_alloc +#include // allocator_arg_t, __use_alloc #include // uninitialized_construct_using_alloc #include #include #if ! __cpp_lib_make_obj_using_allocator -# include // pair, index_sequence +# include // index_sequence # include // tuple, forward_as_tuple #endif @@ -338,10 +338,10 @@ namespace pmr { return _M_resource; } private: +#if ! __cpp_lib_make_obj_using_allocator using __uses_alloc1_ = __uses_alloc1; using __uses_alloc2_ = __uses_alloc2; -#if ! __cpp_lib_make_obj_using_allocator template static tuple<_Args&&...> _S_construct_p(__uses_alloc0, _Ind, tuple<_Args...>& __t) diff --git a/libstdc++-v3/include/std/optional b/libstdc++-v3/include/std/optional index 0a67ce24bbd..df9ed0736b3 100644 --- a/libstdc++-v3/include/std/optional +++ b/libstdc++-v3/include/std/optional @@ -33,14 +33,14 @@ #if __cplusplus >= 201703L -#include #include #include #include #include +#include #include #include -#include +#include // in_place_t #if __cplusplus > 201703L # include #endif diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple index 8ee0d2f1ef5..1292aee45c0 100644 --- a/libstdc++-v3/include/std/tuple +++ b/libstdc++-v3/include/std/tuple @@ -35,10 +35,10 @@ # include #else -#include -#include -#include -#include +#include // for std::pair +#include // for std::allocator_arg_t +#include // for std::get, std::tuple_size etc. +#include // for std::__invoke #if __cplusplus > 201703L # include # define __cpp_lib_constexpr_tuple 201811L @@ -1415,7 +1415,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #if __cplusplus >= 201402L -#define __cpp_lib_tuples_by_type 201304 +#define __cpp_lib_tuples_by_type 201304L // Return the index of _Tp in _Types, if it occurs exactly once. // Otherwise, return sizeof...(_Types). @@ -1613,6 +1613,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION forward_as_tuple(_Elements&&... __args) noexcept { return tuple<_Elements&&...>(std::forward<_Elements>(__args)...); } + // Declarations of std::array and its std::get overloads, so that + // std::tuple_cat can use them if is included before . + + template struct array; + + template + constexpr _Tp& + get(array<_Tp, _Nm>&) noexcept; + + template + constexpr _Tp&& + get(array<_Tp, _Nm>&&) noexcept; + + template + constexpr const _Tp& + get(const array<_Tp, _Nm>&) noexcept; + + template + constexpr const _Tp&& + get(const array<_Tp, _Nm>&&) noexcept; + + template struct __make_tuple_impl; @@ -1721,6 +1743,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION } }; + template + struct __is_tuple_like_impl> : true_type + { }; + /// tuple_cat template...>::value>::type> diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 15ec83a06b8..0d821f9c074 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -41,9 +41,6 @@ namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION - template - class tuple; - template class reference_wrapper; @@ -2680,10 +2677,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __is_tuple_like_impl : false_type { }; - template - struct __is_tuple_like_impl> : true_type - { }; - // Internal type trait that allows us to sfinae-protect tuple_cat. template struct __is_tuple_like diff --git a/libstdc++-v3/include/std/utility b/libstdc++-v3/include/std/utility index 3e68f682e00..c2697f87dc5 100644 --- a/libstdc++-v3/include/std/utility +++ b/libstdc++-v3/include/std/utility @@ -60,9 +60,8 @@ /** * @defgroup utilities Utilities * - * Components deemed generally useful. Includes pair, tuple, - * forward/move helpers, ratio, function object, metaprogramming and - * type traits, time, date, and memory functions. + * Basic function and class templates used with the rest of the library. + * Includes pair, swap, forward/move helpers, declval, integer_sequence. */ #include @@ -71,218 +70,21 @@ #if __cplusplus >= 201103L +#include #include #include -#include +#include -#if __cplusplus > 201703L -#include +#if __cplusplus >= 202002L +#include // __is_standard_integer, __int_traits #endif namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION - /// Finds the size of a given tuple type. - template - struct tuple_size; - - // _GLIBCXX_RESOLVE_LIB_DEFECTS - // 2313. tuple_size should always derive from integral_constant - // 2770. tuple_size specialization is not SFINAE compatible - - template::type, - typename = typename enable_if::value>::type, - size_t = tuple_size<_Tp>::value> - using __enable_if_has_tuple_size = _Tp; - - template - struct tuple_size> - : public tuple_size<_Tp> { }; - - template - struct tuple_size> - : public tuple_size<_Tp> { }; - - template - struct tuple_size> - : public tuple_size<_Tp> { }; - - /// Gives the type of the ith element of a given tuple type. - template - struct tuple_element; - - // Duplicate of C++14's tuple_element_t for internal use in C++11 mode - template - using __tuple_element_t = typename tuple_element<__i, _Tp>::type; - - template - struct tuple_element<__i, const _Tp> - { - typedef typename add_const<__tuple_element_t<__i, _Tp>>::type type; - }; - - template - struct tuple_element<__i, volatile _Tp> - { - typedef typename add_volatile<__tuple_element_t<__i, _Tp>>::type type; - }; - - template - struct tuple_element<__i, const volatile _Tp> - { - typedef typename add_cv<__tuple_element_t<__i, _Tp>>::type type; - }; - #if __cplusplus >= 201402L -// The standard says this macro and alias template should be in -// but we define them here, to be available when the partial specializations -// of tuple_element> and tuple_element> are defined. -#define __cpp_lib_tuple_element_t 201402L - - template - using tuple_element_t = typename tuple_element<__i, _Tp>::type; -#endif - - // Various functions which give std::pair a tuple-like interface. - - /// Partial specialization for std::pair - template - struct __is_tuple_like_impl> : true_type - { }; - - /// Partial specialization for std::pair - template - struct tuple_size> - : public integral_constant { }; - - /// Partial specialization for std::pair - template - struct tuple_element<0, pair<_Tp1, _Tp2>> - { typedef _Tp1 type; }; - - /// Partial specialization for std::pair - template - struct tuple_element<1, pair<_Tp1, _Tp2>> - { typedef _Tp2 type; }; - - template - struct __pair_get; - - template<> - struct __pair_get<0> - { - template - static constexpr _Tp1& - __get(pair<_Tp1, _Tp2>& __pair) noexcept - { return __pair.first; } - - template - static constexpr _Tp1&& - __move_get(pair<_Tp1, _Tp2>&& __pair) noexcept - { return std::forward<_Tp1>(__pair.first); } - - template - static constexpr const _Tp1& - __const_get(const pair<_Tp1, _Tp2>& __pair) noexcept - { return __pair.first; } - - template - static constexpr const _Tp1&& - __const_move_get(const pair<_Tp1, _Tp2>&& __pair) noexcept - { return std::forward(__pair.first); } - }; - - template<> - struct __pair_get<1> - { - template - static constexpr _Tp2& - __get(pair<_Tp1, _Tp2>& __pair) noexcept - { return __pair.second; } - - template - static constexpr _Tp2&& - __move_get(pair<_Tp1, _Tp2>&& __pair) noexcept - { return std::forward<_Tp2>(__pair.second); } - - template - static constexpr const _Tp2& - __const_get(const pair<_Tp1, _Tp2>& __pair) noexcept - { return __pair.second; } - - template - static constexpr const _Tp2&& - __const_move_get(const pair<_Tp1, _Tp2>&& __pair) noexcept - { return std::forward(__pair.second); } - }; - - template - constexpr typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type& - get(pair<_Tp1, _Tp2>& __in) noexcept - { return __pair_get<_Int>::__get(__in); } - - template - constexpr typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&& - get(pair<_Tp1, _Tp2>&& __in) noexcept - { return __pair_get<_Int>::__move_get(std::move(__in)); } - - template - constexpr const typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type& - get(const pair<_Tp1, _Tp2>& __in) noexcept - { return __pair_get<_Int>::__const_get(__in); } - - template - constexpr const typename tuple_element<_Int, pair<_Tp1, _Tp2>>::type&& - get(const pair<_Tp1, _Tp2>&& __in) noexcept - { return __pair_get<_Int>::__const_move_get(std::move(__in)); } - -#if __cplusplus >= 201402L - -#define __cpp_lib_tuples_by_type 201304 - - template - constexpr _Tp& - get(pair<_Tp, _Up>& __p) noexcept - { return __p.first; } - - template - constexpr const _Tp& - get(const pair<_Tp, _Up>& __p) noexcept - { return __p.first; } - - template - constexpr _Tp&& - get(pair<_Tp, _Up>&& __p) noexcept - { return std::move(__p.first); } - - template - constexpr const _Tp&& - get(const pair<_Tp, _Up>&& __p) noexcept - { return std::move(__p.first); } - - template - constexpr _Tp& - get(pair<_Up, _Tp>& __p) noexcept - { return __p.second; } - - template - constexpr const _Tp& - get(const pair<_Up, _Tp>& __p) noexcept - { return __p.second; } - - template - constexpr _Tp&& - get(pair<_Up, _Tp>&& __p) noexcept - { return std::move(__p.second); } - - template - constexpr const _Tp&& - get(const pair<_Up, _Tp>&& __p) noexcept - { return std::move(__p.second); } - -#define __cpp_lib_exchange_function 201304 +#define __cpp_lib_exchange_function 201304L /// Assign @p __new_val to @p __obj and return its previous value. template @@ -291,100 +93,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION exchange(_Tp& __obj, _Up&& __new_val) { return std::__exchange(__obj, std::forward<_Up>(__new_val)); } -#endif // C++14 +#if __cplusplus >= 201703L - // Stores a tuple of indices. Used by tuple and pair, and by bind() to - // extract the elements in a tuple. - template struct _Index_tuple { }; - - // Builds an _Index_tuple<0, 1, 2, ..., _Num-1>. - template - struct _Build_index_tuple - { -#if __has_builtin(__make_integer_seq) - template - using _IdxTuple = _Index_tuple<_Indices...>; - - // Clang defines __make_integer_seq for this purpose. - using __type = __make_integer_seq<_IdxTuple, size_t, _Num>; -#else - // For GCC and other compilers, use __integer_pack instead. - using __type = _Index_tuple<__integer_pack(_Num)...>; -#endif - }; - -#if __cplusplus >= 201402L - -#define __cpp_lib_integer_sequence 201304 - - /// Class template integer_sequence - template - struct integer_sequence - { - typedef _Tp value_type; - static constexpr size_t size() noexcept { return sizeof...(_Idx); } - }; - - /// Alias template make_integer_sequence - template - using make_integer_sequence -#if __has_builtin(__make_integer_seq) - = __make_integer_seq; -#else - = integer_sequence<_Tp, __integer_pack(_Num)...>; -#endif - - /// Alias template index_sequence - template - using index_sequence = integer_sequence; - - /// Alias template make_index_sequence - template - using make_index_sequence = make_integer_sequence; - - /// Alias template index_sequence_for - template - using index_sequence_for = make_index_sequence; -#endif - -#if __cplusplus > 201402L - - struct in_place_t { - explicit in_place_t() = default; - }; - - inline constexpr in_place_t in_place{}; - - template struct in_place_type_t - { - explicit in_place_type_t() = default; - }; - - template - inline constexpr in_place_type_t<_Tp> in_place_type{}; - - template struct in_place_index_t - { - explicit in_place_index_t() = default; - }; - - template - inline constexpr in_place_index_t<_Idx> in_place_index{}; - - template - struct __is_in_place_type_impl : false_type - { }; - - template - struct __is_in_place_type_impl> : true_type - { }; - - template - struct __is_in_place_type - : public __is_in_place_type_impl<_Tp> - { }; - -#define __cpp_lib_as_const 201510 +#define __cpp_lib_as_const 201510L template [[nodiscard]] constexpr add_const_t<_Tp>& @@ -476,6 +187,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif // C++23 #endif // C++20 #endif // C++17 +#endif // C++14 _GLIBCXX_END_NAMESPACE_VERSION } // namespace diff --git a/libstdc++-v3/include/std/variant b/libstdc++-v3/include/std/variant index a4e038e0ec8..6383cf4e502 100644 --- a/libstdc++-v3/include/std/variant +++ b/libstdc++-v3/include/std/variant @@ -33,11 +33,10 @@ #if __cplusplus >= 201703L +#include #include -#include #include -#include -#include +#include #include #include #include @@ -45,6 +44,7 @@ #include #include #include +#include // in_place_index_t #if __cplusplus > 201703L # include #endif diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version index 27bcd32cb60..d5fa38d7786 100644 --- a/libstdc++-v3/include/std/version +++ b/libstdc++-v3/include/std/version @@ -94,7 +94,7 @@ # define __cpp_lib_string_udls 201304 # define __cpp_lib_transparent_operators 201510 # define __cpp_lib_tuple_element_t 201402L -# define __cpp_lib_tuples_by_type 201304 +# define __cpp_lib_tuples_by_type 201304L #endif #if __cplusplus >= 201703L diff --git a/libstdc++-v3/testsuite/20_util/optional/84601.cc b/libstdc++-v3/testsuite/20_util/optional/84601.cc index ddac999d49e..fbfa8fdeebf 100644 --- a/libstdc++-v3/testsuite/20_util/optional/84601.cc +++ b/libstdc++-v3/testsuite/20_util/optional/84601.cc @@ -1,6 +1,7 @@ // { dg-do compile { target c++17 } } #include +#include using pair_t = std::pair; using opt_t = std::optional; diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/constrained.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/constrained.cc index bb980a91b0e..bce65cf0807 100644 --- a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/constrained.cc +++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_fill/constrained.cc @@ -25,6 +25,7 @@ #include #include #include +#include #include #include diff --git a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc index 2875f30011b..423594dd2b3 100644 --- a/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc +++ b/libstdc++-v3/testsuite/23_containers/array/tuple_interface/get_neg.cc @@ -26,6 +26,6 @@ int n1 = std::get<1>(a); int n2 = std::get<1>(std::move(a)); int n3 = std::get<1>(ca); -// { dg-error "static assertion failed" "" { target *-*-* } 363 } -// { dg-error "static assertion failed" "" { target *-*-* } 371 } -// { dg-error "static assertion failed" "" { target *-*-* } 379 } +// { dg-error "static assertion failed" "" { target *-*-* } 367 } +// { dg-error "static assertion failed" "" { target *-*-* } 375 } +// { dg-error "static assertion failed" "" { target *-*-* } 383 } diff --git a/libstdc++-v3/testsuite/std/ranges/access/cbegin.cc b/libstdc++-v3/testsuite/std/ranges/access/cbegin.cc index ed80af589cf..7941563b124 100644 --- a/libstdc++-v3/testsuite/std/ranges/access/cbegin.cc +++ b/libstdc++-v3/testsuite/std/ranges/access/cbegin.cc @@ -19,6 +19,7 @@ // { dg-do run { target c++2a } } #include +#include // as_const #include #include diff --git a/libstdc++-v3/testsuite/std/ranges/access/cend.cc b/libstdc++-v3/testsuite/std/ranges/access/cend.cc index 3e685ae9ce2..135bda80a6a 100644 --- a/libstdc++-v3/testsuite/std/ranges/access/cend.cc +++ b/libstdc++-v3/testsuite/std/ranges/access/cend.cc @@ -19,6 +19,7 @@ // { dg-do run { target c++2a } } #include +#include // as_const #include #include diff --git a/libstdc++-v3/testsuite/std/ranges/access/end.cc b/libstdc++-v3/testsuite/std/ranges/access/end.cc index 25f21c75afc..7321a3088a4 100644 --- a/libstdc++-v3/testsuite/std/ranges/access/end.cc +++ b/libstdc++-v3/testsuite/std/ranges/access/end.cc @@ -19,6 +19,7 @@ // { dg-do run { target c++2a } } #include +#include // as_const #include #include diff --git a/libstdc++-v3/testsuite/std/ranges/single_view.cc b/libstdc++-v3/testsuite/std/ranges/single_view.cc index f1d8e103715..fe03cccf9cc 100644 --- a/libstdc++-v3/testsuite/std/ranges/single_view.cc +++ b/libstdc++-v3/testsuite/std/ranges/single_view.cc @@ -19,6 +19,7 @@ // { dg-do run { target c++2a } } #include +#include // as_const #include void From patchwork Tue Jul 27 12:16:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1510481 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=yUvh6q7Z; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GYwnn05Jbz9sWl for ; Tue, 27 Jul 2021 22:19:09 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 43FF7398306A for ; Tue, 27 Jul 2021 12:19:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 43FF7398306A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627388346; bh=H1NCsC6fsSIZys4LyzI5SJMhE0/jH9Rpg4GG9fov0/A=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=yUvh6q7Z9N7w8KMiB2EzV7tKGPef2mHzuTMvDo6gDANZXJUSFt8q6+WD2DhjNwnKa ttycKcycTLvmNXSqvdoGcJaFrPSwG1UPxPVl07TnzojMkDH1CTVQXeaIu5mieJ+VNC Fpb7mOjyeOKgD04NSF0TSfCiy4hgZSAxuhlWrNbc= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 54BDC398304E for ; Tue, 27 Jul 2021 12:16:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 54BDC398304E Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-598-7LquwQFjO5WTOnkTFh3emg-1; Tue, 27 Jul 2021 08:16:43 -0400 X-MC-Unique: 7LquwQFjO5WTOnkTFh3emg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 62400190A7AF; Tue, 27 Jul 2021 12:16:42 +0000 (UTC) Received: from localhost (ovpn-113-85.ams2.redhat.com [10.36.113.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id D525E18432; Tue, 27 Jul 2021 12:16:41 +0000 (UTC) Date: Tue, 27 Jul 2021 13:16:40 +0100 To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] [2/2] libstdc++: Remove unnecessary uses of Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-14.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" The header includes , with a comment referring to UK-300, a National Body comment on the C++11 draft. That comment proposed to move std::swap to and then require to include . The comment was rejected, so we do not need to implement the suggestion. For backwards compatibility with C++03 we do want to define std::swap, but it does so anyway via . We don't need the whole of to do that. A few other headers that need std::swap can include to get it, instead of . There are several headers that include to get std::pair, but they can use to get it without also including the rel_ops namespace and other contents of . Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: * include/std/algorithm: Do not include . * include/std/functional: Likewise. * include/std/regex: Include instead of . * 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 . * 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 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. Tested powerpc64le-linux. Committed to trunk. commit 16158c96496b537194111526d25e19f268d613b6 Author: Jonathan Wakely Date: Thu Jul 22 14:48:27 2021 libstdc++: Remove unnecessary uses of The header includes , with a comment referring to UK-300, a National Body comment on the C++11 draft. That comment proposed to move std::swap to and then require to include . The comment was rejected, so we do not need to implement the suggestion. For backwards compatibility with C++03 we do want to define std::swap, but it does so anyway via . We don't need the whole of to do that. A few other headers that need std::swap can include to get it, instead of . There are several headers that include to get std::pair, but they can use to get it without also including the rel_ops namespace and other contents of . Signed-off-by: Jonathan Wakely libstdc++-v3/ChangeLog: * include/std/algorithm: Do not include . * include/std/functional: Likewise. * include/std/regex: Include instead of . * 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 . * 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 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. diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h index 4fcd1def92f..3151af1e901 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 #include #include #include @@ -41,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/libstdc++-v3/include/bits/unique_ptr.h b/libstdc++-v3/include/bits/unique_ptr.h index 0a0667a7608..2d8b9ed3fae 100644 --- a/libstdc++-v3/include/bits/unique_ptr.h +++ b/libstdc++-v3/include/bits/unique_ptr.h @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include diff --git a/libstdc++-v3/include/debug/map.h b/libstdc++-v3/include/debug/map.h index ab34b2affd9..c0153d09abe 100644 --- a/libstdc++-v3/include/debug/map.h +++ b/libstdc++-v3/include/debug/map.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include namespace std _GLIBCXX_VISIBILITY(default) { diff --git a/libstdc++-v3/include/debug/multimap.h b/libstdc++-v3/include/debug/multimap.h index 96a44f4725f..94929344a9d 100644 --- a/libstdc++-v3/include/debug/multimap.h +++ b/libstdc++-v3/include/debug/multimap.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include namespace std _GLIBCXX_VISIBILITY(default) { diff --git a/libstdc++-v3/include/debug/multiset.h b/libstdc++-v3/include/debug/multiset.h index 0e76c5ff332..bb68d8c8f18 100644 --- a/libstdc++-v3/include/debug/multiset.h +++ b/libstdc++-v3/include/debug/multiset.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include namespace std _GLIBCXX_VISIBILITY(default) { diff --git a/libstdc++-v3/include/debug/set.h b/libstdc++-v3/include/debug/set.h index c579de7426d..cdf35ea5396 100644 --- a/libstdc++-v3/include/debug/set.h +++ b/libstdc++-v3/include/debug/set.h @@ -32,7 +32,7 @@ #include #include #include -#include +#include namespace std _GLIBCXX_VISIBILITY(default) { diff --git a/libstdc++-v3/include/debug/vector b/libstdc++-v3/include/debug/vector index 987bba17c2b..79ccf527dd6 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 -#include #include #include #include diff --git a/libstdc++-v3/include/experimental/any b/libstdc++-v3/include/experimental/any index 3bb3e8c4a0a..7d18f267e8b 100644 --- a/libstdc++-v3/include/experimental/any +++ b/libstdc++-v3/include/experimental/any @@ -36,8 +36,8 @@ #include #include -#include #include +#include #include namespace std _GLIBCXX_VISIBILITY(default) diff --git a/libstdc++-v3/include/experimental/executor b/libstdc++-v3/include/experimental/executor index c670f2739b6..4322a7f5caf 100644 --- a/libstdc++-v3/include/experimental/executor +++ b/libstdc++-v3/include/experimental/executor @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include diff --git a/libstdc++-v3/include/experimental/memory b/libstdc++-v3/include/experimental/memory index a74b2402f7a..a89a5ecfa84 100644 --- a/libstdc++-v3/include/experimental/memory +++ b/libstdc++-v3/include/experimental/memory @@ -40,7 +40,6 @@ #include #include -#include #include #include diff --git a/libstdc++-v3/include/experimental/optional b/libstdc++-v3/include/experimental/optional index ae2418f0500..431d23631cf 100644 --- a/libstdc++-v3/include/experimental/optional +++ b/libstdc++-v3/include/experimental/optional @@ -32,7 +32,6 @@ #if __cplusplus >= 201402L -#include #include #include #include @@ -40,6 +39,7 @@ #include #include #include +#include #include namespace std _GLIBCXX_VISIBILITY(default) diff --git a/libstdc++-v3/include/experimental/socket b/libstdc++-v3/include/experimental/socket index 9db4a245ccf..6d1c114254a 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 diff --git a/libstdc++-v3/include/std/algorithm b/libstdc++-v3/include/std/algorithm index 9ce4aa8423d..c9df7eae1ff 100644 --- a/libstdc++-v3/include/std/algorithm +++ b/libstdc++-v3/include/std/algorithm @@ -57,7 +57,6 @@ #pragma GCC system_header -#include // UK-300. #include #include #if __cplusplus > 201703L diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index f61f2ac8cfd..131e6629341 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -61,7 +61,6 @@ # include # include # include -# include # include #endif #if __cplusplus > 201703L diff --git a/libstdc++-v3/include/std/regex b/libstdc++-v3/include/std/regex index cd33f26af0d..e623a6ed498 100644 --- a/libstdc++-v3/include/std/regex +++ b/libstdc++-v3/include/std/regex @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -55,6 +54,7 @@ #include #include #include +#include #include #include #include diff --git a/libstdc++-v3/src/filesystem/ops-common.h b/libstdc++-v3/src/filesystem/ops-common.h index 529d4e09016..43311e6c38f 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 +#include // std::__exchange #ifdef _GLIBCXX_HAVE_UNISTD_H # include @@ -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 5de981665d9..3e80b73603e 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 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 217c39b5eb4..ac4eabc5341 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 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 ac9128e6a00..7946effcf3a 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 #include #include +#include #include #include 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 05824c021a8..7267738a4af 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 #include #include +#include #include #include 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 cc8cf0beef8..8759d042bb6 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 #include #include +#include #include #include 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 efcf138dd5f..164d9ca667b 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 #include #include +#include #include #include 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 2283d99b260..b85199e693f 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 -// { 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" } From patchwork Tue Jul 27 20:38:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1510629 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=tkoC8o/D; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GZ7v54p5Dz9sWS for ; Wed, 28 Jul 2021 06:39:28 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DFD6E398305F for ; Tue, 27 Jul 2021 20:39:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DFD6E398305F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627418362; bh=lCzFqaCdfPgvSMNvZE8SRuLT+9D2gvifMsjiHeFRNXw=; h=Date:To:Subject:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=tkoC8o/DKML8Cb1xOMi9ovdbmcT8cZxDxtZdcNBXEEK51jDIGAzC6tH2kUgQpT4UB RWosV1l7hFzFQd+hyM9AAosbXXZkKx2uF+FqfDXXwtifEnNOSCVIeTZGJESATKnxqt oadvpC4P/iCrXEhr9pc3q/LSBWeO7v38xNAMFN/M= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id DBAFA384841C for ; Tue, 27 Jul 2021 20:38:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DBAFA384841C Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-215-1k9WCE18NWKUZGTqUt6f6A-1; Tue, 27 Jul 2021 16:38:36 -0400 X-MC-Unique: 1k9WCE18NWKUZGTqUt6f6A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A1C5F8799EB; Tue, 27 Jul 2021 20:38:35 +0000 (UTC) Received: from localhost (ovpn-113-85.ams2.redhat.com [10.36.113.85]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39448189C7; Tue, 27 Jul 2021 20:38:34 +0000 (UTC) Date: Tue, 27 Jul 2021 21:38:34 +0100 To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] [3/2] testsuite: Add missing C++ includes to tests [PR101646] Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-14.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" These tests stopped working after some libstdc++ refactoring, because they aren't including what they use. I committed a blank ChangeLog (I did 'git push' when I meant to push to the compile farm, oops) so I'll fix that tomorrow. Tested powerpc64le-linux. Committed to trunk. commit b7195fb01fe62a313ae5f7faede698101bdb3025 Author: Jonathan Wakely Date: Tue Jul 27 21:29:10 2021 testsuite: Add missing C++ includes to tests [PR101646] These tests stopped working after some libstdc++ refactoring, because they aren't including what they use. gcc/testsuite/ChangeLog: PR testsuite/101646 * g++.dg/coroutines/pr99047.C: * g++.dg/pr71655.C: diff --git a/gcc/testsuite/g++.dg/coroutines/pr99047.C b/gcc/testsuite/g++.dg/coroutines/pr99047.C index 124633a08e6..05ce08567b2 100644 --- a/gcc/testsuite/g++.dg/coroutines/pr99047.C +++ b/gcc/testsuite/g++.dg/coroutines/pr99047.C @@ -1,4 +1,5 @@ #include +#include #include template diff --git a/gcc/testsuite/g++.dg/pr71655.C b/gcc/testsuite/g++.dg/pr71655.C index 8ed33711c36..45943060bc5 100644 --- a/gcc/testsuite/g++.dg/pr71655.C +++ b/gcc/testsuite/g++.dg/pr71655.C @@ -5,6 +5,7 @@ #include #include +#include extern int var_16, le_s5, le_s6, le_s9; std::array, 4>, 24> v4; extern std::array, 18> v15;