insert_iter_iter.pass.cpp revision b64f8b07c104c6cc986570ac8ee0ed16a9f23976
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//   void insert(InputIterator first, InputIterator last);
16
17#include <set>
18#include <cassert>
19
20#include "../../iterators.h"
21
22int main()
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}
48