From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5629 invoked by alias); 23 Mar 2017 17:49:09 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 5165 invoked by uid 89); 23 Mar 2017 17:49:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=H*MI:sk:CAGNvRg X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 23 Mar 2017 17:49:07 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D14ECC0528C0; Thu, 23 Mar 2017 17:49:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com D14ECC0528C0 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jwakely@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com D14ECC0528C0 Received: from localhost (unknown [10.33.36.35]) by smtp.corp.redhat.com (Postfix) with ESMTP id 819307C8C1; Thu, 23 Mar 2017 17:49:07 +0000 (UTC) Date: Thu, 23 Mar 2017 17:50:00 -0000 From: Jonathan Wakely To: Daniel =?iso-8859-1?Q?Kr=FCgler?= Cc: libstdc++ , gcc-patches List Subject: Re: [PATCH] Implement LWG 2686, hash Message-ID: <20170323174905.GG4425@redhat.com> References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="TKDEsImF70pdVIl+" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.8.0 (2017-02-23) X-SW-Source: 2017-03/txt/msg01247.txt.bz2 --TKDEsImF70pdVIl+ Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-length: 1039 On 12/03/17 13:16 +0100, Daniel Krügler wrote: >The following is an *untested* patch suggestion, please verify. > >Notes: My interpretation is that hash should be >defined outside of the _GLIBCXX_COMPATIBILITY_CXX0X block, please >double-check that course of action. That's right. >I noticed that the preexisting hash did directly refer to >the private members of error_code albeit those have public access >functions. For consistency I mimicked that existing style when >implementing hash. I see no reason for that, so I've removed the friend declaration and used the public member functions. Although this is a DR, I'm treating it as a new C++17 feature, so I've adjusted the patch to only add the new specialization for C++17 mode. We're too close to the GCC 7 release to be adding new things to the default mode, even minor things like this. After GCC 7 is released we can revisit it and decide if we want to enable it for all modes. Here's what I've tested and will be committing. --TKDEsImF70pdVIl+ Content-Type: text/x-patch; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" Content-length: 3178 commit 90ca0fd91f5c65af370beb20af06bdca257aaf63 Author: Jonathan Wakely Date: Thu Mar 23 11:47:39 2017 +0000 Implement LWG 2686, std::hash, for C++17 2017-03-23 Daniel Kruegler Implement LWG 2686, Why is std::hash specialized for error_code, but not error_condition? * include/std/system_error (hash): Define for C++17. * testsuite/20_util/hash/operators/size_t.cc (hash): Instantiate test for error_condition. * testsuite/20_util/hash/requirements/explicit_instantiation.cc (hash): Instantiate hash. diff --git a/libstdc++-v3/include/std/system_error b/libstdc++-v3/include/std/system_error index 6775a6e..ec7d25f 100644 --- a/libstdc++-v3/include/std/system_error +++ b/libstdc++-v3/include/std/system_error @@ -373,14 +373,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION } // namespace -#ifndef _GLIBCXX_COMPATIBILITY_CXX0X - #include namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION +#ifndef _GLIBCXX_COMPATIBILITY_CXX0X // DR 1182. /// std::hash specialization for error_code. template<> @@ -394,12 +393,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return std::_Hash_impl::__hash_combine(__e._M_cat, __tmp); } }; +#endif // _GLIBCXX_COMPATIBILITY_CXX0X + +#if __cplusplus > 201402L + // DR 2686. + /// std::hash specialization for error_condition. + template<> + struct hash + : public __hash_base + { + size_t + operator()(const error_condition& __e) const noexcept + { + const size_t __tmp = std::_Hash_impl::hash(__e.value()); + return std::_Hash_impl::__hash_combine(__e.category(), __tmp); + } + }; +#endif _GLIBCXX_END_NAMESPACE_VERSION } // namespace -#endif // _GLIBCXX_COMPATIBILITY_CXX0X - #endif // C++11 #endif // _GLIBCXX_SYSTEM_ERROR diff --git a/libstdc++-v3/testsuite/20_util/hash/operators/size_t.cc b/libstdc++-v3/testsuite/20_util/hash/operators/size_t.cc index ad02843..cc191d6 100644 --- a/libstdc++-v3/testsuite/20_util/hash/operators/size_t.cc +++ b/libstdc++-v3/testsuite/20_util/hash/operators/size_t.cc @@ -43,6 +43,9 @@ template void test01() { do_test(); +#if __cplusplus > 201402L + do_test(); +#endif } int main() diff --git a/libstdc++-v3/testsuite/20_util/hash/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/hash/requirements/explicit_instantiation.cc index e9e5ea1..d01829a 100644 --- a/libstdc++-v3/testsuite/20_util/hash/requirements/explicit_instantiation.cc +++ b/libstdc++-v3/testsuite/20_util/hash/requirements/explicit_instantiation.cc @@ -40,6 +40,9 @@ template class std::hash; template class std::hash; template class std::hash; template class std::hash; +#if __cplusplus > 201402L +template class std::hash; +#endif #ifdef _GLIBCXX_USE_WCHAR_T template class std::hash; --TKDEsImF70pdVIl+--