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