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 // <map> 11 12 // class multimap 13 14 // template <class P> 15 // iterator insert(P&& p); 16 17 #include <map> 18 #include <cassert> 19 20 #include "../../../MoveOnly.h" 21 #include "min_allocator.h" 22 23 int main() 24 { 25 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 26 { 27 typedef std::multimap<int, MoveOnly> M; 28 typedef M::iterator R; 29 M m; 30 R r = m.insert(M::value_type(2, 2)); 31 assert(r == m.begin()); 32 assert(m.size() == 1); 33 assert(r->first == 2); 34 assert(r->second == 2); 35 36 r = m.insert(M::value_type(1, 1)); 37 assert(r == m.begin()); 38 assert(m.size() == 2); 39 assert(r->first == 1); 40 assert(r->second == 1); 41 42 r = m.insert(M::value_type(3, 3)); 43 assert(r == prev(m.end())); 44 assert(m.size() == 3); 45 assert(r->first == 3); 46 assert(r->second == 3); 47 48 r = m.insert(M::value_type(3, 3)); 49 assert(r == prev(m.end())); 50 assert(m.size() == 4); 51 assert(r->first == 3); 52 assert(r->second == 3); 53 } 54 #if __cplusplus >= 201103L 55 { 56 typedef std::multimap<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M; 57 typedef M::iterator R; 58 M m; 59 R r = m.insert(M::value_type(2, 2)); 60 assert(r == m.begin()); 61 assert(m.size() == 1); 62 assert(r->first == 2); 63 assert(r->second == 2); 64 65 r = m.insert(M::value_type(1, 1)); 66 assert(r == m.begin()); 67 assert(m.size() == 2); 68 assert(r->first == 1); 69 assert(r->second == 1); 70 71 r = m.insert(M::value_type(3, 3)); 72 assert(r == prev(m.end())); 73 assert(m.size() == 3); 74 assert(r->first == 3); 75 assert(r->second == 3); 76 77 r = m.insert(M::value_type(3, 3)); 78 assert(r == prev(m.end())); 79 assert(m.size() == 4); 80 assert(r->first == 3); 81 assert(r->second == 3); 82 } 83 #endif 84 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 85 } 86