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 "MoveOnly.h" 22 #include "min_allocator.h" 23 24 int main() 25 { 26 { 27 typedef std::unordered_multiset<double> C; 28 typedef C::iterator R; 29 typedef double P; 30 C c; 31 R r = c.insert(P(3.5)); 32 assert(c.size() == 1); 33 assert(*r == 3.5); 34 35 r = c.insert(P(3.5)); 36 assert(c.size() == 2); 37 assert(*r == 3.5); 38 39 r = c.insert(P(4.5)); 40 assert(c.size() == 3); 41 assert(*r == 4.5); 42 43 r = c.insert(P(5.5)); 44 assert(c.size() == 4); 45 assert(*r == 5.5); 46 } 47 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 48 { 49 typedef std::unordered_multiset<MoveOnly> C; 50 typedef C::iterator R; 51 typedef MoveOnly P; 52 C c; 53 R r = c.insert(P(3)); 54 assert(c.size() == 1); 55 assert(*r == 3); 56 57 r = c.insert(P(3)); 58 assert(c.size() == 2); 59 assert(*r == 3); 60 61 r = c.insert(P(4)); 62 assert(c.size() == 3); 63 assert(*r == 4); 64 65 r = c.insert(P(5)); 66 assert(c.size() == 4); 67 assert(*r == 5); 68 } 69 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 70 #if __cplusplus >= 201103L 71 { 72 typedef std::unordered_multiset<double, std::hash<double>, 73 std::equal_to<double>, min_allocator<double>> C; 74 typedef C::iterator R; 75 typedef double P; 76 C c; 77 R r = c.insert(P(3.5)); 78 assert(c.size() == 1); 79 assert(*r == 3.5); 80 81 r = c.insert(P(3.5)); 82 assert(c.size() == 2); 83 assert(*r == 3.5); 84 85 r = c.insert(P(4.5)); 86 assert(c.size() == 3); 87 assert(*r == 4.5); 88 89 r = c.insert(P(5.5)); 90 assert(c.size() == 4); 91 assert(*r == 5.5); 92 } 93 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 94 { 95 typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, 96 std::equal_to<MoveOnly>, min_allocator<MoveOnly>> C; 97 typedef C::iterator R; 98 typedef MoveOnly P; 99 C c; 100 R r = c.insert(P(3)); 101 assert(c.size() == 1); 102 assert(*r == 3); 103 104 r = c.insert(P(3)); 105 assert(c.size() == 2); 106 assert(*r == 3); 107 108 r = c.insert(P(4)); 109 assert(c.size() == 3); 110 assert(*r == 4); 111 112 r = c.insert(P(5)); 113 assert(c.size() == 4); 114 assert(*r == 5); 115 } 116 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 117 #endif 118 } 119