This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
On 04/05/19 15:36 +0100, Jonathan Wakely wrote:
On 03/05/19 23:42 +0100, Jonathan Wakely wrote:On 23/03/17 17:49 +0000, Jonathan Wakely wrote: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<error_condition> 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<error_code> 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<error_condition>.I see no reason for that, so I've removed the friend declaration and used the public member functions.I'm going to do the same for hash<error_code> too. It can also use the public members instead of being a friend.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.We never revisited that, and it's still only enabled for C++17 and up. I guess that's OK, but we could enabled it for C++11 and 14 on trunk if we want. Anybody care enough to argue for that?Here's what I've tested and will be committing.commit 90ca0fd91f5c65af370beb20af06bdca257aaf63 Author: Jonathan Wakely <jwakely@redhat.com> Date: Thu Mar 23 11:47:39 2017 +0000 Implement LWG 2686, std::hash<error_condition>, for C++17 2017-03-23 Daniel Kruegler <daniel.kruegler@gmail.com> Implement LWG 2686, Why is std::hash specialized for error_code, but not error_condition? * include/std/system_error (hash<error_condition>): Define for C++17. * testsuite/20_util/hash/operators/size_t.cc (hash<error_condition>): Instantiate test for error_condition. * testsuite/20_util/hash/requirements/explicit_instantiation.cc (hash<error_condition>): Instantiate hash<error_condition>.
I'm adding a similar test for hash<error_code> too. Tested powerpc64le-linux, committing to trunk shortly.
commit 4034dddf0dbfc20ff9069602a419a95b09de20f6
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Tue May 7 11:09:00 2019 +0100
Add test for std::hash<std::error_code>
Copied from 19_diagnostics/error_condition/hash.cc added recently.
* testsuite/19_diagnostics/error_code/hash.cc: New test.
diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_code/hash.cc b/libstdc++-v3/testsuite/19_diagnostics/error_code/hash.cc
new file mode 100644
index 00000000000..2014e676878
--- /dev/null
+++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/hash.cc
@@ -0,0 +1,50 @@
+// Copyright (C) 2019 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.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do run { target c++11 } }
+
+#include <system_error>
+#include <testsuite_hooks.h>
+
+struct error_cat : std::error_category
+{
+ error_cat(std::string s) : _name(s) { }
+ std::string _name;
+ const char* name() const noexcept override { return _name.c_str(); }
+ std::string message(int) const override { return "error"; }
+};
+
+void
+test01()
+{
+ std::hash<std::error_code> h;
+ error_cat kitty("kitty"), moggy("moggy");
+ std::error_code cond1(99, kitty);
+ VERIFY( h(cond1) == h(cond1) );
+ std::error_code cond2(99, kitty);
+ VERIFY( h(cond1) == h(cond2) );
+ std::error_code cond3(88, kitty);
+ VERIFY( h(cond1) != h(cond3) );
+ std::error_code cond4(99, moggy);
+ VERIFY( h(cond1) != h(cond4) );
+}
+
+int
+main()
+{
+ test01();
+}
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |