From patchwork Thu May 26 12:36:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 54404 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6CD5D38376C3 for ; Thu, 26 May 2022 12:40:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6CD5D38376C3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1653568837; bh=AW44Y6Cwoyfw7jpJwKUcgyIFv4xz/NHz2qRGjcB79xc=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=gKbfmHRKmjL8cZz2YePQ+x7x+Zs0jtmknQ9jhACjPRjAL65YoFbMphE4UeZlb2Awv hcNLk+hgiuZzojna87RZqo/nDNNW+jcaZ/P6zAXYTHF8lozzTJ36RIjzE8G4MnbkjH c5d2iJ7t8UrZYFnVwMlC12C3Uc7vxO54kxBADyic= 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 ESMTPS id 2406C3834E55 for ; Thu, 26 May 2022 12:36:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2406C3834E55 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-30-7dFSviTpMge22esWeO2h6g-1; Thu, 26 May 2022 08:36:35 -0400 X-MC-Unique: 7dFSviTpMge22esWeO2h6g-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8C2E938349B3; Thu, 26 May 2022 12:36:35 +0000 (UTC) Received: from localhost (unknown [10.33.36.185]) by smtp.corp.redhat.com (Postfix) with ESMTP id 179FE2166B26; Thu, 26 May 2022 12:36:34 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed 3/3] libstdc++: Refactor includes for unordered containers Date: Thu, 26 May 2022 13:36:32 +0100 Message-Id: <20220526123632.1284224-3-jwakely@redhat.com> In-Reply-To: <20220526123632.1284224-1-jwakely@redhat.com> References: <20220526123632.1284224-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.7 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_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Tested powerpc64le-linux, pushed to trunk. -- >8 -- This moves some #include directives to the relevant place. For example, needs so should include it directly instead of relying on and to do so first. libstdc++-v3/ChangeLog: * include/bits/functional_hash.h (__is_fast_hash): Add doxygen comment. * include/bits/hashtable.h: Do not include here. * include/bits/hashtable_policy.h: Include and . * include/bits/unordered_map.h: Include required headers. * include/bits/unordered_set.h: Likewise. * include/std/unordered_map: Do not include headers for indirect dependencies. * include/std/unordered_set: Likewise. --- libstdc++-v3/include/bits/functional_hash.h | 15 +++++++++++---- libstdc++-v3/include/bits/hashtable.h | 3 +-- libstdc++-v3/include/bits/hashtable_policy.h | 2 ++ libstdc++-v3/include/bits/unordered_map.h | 5 +++++ libstdc++-v3/include/bits/unordered_set.h | 5 +++++ libstdc++-v3/include/std/unordered_map | 8 -------- libstdc++-v3/include/std/unordered_set | 8 -------- 7 files changed, 24 insertions(+), 22 deletions(-) diff --git a/libstdc++-v3/include/bits/functional_hash.h b/libstdc++-v3/include/bits/functional_hash.h index c00113eff83..292c0ee03f7 100644 --- a/libstdc++-v3/include/bits/functional_hash.h +++ b/libstdc++-v3/include/bits/functional_hash.h @@ -280,10 +280,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// @} group hashes - // Hint about performance of hash functor. If not fast the hash-based - // containers will cache the hash code. - // Default behavior is to consider that hashers are fast unless specified - // otherwise. + /** Hint about performance of hash functions. + * + * If a given hash function object is not fast, the hash-based containers + * will cache the hash code. + * The default behavior is to consider that hashers are fast unless specified + * otherwise. + * + * Users can specialize this for their own hash functions in order to force + * caching of hash codes in unordered containers. Specializing this trait + * affects the ABI of the unordered containers, so use it carefully. + */ template struct __is_fast_hash : public std::true_type { }; diff --git a/libstdc++-v3/include/bits/hashtable.h b/libstdc++-v3/include/bits/hashtable.h index edc151ef15b..29ec1192f32 100644 --- a/libstdc++-v3/include/bits/hashtable.h +++ b/libstdc++-v3/include/bits/hashtable.h @@ -34,11 +34,10 @@ #include #include +#include // __has_is_transparent_t #if __cplusplus > 201402L # include #endif -#include -#include // equal_to, _Identity, _Select1st namespace std _GLIBCXX_VISIBILITY(default) { diff --git a/libstdc++-v3/include/bits/hashtable_policy.h b/libstdc++-v3/include/bits/hashtable_policy.h index 799c3e986b4..1a259702f98 100644 --- a/libstdc++-v3/include/bits/hashtable_policy.h +++ b/libstdc++-v3/include/bits/hashtable_policy.h @@ -32,7 +32,9 @@ #define _HASHTABLE_POLICY_H 1 #include // for std::tuple, std::forward_as_tuple +#include // for __is_fast_hash #include // for std::min, std::is_permutation. +#include // for std::pair #include // for __gnu_cxx::__aligned_buffer #include // for std::__alloc_rebind #include // for __gnu_cxx::__int_traits diff --git a/libstdc++-v3/include/bits/unordered_map.h b/libstdc++-v3/include/bits/unordered_map.h index d5edfde8caf..5a3e6f61af2 100644 --- a/libstdc++-v3/include/bits/unordered_map.h +++ b/libstdc++-v3/include/bits/unordered_map.h @@ -30,6 +30,11 @@ #ifndef _UNORDERED_MAP_H #define _UNORDERED_MAP_H +#include +#include +#include // hash +#include // equal_to + namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION diff --git a/libstdc++-v3/include/bits/unordered_set.h b/libstdc++-v3/include/bits/unordered_set.h index d2fa2c51171..740bbafd4c9 100644 --- a/libstdc++-v3/include/bits/unordered_set.h +++ b/libstdc++-v3/include/bits/unordered_set.h @@ -30,6 +30,11 @@ #ifndef _UNORDERED_SET_H #define _UNORDERED_SET_H +#include +#include +#include // hash +#include // equal_to + namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION diff --git a/libstdc++-v3/include/std/unordered_map b/libstdc++-v3/include/std/unordered_map index e13bb9a2148..b50ec2a8de2 100644 --- a/libstdc++-v3/include/std/unordered_map +++ b/libstdc++-v3/include/std/unordered_map @@ -35,15 +35,7 @@ # include #else -#include #include -#include -#include -#include -#include -#include // equal_to, _Identity, _Select1st -#include -#include #include #include #include diff --git a/libstdc++-v3/include/std/unordered_set b/libstdc++-v3/include/std/unordered_set index 8b665718a83..edaa517635b 100644 --- a/libstdc++-v3/include/std/unordered_set +++ b/libstdc++-v3/include/std/unordered_set @@ -35,15 +35,7 @@ # include #else -#include #include -#include -#include -#include -#include -#include // equal_to, _Identity, _Select1st -#include -#include #include #include #include