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 // template <class InputIterator> 15 // set(InputIterator first, InputIterator last, 16 // const value_compare& comp, const allocator_type& a); 17 // 18 // template <class InputIterator> 19 // set(InputIterator first, InputIterator last, 20 // const allocator_type& a); 21 22 #include <set> 23 #include <cassert> 24 25 #include "test_iterators.h" 26 #include "../../../test_compare.h" 27 #include "test_allocator.h" 28 29 int main() 30 { 31 { 32 typedef int V; 33 V ar[] = 34 { 35 1, 36 1, 37 1, 38 2, 39 2, 40 2, 41 3, 42 3, 43 3 44 }; 45 typedef test_compare<std::less<V> > C; 46 typedef test_allocator<V> A; 47 std::set<V, C, A> m(input_iterator<const V*>(ar), 48 input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])), 49 C(5), A(7)); 50 assert(m.value_comp() == C(5)); 51 assert(m.get_allocator() == A(7)); 52 assert(m.size() == 3); 53 assert(distance(m.begin(), m.end()) == 3); 54 assert(*m.begin() == 1); 55 assert(*next(m.begin()) == 2); 56 assert(*next(m.begin(), 2) == 3); 57 } 58 #if _LIBCPP_STD_VER > 11 59 { 60 typedef int V; 61 V ar[] = 62 { 63 1, 64 1, 65 1, 66 2, 67 2, 68 2, 69 3, 70 3, 71 3 72 }; 73 typedef test_allocator<V> A; 74 typedef test_compare<std::less<int> > C; 75 A a(7); 76 std::set<V, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a); 77 78 assert(m.size() == 3); 79 assert(distance(m.begin(), m.end()) == 3); 80 assert(*m.begin() == 1); 81 assert(*next(m.begin()) == 2); 82 assert(*next(m.begin(), 2) == 3); 83 assert(m.get_allocator() == a); 84 } 85 #endif 86 } 87