]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/19_diagnostics/error_condition/hash.cc
1 // Copyright (C) 2019-2021 Free Software Foundation, Inc.
3 // This file is part of the GNU ISO C++ Library. This library is free
4 // software; you can redistribute it and/or modify it under the
5 // terms of the GNU General Public License as published by the
6 // Free Software Foundation; either version 3, or (at your option)
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License along
15 // with this library; see the file COPYING3. If not see
16 // <http://www.gnu.org/licenses/>.
18 // { dg-options "-std=gnu++17" }
19 // { dg-do run { target c++17 } }
21 #include <system_error>
22 #include <testsuite_hooks.h>
24 struct error_cat
: std::error_category
26 error_cat(std::string s
) : _name(s
) { }
28 const char* name() const noexcept override
{ return _name
.c_str(); }
29 std::string
message(int) const override
{ return "error"; }
35 std::hash
<std::error_condition
> h
;
36 error_cat
kitty("kitty"), moggy("moggy");
37 std::error_condition
cond1(99, kitty
);
38 VERIFY( h(cond1
) == h(cond1
) );
39 std::error_condition
cond2(99, kitty
);
40 VERIFY( h(cond1
) == h(cond2
) );
41 std::error_condition
cond3(88, kitty
);
42 VERIFY( h(cond1
) != h(cond3
) );
43 std::error_condition
cond4(99, moggy
);
44 VERIFY( h(cond1
) != h(cond4
) );