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 // <unordered_map> 11 12 // template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, 13 // class Alloc = allocator<pair<const Key, T>>> 14 // class unordered_map 15 16 // pair<iterator, bool> insert(const value_type& x); 17 18 #include <unordered_map> 19 #include <cassert> 20 21 int main() 22 { 23 { 24 typedef std::unordered_map<double, int> C; 25 typedef std::pair<C::iterator, bool> R; 26 typedef C::value_type P; 27 C c; 28 R r = c.insert(P(3.5, 3)); 29 assert(r.second); 30 assert(c.size() == 1); 31 assert(r.first->first == 3.5); 32 assert(r.first->second == 3); 33 34 r = c.insert(P(3.5, 4)); 35 assert(!r.second); 36 assert(c.size() == 1); 37 assert(r.first->first == 3.5); 38 assert(r.first->second == 3); 39 40 r = c.insert(P(4.5, 4)); 41 assert(r.second); 42 assert(c.size() == 2); 43 assert(r.first->first == 4.5); 44 assert(r.first->second == 4); 45 46 r = c.insert(P(5.5, 4)); 47 assert(r.second); 48 assert(c.size() == 3); 49 assert(r.first->first == 5.5); 50 assert(r.first->second == 4); 51 } 52 } 53