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 // <map>
11
12 // class multimap
13
14 // multimap& operator=(initializer_list<value_type> il);
15
16 #include <map>
17 #include <cassert>
18
19 #include "min_allocator.h"
20
main()21 int main()
22 {
23 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
24 {
25 typedef std::multimap<int, double> C;
26 typedef C::value_type V;
27 C m = {{20, 1}};
28 m =
29 {
30 {1, 1},
31 {1, 1.5},
32 {1, 2},
33 {2, 1},
34 {2, 1.5},
35 {2, 2},
36 {3, 1},
37 {3, 1.5},
38 {3, 2}
39 };
40 assert(m.size() == 9);
41 assert(distance(m.begin(), m.end()) == 9);
42 C::const_iterator i = m.cbegin();
43 assert(*i == V(1, 1));
44 assert(*++i == V(1, 1.5));
45 assert(*++i == V(1, 2));
46 assert(*++i == V(2, 1));
47 assert(*++i == V(2, 1.5));
48 assert(*++i == V(2, 2));
49 assert(*++i == V(3, 1));
50 assert(*++i == V(3, 1.5));
51 assert(*++i == V(3, 2));
52 }
53 #if __cplusplus >= 201103L
54 {
55 typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C;
56 typedef C::value_type V;
57 C m = {{20, 1}};
58 m =
59 {
60 {1, 1},
61 {1, 1.5},
62 {1, 2},
63 {2, 1},
64 {2, 1.5},
65 {2, 2},
66 {3, 1},
67 {3, 1.5},
68 {3, 2}
69 };
70 assert(m.size() == 9);
71 assert(distance(m.begin(), m.end()) == 9);
72 C::const_iterator i = m.cbegin();
73 assert(*i == V(1, 1));
74 assert(*++i == V(1, 1.5));
75 assert(*++i == V(1, 2));
76 assert(*++i == V(2, 1));
77 assert(*++i == V(2, 1.5));
78 assert(*++i == V(2, 2));
79 assert(*++i == V(3, 1));
80 assert(*++i == V(3, 1.5));
81 assert(*++i == V(3, 2));
82 }
83 #endif
84 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
85 }
86