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
17 #include <set>
18 #include <cassert>
19
20 #include "test_iterators.h"
21 #include "min_allocator.h"
22
main()23 int main()
24 {
25 {
26 typedef int V;
27 V ar[] =
28 {
29 1,
30 1,
31 1,
32 2,
33 2,
34 2,
35 3,
36 3,
37 3
38 };
39 std::set<V> m(input_iterator<const int*>(ar),
40 input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0])));
41 assert(m.size() == 3);
42 assert(distance(m.begin(), m.end()) == 3);
43 assert(*m.begin() == 1);
44 assert(*next(m.begin()) == 2);
45 assert(*next(m.begin(), 2) == 3);
46 }
47 #if __cplusplus >= 201103L
48 {
49 typedef int V;
50 V ar[] =
51 {
52 1,
53 1,
54 1,
55 2,
56 2,
57 2,
58 3,
59 3,
60 3
61 };
62 std::set<V, std::less<int>, min_allocator<int>> m(input_iterator<const int*>(ar),
63 input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0])));
64 assert(m.size() == 3);
65 assert(distance(m.begin(), m.end()) == 3);
66 assert(*m.begin() == 1);
67 assert(*next(m.begin()) == 2);
68 assert(*next(m.begin(), 2) == 3);
69 }
70 #endif
71 }
72