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 set 13 14 // set(set&& s); 15 16 #include <set> 17 #include <cassert> 18 19 #include "../../../test_compare.h" 20 #include "../../../test_allocator.h" 21 22 int main() 23 { 24 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 25 { 26 typedef int V; 27 typedef test_compare<std::less<int> > C; 28 typedef test_allocator<V> A; 29 std::set<int, C, A> mo(C(5), A(7)); 30 std::set<int, C, A> m = std::move(mo); 31 assert(m.get_allocator() == A(7)); 32 assert(m.key_comp() == C(5)); 33 assert(m.size() == 0); 34 assert(distance(m.begin(), m.end()) == 0); 35 36 assert(mo.get_allocator() == A(7)); 37 assert(mo.key_comp() == C(5)); 38 assert(mo.size() == 0); 39 assert(distance(mo.begin(), mo.end()) == 0); 40 } 41 { 42 typedef int V; 43 V ar[] = 44 { 45 1, 46 1, 47 1, 48 2, 49 2, 50 2, 51 3, 52 3, 53 3 54 }; 55 typedef test_compare<std::less<int> > C; 56 typedef test_allocator<V> A; 57 std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); 58 std::set<int, C, A> m = std::move(mo); 59 assert(m.get_allocator() == A(7)); 60 assert(m.key_comp() == C(5)); 61 assert(m.size() == 3); 62 assert(distance(m.begin(), m.end()) == 3); 63 assert(*m.begin() == 1); 64 assert(*next(m.begin()) == 2); 65 assert(*next(m.begin(), 2) == 3); 66 67 assert(mo.get_allocator() == A(7)); 68 assert(mo.key_comp() == C(5)); 69 assert(mo.size() == 0); 70 assert(distance(mo.begin(), mo.end()) == 0); 71 } 72 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 73 } 74