Debian Codegraph @

libcxx/test/std/containers/unord/unord.multiset/find_const.pass.cpp

raw
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 // const_iterator find(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
23 int main(int, char**)
24 {
25 {
26 typedef std::unordered_multiset<int> C;
27 typedef int P;
28 P a[] =
29 {
30 P(10),
31 P(20),
32 P(30),
33 P(40),
34 P(50),
35 P(60),
36 P(70),
37 P(80)
38 };
39 const C c(std::begin(a), std::end(a));
40 C::const_iterator i = c.find(30);
41 assert(*i == 30);
42 i = c.find(5);
43 assert(i == c.cend());
44 }
45 #if TEST_STD_VER >= 11
46 {
47 typedef std::unordered_multiset<int, std::hash<int>,
48 std::equal_to<int>, min_allocator<int>> C;
49 typedef int P;
50 P a[] =
51 {
52 P(10),
53 P(20),
54 P(30),
55 P(40),
56 P(50),
57 P(60),
58 P(70),
59 P(80)
60 };
61 const C c(std::begin(a), std::end(a));
62 C::const_iterator i = c.find(30);
63 assert(*i == 30);
64 i = c.find(5);
65 assert(i == c.cend());
66 }
67 #endif
68
69 return 0;
70 }