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