[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / containers / associative / map / map.modifiers / extract_key.pass.cpp
blobc0ffa343497e2ecabcda247120942222f448fb56
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, c++11, c++14
11 // <map>
13 // class map
15 // node_type extract(key_type const&);
17 #include <map>
18 #include "test_macros.h"
19 #include "min_allocator.h"
20 #include "Counter.h"
22 template <class Container, class KeyTypeIter>
23 void test(Container& c, KeyTypeIter first, KeyTypeIter last)
25 std::size_t sz = c.size();
26 assert((std::size_t)std::distance(first, last) == sz);
28 for (KeyTypeIter copy = first; copy != last; ++copy)
30 typename Container::node_type t = c.extract(*copy);
31 assert(!t.empty());
32 --sz;
33 assert(t.key() == *copy);
34 t.key() = *first; // We should be able to mutate key.
35 assert(t.key() == *first);
36 assert(t.get_allocator() == c.get_allocator());
37 assert(sz == c.size());
40 assert(c.size() == 0);
42 for (KeyTypeIter copy = first; copy != last; ++copy)
44 typename Container::node_type t = c.extract(*copy);
45 assert(t.empty());
49 int main(int, char**)
52 std::map<int, int> m = {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
53 int keys[] = {1, 2, 3, 4, 5, 6};
54 test(m, std::begin(keys), std::end(keys));
58 std::map<Counter<int>, Counter<int>> m =
59 {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
61 Counter<int> keys[] = {1, 2, 3, 4, 5, 6};
62 assert(Counter_base::gConstructed == 12+6);
63 test(m, std::begin(keys), std::end(keys));
65 assert(Counter_base::gConstructed == 0);
69 using min_alloc_map =
70 std::map<int, int, std::less<int>,
71 min_allocator<std::pair<const int, int>>>;
72 min_alloc_map m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}};
73 int keys[] = {1, 2, 3, 4, 5, 6};
74 test(m, std::begin(keys), std::end(keys));
77 return 0;