blob: 4ed00c7124cc08383db6c88e3d349cf1bf66b7bc [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00007//
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
Marshall Clow83e2c4d2013-01-05 03:21:01 +000021#include "test_iterators.h"
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000022#include "../../../test_compare.h"
Marshall Clow1b921882013-12-03 00:18:10 +000023#include "test_allocator.h"
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000024
25int main()
26{
27 typedef int V;
28 V ar[] =
29 {
30 1,
31 1,
32 1,
33 2,
34 2,
35 2,
36 3,
37 3,
38 3
39 };
40 typedef test_compare<std::less<V> > C;
41 typedef test_allocator<V> A;
42 std::multiset<V, C, A> m(input_iterator<const V*>(ar),
43 input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])),
44 C(5), A(7));
45 assert(m.value_comp() == C(5));
46 assert(m.get_allocator() == A(7));
47 assert(m.size() == 9);
48 assert(distance(m.begin(), m.end()) == 9);
49 assert(*next(m.begin(), 0) == 1);
50 assert(*next(m.begin(), 1) == 1);
51 assert(*next(m.begin(), 2) == 1);
52 assert(*next(m.begin(), 3) == 2);
53 assert(*next(m.begin(), 4) == 2);
54 assert(*next(m.begin(), 5) == 2);
55 assert(*next(m.begin(), 6) == 3);
56 assert(*next(m.begin(), 7) == 3);
57 assert(*next(m.begin(), 8) == 3);
Marshall Clow24a7e332013-09-11 00:06:45 +000058#if _LIBCPP_STD_VER > 11
59 {
60 typedef int V;
61 V ar[] =
62 {
63 1,
64 1,
65 1,
66 2,
67 2,
68 2,
69 3,
70 3,
71 3
72 };
73 typedef test_allocator<V> A;
74 typedef test_compare<std::less<int> > C;
75 A a;
76 std::multiset<V, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a);
77
78 assert(m.size() == 9);
79 assert(distance(m.begin(), m.end()) == 9);
80 assert(*next(m.begin(), 0) == 1);
81 assert(*next(m.begin(), 1) == 1);
82 assert(*next(m.begin(), 2) == 1);
83 assert(*next(m.begin(), 3) == 2);
84 assert(*next(m.begin(), 4) == 2);
85 assert(*next(m.begin(), 5) == 2);
86 assert(*next(m.begin(), 6) == 3);
87 assert(*next(m.begin(), 7) == 3);
88 assert(*next(m.begin(), 8) == 3);
89 assert(m.get_allocator() == a);
90 }
91#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000092}