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_multimap 15 16 // template <class... Args> 17 // iterator emplace(Args&&... args); 18 19 #include <unordered_map> 20 #include <cassert> 21 22 #include "../../../Emplaceable.h" 23 #include "min_allocator.h" 24 25 int main() 26 { 27 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 28 { 29 typedef std::unordered_multimap<int, Emplaceable> C; 30 typedef C::iterator R; 31 C c; 32 R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3), 33 std::forward_as_tuple()); 34 assert(c.size() == 1); 35 assert(r->first == 3); 36 assert(r->second == Emplaceable()); 37 38 r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6))); 39 assert(c.size() == 2); 40 assert(r->first == 4); 41 assert(r->second == Emplaceable(5, 6)); 42 43 r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5), 44 std::forward_as_tuple(6, 7)); 45 assert(c.size() == 3); 46 assert(r->first == 5); 47 assert(r->second == Emplaceable(6, 7)); 48 } 49 #if __cplusplus >= 201103L 50 { 51 typedef std::unordered_multimap<int, Emplaceable, std::hash<int>, std::equal_to<int>, 52 min_allocator<std::pair<const int, Emplaceable>>> C; 53 typedef C::iterator R; 54 C c; 55 R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3), 56 std::forward_as_tuple()); 57 assert(c.size() == 1); 58 assert(r->first == 3); 59 assert(r->second == Emplaceable()); 60 61 r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6))); 62 assert(c.size() == 2); 63 assert(r->first == 4); 64 assert(r->second == Emplaceable(5, 6)); 65 66 r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5), 67 std::forward_as_tuple(6, 7)); 68 assert(c.size() == 3); 69 assert(r->first == 5); 70 assert(r->second == Emplaceable(6, 7)); 71 } 72 #endif 73 #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 74 } 75