Home | History | Annotate | Download | only in map.cons
      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 // UNSUPPORTED: c++98, c++03
     11 
     12 // <map>
     13 
     14 // class map
     15 
     16 // map& operator=(initializer_list<value_type> il);
     17 
     18 #include <map>
     19 #include <cassert>
     20 
     21 #include "min_allocator.h"
     22 
     23 int main()
     24 {
     25     {
     26     typedef std::pair<const int, double> V;
     27     std::map<int, double> m =
     28                             {
     29                                 {20, 1},
     30                             };
     31     m =
     32                             {
     33                                 {1, 1},
     34                                 {1, 1.5},
     35                                 {1, 2},
     36                                 {2, 1},
     37                                 {2, 1.5},
     38                                 {2, 2},
     39                                 {3, 1},
     40                                 {3, 1.5},
     41                                 {3, 2}
     42                             };
     43     assert(m.size() == 3);
     44     assert(distance(m.begin(), m.end()) == 3);
     45     assert(*m.begin() == V(1, 1));
     46     assert(*next(m.begin()) == V(2, 1));
     47     assert(*next(m.begin(), 2) == V(3, 1));
     48     }
     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 }
     74