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 29int main() 30{ 31 typedef int V; 32 V ar[] = 33 { 34 1, 35 1, 36 1, 37 2, 38 2, 39 2, 40 3, 41 3, 42 3 43 }; 44 typedef test_compare<std::less<V> > C; 45 typedef test_allocator<V> A; 46 std::set<V, C, A> m(input_iterator<const V*>(ar), 47 input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])), 48 C(5), A(7)); 49 assert(m.value_comp() == C(5)); 50 assert(m.get_allocator() == A(7)); 51 assert(m.size() == 3); 52 assert(distance(m.begin(), m.end()) == 3); 53 assert(*m.begin() == 1); 54 assert(*next(m.begin()) == 2); 55 assert(*next(m.begin(), 2) == 3); 56#if _LIBCPP_STD_VER > 11 57 { 58 typedef int V; 59 V ar[] = 60 { 61 1, 62 1, 63 1, 64 2, 65 2, 66 2, 67 3, 68 3, 69 3 70 }; 71 typedef test_allocator<V> A; 72 typedef test_compare<std::less<int> > C; 73 A a(7); 74 std::set<V, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a); 75 76 assert(m.size() == 3); 77 assert(distance(m.begin(), m.end()) == 3); 78 assert(*m.begin() == 1); 79 assert(*next(m.begin()) == 2); 80 assert(*next(m.begin(), 2) == 3); 81 assert(m.get_allocator() == a); 82 } 83#endif 84} 85