1*4684ddb6SLionel Sambuc //===----------------------------------------------------------------------===// 2*4684ddb6SLionel Sambuc // 3*4684ddb6SLionel Sambuc // The LLVM Compiler Infrastructure 4*4684ddb6SLionel Sambuc // 5*4684ddb6SLionel Sambuc // This file is dual licensed under the MIT and the University of Illinois Open 6*4684ddb6SLionel Sambuc // Source Licenses. See LICENSE.TXT for details. 7*4684ddb6SLionel Sambuc // 8*4684ddb6SLionel Sambuc //===----------------------------------------------------------------------===// 9*4684ddb6SLionel Sambuc 10*4684ddb6SLionel Sambuc // <set> 11*4684ddb6SLionel Sambuc 12*4684ddb6SLionel Sambuc // class set 13*4684ddb6SLionel Sambuc 14*4684ddb6SLionel Sambuc // set(const set& m); 15*4684ddb6SLionel Sambuc 16*4684ddb6SLionel Sambuc #include <set> 17*4684ddb6SLionel Sambuc #include <cassert> 18*4684ddb6SLionel Sambuc 19*4684ddb6SLionel Sambuc #include "../../../test_compare.h" 20*4684ddb6SLionel Sambuc #include "../../../test_allocator.h" 21*4684ddb6SLionel Sambuc 22*4684ddb6SLionel Sambuc int main() 23*4684ddb6SLionel Sambuc { 24*4684ddb6SLionel Sambuc { 25*4684ddb6SLionel Sambuc typedef int V; 26*4684ddb6SLionel Sambuc V ar[] = 27*4684ddb6SLionel Sambuc { 28*4684ddb6SLionel Sambuc 1, 29*4684ddb6SLionel Sambuc 1, 30*4684ddb6SLionel Sambuc 1, 31*4684ddb6SLionel Sambuc 2, 32*4684ddb6SLionel Sambuc 2, 33*4684ddb6SLionel Sambuc 2, 34*4684ddb6SLionel Sambuc 3, 35*4684ddb6SLionel Sambuc 3, 36*4684ddb6SLionel Sambuc 3 37*4684ddb6SLionel Sambuc }; 38*4684ddb6SLionel Sambuc typedef test_compare<std::less<int> > C; 39*4684ddb6SLionel Sambuc typedef test_allocator<V> A; 40*4684ddb6SLionel Sambuc std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); 41*4684ddb6SLionel Sambuc std::set<int, C, A> m = mo; 42*4684ddb6SLionel Sambuc assert(m.get_allocator() == A(7)); 43*4684ddb6SLionel Sambuc assert(m.key_comp() == C(5)); 44*4684ddb6SLionel Sambuc assert(m.size() == 3); 45*4684ddb6SLionel Sambuc assert(distance(m.begin(), m.end()) == 3); 46*4684ddb6SLionel Sambuc assert(*m.begin() == 1); 47*4684ddb6SLionel Sambuc assert(*next(m.begin()) == 2); 48*4684ddb6SLionel Sambuc assert(*next(m.begin(), 2) == 3); 49*4684ddb6SLionel Sambuc 50*4684ddb6SLionel Sambuc assert(mo.get_allocator() == A(7)); 51*4684ddb6SLionel Sambuc assert(mo.key_comp() == C(5)); 52*4684ddb6SLionel Sambuc assert(mo.size() == 3); 53*4684ddb6SLionel Sambuc assert(distance(mo.begin(), mo.end()) == 3); 54*4684ddb6SLionel Sambuc assert(*mo.begin() == 1); 55*4684ddb6SLionel Sambuc assert(*next(mo.begin()) == 2); 56*4684ddb6SLionel Sambuc assert(*next(mo.begin(), 2) == 3); 57*4684ddb6SLionel Sambuc } 58*4684ddb6SLionel Sambuc #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE 59*4684ddb6SLionel Sambuc { 60*4684ddb6SLionel Sambuc typedef int V; 61*4684ddb6SLionel Sambuc V ar[] = 62*4684ddb6SLionel Sambuc { 63*4684ddb6SLionel Sambuc 1, 64*4684ddb6SLionel Sambuc 1, 65*4684ddb6SLionel Sambuc 1, 66*4684ddb6SLionel Sambuc 2, 67*4684ddb6SLionel Sambuc 2, 68*4684ddb6SLionel Sambuc 2, 69*4684ddb6SLionel Sambuc 3, 70*4684ddb6SLionel Sambuc 3, 71*4684ddb6SLionel Sambuc 3 72*4684ddb6SLionel Sambuc }; 73*4684ddb6SLionel Sambuc typedef test_compare<std::less<int> > C; 74*4684ddb6SLionel Sambuc typedef other_allocator<V> A; 75*4684ddb6SLionel Sambuc std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7)); 76*4684ddb6SLionel Sambuc std::set<int, C, A> m = mo; 77*4684ddb6SLionel Sambuc assert(m.get_allocator() == A(-2)); 78*4684ddb6SLionel Sambuc assert(m.key_comp() == C(5)); 79*4684ddb6SLionel Sambuc assert(m.size() == 3); 80*4684ddb6SLionel Sambuc assert(distance(m.begin(), m.end()) == 3); 81*4684ddb6SLionel Sambuc assert(*m.begin() == 1); 82*4684ddb6SLionel Sambuc assert(*next(m.begin()) == 2); 83*4684ddb6SLionel Sambuc assert(*next(m.begin(), 2) == 3); 84*4684ddb6SLionel Sambuc 85*4684ddb6SLionel Sambuc assert(mo.get_allocator() == A(7)); 86*4684ddb6SLionel Sambuc assert(mo.key_comp() == C(5)); 87*4684ddb6SLionel Sambuc assert(mo.size() == 3); 88*4684ddb6SLionel Sambuc assert(distance(mo.begin(), mo.end()) == 3); 89*4684ddb6SLionel Sambuc assert(*mo.begin() == 1); 90*4684ddb6SLionel Sambuc assert(*next(mo.begin()) == 2); 91*4684ddb6SLionel Sambuc assert(*next(mo.begin(), 2) == 3); 92*4684ddb6SLionel Sambuc } 93*4684ddb6SLionel Sambuc #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE 94*4684ddb6SLionel Sambuc } 95