Home | History | Annotate | Download | only in unord.map.modifiers
      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 // <unordered_map>
     13 
     14 // template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
     15 //           class Alloc = allocator<pair<const Key, T>>>
     16 // class unordered_map
     17 
     18 // void insert(initializer_list<value_type> il);
     19 
     20 #include <unordered_map>
     21 #include <string>
     22 #include <cassert>
     23 
     24 #include "test_iterators.h"
     25 #include "min_allocator.h"
     26 
     27 int main()
     28 {
     29     {
     30         typedef std::unordered_map<int, std::string> C;
     31         typedef std::pair<int, std::string> P;
     32         C c;
     33         c.insert(
     34                     {
     35                         P(1, "one"),
     36                         P(2, "two"),
     37                         P(3, "three"),
     38                         P(4, "four"),
     39                         P(1, "four"),
     40                         P(2, "four"),
     41                     }
     42                 );
     43         assert(c.size() == 4);
     44         assert(c.at(1) == "one");
     45         assert(c.at(2) == "two");
     46         assert(c.at(3) == "three");
     47         assert(c.at(4) == "four");
     48     }
     49     {
     50         typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
     51                             min_allocator<std::pair<const int, std::string>>> C;
     52         typedef std::pair<int, std::string> P;
     53         C c;
     54         c.insert(
     55                     {
     56                         P(1, "one"),
     57                         P(2, "two"),
     58                         P(3, "three"),
     59                         P(4, "four"),
     60                         P(1, "four"),
     61                         P(2, "four"),
     62                     }
     63                 );
     64         assert(c.size() == 4);
     65         assert(c.at(1) == "one");
     66         assert(c.at(2) == "two");
     67         assert(c.at(3) == "three");
     68         assert(c.at(4) == "four");
     69     }
     70 }
     71