Home | History | Annotate | Download | only in multimap.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 multimap
     15 
     16 // multimap(initializer_list<value_type> il, const key_compare& comp = key_compare());
     17 
     18 #include <map>
     19 #include <cassert>
     20 
     21 #include "min_allocator.h"
     22 
     23 int main()
     24 {
     25     {
     26     typedef std::multimap<int, double> C;
     27     typedef C::value_type V;
     28     C 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     {
     54     typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C;
     55     typedef C::value_type V;
     56     C m =
     57            {
     58                {1, 1},
     59                {1, 1.5},
     60                {1, 2},
     61                {2, 1},
     62                {2, 1.5},
     63                {2, 2},
     64                {3, 1},
     65                {3, 1.5},
     66                {3, 2}
     67            };
     68     assert(m.size() == 9);
     69     assert(distance(m.begin(), m.end()) == 9);
     70     C::const_iterator i = m.cbegin();
     71     assert(*i == V(1, 1));
     72     assert(*++i == V(1, 1.5));
     73     assert(*++i == V(1, 2));
     74     assert(*++i == V(2, 1));
     75     assert(*++i == V(2, 1.5));
     76     assert(*++i == V(2, 2));
     77     assert(*++i == V(3, 1));
     78     assert(*++i == V(3, 1.5));
     79     assert(*++i == V(3, 2));
     80     }
     81 }
     82