[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / containers / unord / unord.map / unord.map.modifiers / emplace.pass.cpp
blob11bbaf039b5383be73682868d89281de47a2c642
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03
11 // <unordered_map>
13 // template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
14 // class Alloc = allocator<pair<const Key, T>>>
15 // class unordered_map
17 // template <class... Args>
18 // pair<iterator, bool> emplace(Args&&... args);
20 #include <unordered_map>
21 #include <cassert>
23 #include "test_macros.h"
24 #include "../../../Emplaceable.h"
25 #include "min_allocator.h"
27 int main(int, char**)
30 typedef std::unordered_map<int, Emplaceable> C;
31 typedef std::pair<C::iterator, bool> R;
32 C c;
33 R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
34 std::forward_as_tuple());
35 assert(r.second);
36 assert(c.size() == 1);
37 assert(r.first->first == 3);
38 assert(r.first->second == Emplaceable());
40 r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
41 assert(r.second);
42 assert(c.size() == 2);
43 assert(r.first->first == 4);
44 assert(r.first->second == Emplaceable(5, 6));
46 r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5),
47 std::forward_as_tuple(6, 7));
48 assert(r.second);
49 assert(c.size() == 3);
50 assert(r.first->first == 5);
51 assert(r.first->second == Emplaceable(6, 7));
54 typedef std::unordered_map<int, Emplaceable, std::hash<int>, std::equal_to<int>,
55 min_allocator<std::pair<const int, Emplaceable>>> C;
56 typedef std::pair<C::iterator, bool> R;
57 C c;
58 R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
59 std::forward_as_tuple());
60 assert(r.second);
61 assert(c.size() == 1);
62 assert(r.first->first == 3);
63 assert(r.first->second == Emplaceable());
65 r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
66 assert(r.second);
67 assert(c.size() == 2);
68 assert(r.first->first == 4);
69 assert(r.first->second == Emplaceable(5, 6));
71 r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5),
72 std::forward_as_tuple(6, 7));
73 assert(r.second);
74 assert(c.size() == 3);
75 assert(r.first->first == 5);
76 assert(r.first->second == Emplaceable(6, 7));
79 return 0;