1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <set>
10 
11 // class set
12 
13 // template <class InputIterator>
14 //   void insert(InputIterator first, InputIterator last);
15 
16 #include <set>
17 #include <cassert>
18 
19 #include "test_iterators.h"
20 #include "min_allocator.h"
21 
22 int main(int, char**)
23 {
24     {
25         typedef std::set<int> M;
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         M m;
40         m.insert(input_iterator<const V*>(ar),
41                  input_iterator<const V*>(ar + sizeof(ar)/sizeof(ar[0])));
42         assert(m.size() == 3);
43         assert(*m.begin() == 1);
44         assert(*next(m.begin()) == 2);
45         assert(*next(m.begin(), 2) == 3);
46     }
47 #if TEST_STD_VER >= 11
48     {
49         typedef std::set<int, std::less<int>, min_allocator<int>> M;
50         typedef int V;
51         V ar[] =
52         {
53             1,
54             1,
55             1,
56             2,
57             2,
58             2,
59             3,
60             3,
61             3
62         };
63         M m;
64         m.insert(input_iterator<const V*>(ar),
65                  input_iterator<const V*>(ar + sizeof(ar)/sizeof(ar[0])));
66         assert(m.size() == 3);
67         assert(*m.begin() == 1);
68         assert(*next(m.begin()) == 2);
69         assert(*next(m.begin(), 2) == 3);
70     }
71 #endif
72 
73   return 0;
74 }
75