1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <unordered_set> 11 12 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>, 13 // class Alloc = allocator<Value>> 14 // class unordered_multiset 15 16 // iterator insert(value_type&& x); 17 18 #include <unordered_set> 19 #include <cassert> 20 21 #include "test_macros.h" 22 #include "MoveOnly.h" 23 #include "min_allocator.h" 24 25 int main() 26 { 27 { 28 typedef std::unordered_multiset<double> C; 29 typedef C::iterator R; 30 typedef double P; 31 C c; 32 R r = c.insert(P(3.5)); 33 assert(c.size() == 1); 34 assert(*r == 3.5); 35 36 r = c.insert(P(3.5)); 37 assert(c.size() == 2); 38 assert(*r == 3.5); 39 40 r = c.insert(P(4.5)); 41 assert(c.size() == 3); 42 assert(*r == 4.5); 43 44 r = c.insert(P(5.5)); 45 assert(c.size() == 4); 46 assert(*r == 5.5); 47 } 48 #if TEST_STD_VER >= 11 49 { 50 typedef std::unordered_multiset<MoveOnly> C; 51 typedef C::iterator R; 52 typedef MoveOnly P; 53 C c; 54 R r = c.insert(P(3)); 55 assert(c.size() == 1); 56 assert(*r == 3); 57 58 r = c.insert(P(3)); 59 assert(c.size() == 2); 60 assert(*r == 3); 61 62 r = c.insert(P(4)); 63 assert(c.size() == 3); 64 assert(*r == 4); 65 66 r = c.insert(P(5)); 67 assert(c.size() == 4); 68 assert(*r == 5); 69 } 70 { 71 typedef std::unordered_multiset<double, std::hash<double>, 72 std::equal_to<double>, min_allocator<double>> C; 73 typedef C::iterator R; 74 typedef double P; 75 C c; 76 R r = c.insert(P(3.5)); 77 assert(c.size() == 1); 78 assert(*r == 3.5); 79 80 r = c.insert(P(3.5)); 81 assert(c.size() == 2); 82 assert(*r == 3.5); 83 84 r = c.insert(P(4.5)); 85 assert(c.size() == 3); 86 assert(*r == 4.5); 87 88 r = c.insert(P(5.5)); 89 assert(c.size() == 4); 90 assert(*r == 5.5); 91 } 92 { 93 typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, 94 std::equal_to<MoveOnly>, min_allocator<MoveOnly>> C; 95 typedef C::iterator R; 96 typedef MoveOnly P; 97 C c; 98 R r = c.insert(P(3)); 99 assert(c.size() == 1); 100 assert(*r == 3); 101 102 r = c.insert(P(3)); 103 assert(c.size() == 2); 104 assert(*r == 3); 105 106 r = c.insert(P(4)); 107 assert(c.size() == 3); 108 assert(*r == 4); 109 110 r = c.insert(P(5)); 111 assert(c.size() == 4); 112 assert(*r == 5); 113 } 114 #endif // TEST_STD_VER >= 11 115 } 116