1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// <unordered_set>
10
11// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
12// class Alloc = allocator<Value>>
13// class unordered_multiset
14
15// size_type bucket(const key_type& __k) const;
16
17#include <unordered_set>
18#include <cassert>
19
20#include "test_macros.h"
21#include "min_allocator.h"
22
23int main(int, char**)
24{
25 {
26 typedef std::unordered_multiset<int> C;
27 typedef int P;
28 P a[] =
29 {
30 P(1),
31 P(2),
32 P(3),
33 P(4),
34 P(1),
35 P(2)
36 };
37 const C c(std::begin(arr&: a), std::end(arr&: a));
38 std::size_t bc = c.bucket_count();
39 assert(bc >= 7);
40 for (std::size_t i = 0; i < 13; ++i)
41 LIBCPP_ASSERT(c.bucket(key: i) == i % bc);
42 }
43#if TEST_STD_VER >= 11
44 {
45 typedef std::unordered_multiset<int, std::hash<int>,
46 std::equal_to<int>, min_allocator<int>> C;
47 typedef int P;
48 P a[] =
49 {
50 P(1),
51 P(2),
52 P(3),
53 P(4),
54 P(1),
55 P(2)
56 };
57 const C c(std::begin(a), std::end(a));
58 std::size_t bc = c.bucket_count();
59 assert(bc >= 7);
60 for (std::size_t i = 0; i < 13; ++i)
61 LIBCPP_ASSERT(c.bucket(i) == i % bc);
62 }
63#endif
64
65 return 0;
66}
67

source code of libcxx/test/std/containers/unord/unord.multiset/bucket.pass.cpp