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