1 // { dg-do run { target c++11 } }
3 // Copyright (C) 2013-2025 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 #include <testsuite_hooks.h>
21 #include <unordered_set>
32 std::size_t operator() (int val
) const noexcept
33 { return val
% _M_modulo
; }
42 // static_assert(std::__cache_default<int, hash>::value,
43 // "Unexpected default cache value");
44 typedef std::unordered_set
<int, hash
> us_t
;
45 us_t
us1(10, hash(13));
46 us_t
us2(10, hash(7));
48 VERIFY( us1
.hash_function()._M_modulo
== 13 );
49 VERIFY( us2
.hash_function()._M_modulo
== 7 );
52 for (int i
= 0; i
!= nb
* us1
.hash_function()._M_modulo
; ++i
)
55 us_t::local_iterator lit
= us1
.begin(12);
56 us_t::local_iterator litend
= us1
.end(12);
57 VERIFY( std::distance(lit
, litend
) == nb
);
61 VERIFY( us1
.hash_function()._M_modulo
== 7 );
62 VERIFY( us2
.hash_function()._M_modulo
== 13 );
64 VERIFY( std::distance(lit
, litend
) == nb
);