From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id D69A33857C43 for ; Tue, 26 Apr 2022 12:24:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D69A33857C43 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-665-GLBAoEfwN-qGiDE7CFNH6w-1; Tue, 26 Apr 2022 08:24:36 -0400 X-MC-Unique: GLBAoEfwN-qGiDE7CFNH6w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8CF611014A6D; Tue, 26 Apr 2022 12:24:31 +0000 (UTC) Received: from localhost (unknown [10.33.36.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 133FC112131B; Tue, 26 Apr 2022 12:24:23 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Define std::hash (LWG 3657) Date: Tue, 26 Apr 2022 13:24:23 +0100 Message-Id: <20220426122423.2075300-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.4 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, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=unavailable autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Apr 2022 12:24:43 -0000 Tested powerpc64le-linux, pushed to trunk. -- >8 -- This DR was approved at the February 2022 plenary. libstdc++-v3/ChangeLog: * include/bits/fs_path.h (hash): Define. * testsuite/27_io/filesystem/path/nonmember/hash_value.cc: Check std::hash specialization. --- libstdc++-v3/include/bits/fs_path.h | 10 ++++++++++ .../27_io/filesystem/path/nonmember/hash_value.cc | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h index 9e06fa679d8..d6202fd275a 100644 --- a/libstdc++-v3/include/bits/fs_path.h +++ b/libstdc++-v3/include/bits/fs_path.h @@ -1416,6 +1416,16 @@ extern template class __shared_ptr; /// @endcond +// _GLIBCXX_RESOLVE_LIB_DEFECTS +// 3657. std::hash is not enabled +template<> + struct hash + { + size_t + operator()(const filesystem::path& __p) const noexcept + { return filesystem::hash_value(__p); } + }; + _GLIBCXX_END_NAMESPACE_VERSION } // namespace std diff --git a/libstdc++-v3/testsuite/27_io/filesystem/path/nonmember/hash_value.cc b/libstdc++-v3/testsuite/27_io/filesystem/path/nonmember/hash_value.cc index 6bc6296b5a8..0dcea6efc64 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/path/nonmember/hash_value.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/path/nonmember/hash_value.cc @@ -42,9 +42,19 @@ test02() } } +void +test03() +{ + std::hash h; + // LWG 3657. std::hash is not enabled + for (const path p : __gnu_test::test_paths) + VERIFY( h(p) == hash_value(p) ); +} + int main() { test01(); test02(); + test03(); } -- 2.34.1