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