aboutsummaryrefslogtreecommitdiff
path: root/test/std/containers
diff options
context:
space:
mode:
Diffstat (limited to 'test/std/containers')
-rw-r--r--test/std/containers/associative/map/map.modifiers/extract_iterator.pass.cpp67
-rw-r--r--test/std/containers/associative/map/map.modifiers/extract_key.pass.cpp76
-rw-r--r--test/std/containers/associative/map/map.modifiers/insert_node_type.pass.cpp85
-rw-r--r--test/std/containers/associative/map/map.modifiers/insert_node_type_hint.pass.cpp64
-rw-r--r--test/std/containers/associative/multimap/multimap.modifiers/extract_iterator.pass.cpp67
-rw-r--r--test/std/containers/associative/multimap/multimap.modifiers/extract_key.pass.cpp76
-rw-r--r--test/std/containers/associative/multimap/multimap.modifiers/insert_node_type.pass.cpp78
-rw-r--r--test/std/containers/associative/multimap/multimap.modifiers/insert_node_type_hint.pass.cpp64
-rw-r--r--test/std/containers/associative/multiset/extract_iterator.pass.cpp60
-rw-r--r--test/std/containers/associative/multiset/extract_key.pass.cpp71
-rw-r--r--test/std/containers/associative/multiset/insert_node_type.pass.cpp77
-rw-r--r--test/std/containers/associative/multiset/insert_node_type_hint.pass.cpp59
-rw-r--r--test/std/containers/associative/set/extract_iterator.pass.cpp60
-rw-r--r--test/std/containers/associative/set/extract_key.pass.cpp71
-rw-r--r--test/std/containers/associative/set/insert_node_type.pass.cpp83
-rw-r--r--test/std/containers/associative/set/insert_node_type_hint.pass.cpp61
-rw-r--r--test/std/containers/container.node/node_handle.pass.cpp145
-rw-r--r--test/std/containers/unord/unord.map/unord.map.modifiers/extract_iterator.pass.cpp67
-rw-r--r--test/std/containers/unord/unord.map/unord.map.modifiers/extract_key.pass.cpp76
-rw-r--r--test/std/containers/unord/unord.map/unord.map.modifiers/insert_node_type.pass.cpp84
-rw-r--r--test/std/containers/unord/unord.map/unord.map.modifiers/insert_node_type_hint.pass.cpp64
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.modifiers/extract_iterator.pass.cpp67
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.modifiers/extract_key.pass.cpp77
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_node_type.pass.cpp77
-rw-r--r--test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_node_type_hint.pass.cpp63
-rw-r--r--test/std/containers/unord/unord.multiset/extract_iterator.pass.cpp60
-rw-r--r--test/std/containers/unord/unord.multiset/extract_key.pass.cpp71
-rw-r--r--test/std/containers/unord/unord.multiset/insert_node_type.pass.cpp76
-rw-r--r--test/std/containers/unord/unord.multiset/insert_node_type_hint.pass.cpp59
-rw-r--r--test/std/containers/unord/unord.set/extract_iterator.pass.cpp60
-rw-r--r--test/std/containers/unord/unord.set/extract_key.pass.cpp71
-rw-r--r--test/std/containers/unord/unord.set/insert_node_type.pass.cpp83
-rw-r--r--test/std/containers/unord/unord.set/insert_node_type_hint.pass.cpp61
33 files changed, 2380 insertions, 0 deletions
diff --git a/test/std/containers/associative/map/map.modifiers/extract_iterator.pass.cpp b/test/std/containers/associative/map/map.modifiers/extract_iterator.pass.cpp
new file mode 100644
index 000000000000..ea7fd890764b
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/extract_iterator.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <map>
+
+// class map
+
+// node_type extract(const_iterator);
+
+#include <map>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container>
+void test(Container& c)
+{
+ size_t sz = c.size();
+
+ auto some_key = c.cbegin()->first;
+
+ for (auto first = c.cbegin(); first != c.cend();)
+ {
+ auto key_value = first->first;
+ typename Container::node_type t = c.extract(first++);
+ --sz;
+ assert(t.key() == key_value);
+ t.key() = some_key;
+ assert(t.key() == some_key);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+}
+
+int main()
+{
+ {
+ using map_type = std::map<int, int>;
+ map_type m = {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ test(m);
+ }
+
+ {
+ std::map<Counter<int>, Counter<int>> m =
+ {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ assert(Counter_base::gConstructed == 12);
+ test(m);
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_map =
+ std::map<int, int, std::less<int>,
+ min_allocator<std::pair<const int, int>>>;
+ min_alloc_map m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}};
+ test(m);
+ }
+}
diff --git a/test/std/containers/associative/map/map.modifiers/extract_key.pass.cpp b/test/std/containers/associative/map/map.modifiers/extract_key.pass.cpp
new file mode 100644
index 000000000000..41cd09300b2a
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/extract_key.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <map>
+
+// class map
+
+// node_type extract(key_type const&);
+
+#include <map>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container, class KeyTypeIter>
+void test(Container& c, KeyTypeIter first, KeyTypeIter last)
+{
+ size_t sz = c.size();
+ assert((size_t)std::distance(first, last) == sz);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(!t.empty());
+ --sz;
+ assert(t.key() == *copy);
+ t.key() = *first; // We should be able to mutate key.
+ assert(t.key() == *first);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(t.empty());
+ }
+}
+
+int main()
+{
+ {
+ std::map<int, int> m = {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+
+ {
+ std::map<Counter<int>, Counter<int>> m =
+ {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ {
+ Counter<int> keys[] = {1, 2, 3, 4, 5, 6};
+ assert(Counter_base::gConstructed == 12+6);
+ test(m, std::begin(keys), std::end(keys));
+ }
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_map =
+ std::map<int, int, std::less<int>,
+ min_allocator<std::pair<const int, int>>>;
+ min_alloc_map m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+}
diff --git a/test/std/containers/associative/map/map.modifiers/insert_node_type.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_node_type.pass.cpp
new file mode 100644
index 000000000000..cc1704c30873
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/insert_node_type.pass.cpp
@@ -0,0 +1,85 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <map>
+
+// class map
+
+// insert_return_type insert(node_type&&);
+
+#include <map>
+#include <type_traits>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key,
+ typename Container::mapped_type const& mapped)
+{
+ static Container c;
+ auto p = c.insert({key, mapped});
+ assert(p.second);
+ return c.extract(p.first);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i, i + 1);
+ assert(!node.empty());
+ typename Container::insert_return_type irt = c.insert(std::move(node));
+ assert(node.empty());
+ assert(irt.inserted);
+ assert(irt.node.empty());
+ assert(irt.position->first == i && irt.position->second == i + 1);
+ }
+
+ assert(c.size() == 10);
+
+ { // Insert empty node.
+ typename Container::node_type def;
+ auto irt = c.insert(std::move(def));
+ assert(def.empty());
+ assert(!irt.inserted);
+ assert(irt.node.empty());
+ assert(irt.position == c.end());
+ }
+
+ { // Insert duplicate node.
+ typename Container::node_type dupl = nf(0, 42);
+ auto irt = c.insert(std::move(dupl));
+ assert(dupl.empty());
+ assert(!irt.inserted);
+ assert(!irt.node.empty());
+ assert(irt.position == c.find(0));
+ assert(irt.node.key() == 0 && irt.node.mapped() == 42);
+ }
+
+ assert(c.size() == 10);
+
+ for (int i = 0; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ assert(c[i] == i + 1);
+ }
+}
+
+int main()
+{
+ std::map<int, int> m;
+ test(m);
+ std::map<int, int, std::less<int>, min_allocator<std::pair<const int, int>>> m2;
+ test(m2);
+}
diff --git a/test/std/containers/associative/map/map.modifiers/insert_node_type_hint.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_node_type_hint.pass.cpp
new file mode 100644
index 000000000000..3c6b3e31af46
--- /dev/null
+++ b/test/std/containers/associative/map/map.modifiers/insert_node_type_hint.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <map>
+
+// class map
+
+// iterator insert(const_iterator hint, node_type&&);
+
+#include <map>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key,
+ typename Container::mapped_type const& mapped)
+{
+ static Container c;
+ auto p = c.insert({key, mapped});
+ assert(p.second);
+ return c.extract(p.first);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i, i + 1);
+ assert(!node.empty());
+ size_t prev = c.size();
+ auto it = c.insert(c.end(), std::move(node));
+ assert(node.empty());
+ assert(prev + 1 == c.size());
+ assert(it->first == i);
+ assert(it->second == i + 1);
+ }
+
+ assert(c.size() == 10);
+
+ for (int i = 0; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ assert(c[i] == i + 1);
+ }
+}
+
+int main()
+{
+ std::map<int, int> m;
+ test(m);
+ std::map<int, int, std::less<int>, min_allocator<std::pair<const int, int>>> m2;
+ test(m2);
+}
diff --git a/test/std/containers/associative/multimap/multimap.modifiers/extract_iterator.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/extract_iterator.pass.cpp
new file mode 100644
index 000000000000..3e00d2b98d70
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.modifiers/extract_iterator.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <map>
+
+// class multimap
+
+// node_type extract(const_iterator);
+
+#include <map>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container>
+void test(Container& c)
+{
+ size_t sz = c.size();
+
+ auto some_key = c.cbegin()->first;
+
+ for (auto first = c.cbegin(); first != c.cend();)
+ {
+ auto key_value = first->first;
+ typename Container::node_type t = c.extract(first++);
+ --sz;
+ assert(t.key() == key_value);
+ t.key() = some_key;
+ assert(t.key() == some_key);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+}
+
+int main()
+{
+ {
+ using map_type = std::multimap<int, int>;
+ map_type m = {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ test(m);
+ }
+
+ {
+ std::multimap<Counter<int>, Counter<int>> m =
+ {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ assert(Counter_base::gConstructed == 12);
+ test(m);
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_map =
+ std::multimap<int, int, std::less<int>,
+ min_allocator<std::pair<const int, int>>>;
+ min_alloc_map m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}};
+ test(m);
+ }
+}
diff --git a/test/std/containers/associative/multimap/multimap.modifiers/extract_key.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/extract_key.pass.cpp
new file mode 100644
index 000000000000..ca69cca6b0ec
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.modifiers/extract_key.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <map>
+
+// class multimap
+
+// node_type extract(key_type const&);
+
+#include <map>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container, class KeyTypeIter>
+void test(Container& c, KeyTypeIter first, KeyTypeIter last)
+{
+ size_t sz = c.size();
+ assert((size_t)std::distance(first, last) == sz);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(!t.empty());
+ --sz;
+ assert(t.key() == *copy);
+ t.key() = *first; // We should be able to mutate key.
+ assert(t.key() == *first);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(t.empty());
+ }
+}
+
+int main()
+{
+ {
+ std::multimap<int, int> m = {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+
+ {
+ std::multimap<Counter<int>, Counter<int>> m =
+ {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ {
+ Counter<int> keys[] = {1, 2, 3, 4, 5, 6};
+ assert(Counter_base::gConstructed == 12+6);
+ test(m, std::begin(keys), std::end(keys));
+ }
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_map =
+ std::multimap<int, int, std::less<int>,
+ min_allocator<std::pair<const int, int>>>;
+ min_alloc_map m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+}
diff --git a/test/std/containers/associative/multimap/multimap.modifiers/insert_node_type.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/insert_node_type.pass.cpp
new file mode 100644
index 000000000000..906770514196
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.modifiers/insert_node_type.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <map>
+
+// class multimap
+
+// iterator insert(node_type&&);
+
+#include <map>
+#include <type_traits>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key,
+ typename Container::mapped_type const& mapped)
+{
+ static Container c;
+ auto it = c.insert({key, mapped});
+ return c.extract(it);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i, i + 1);
+ assert(!node.empty());
+ typename Container::iterator it = c.insert(std::move(node));
+ assert(node.empty());
+ assert(it == c.find(i) && it != c.end());
+ }
+
+ assert(c.size() == 10);
+
+ { // Insert empty node.
+ typename Container::node_type def;
+ auto it = c.insert(std::move(def));
+ assert(def.empty());
+ assert(it == c.end());
+ }
+
+ { // Insert duplicate node.
+ typename Container::node_type dupl = nf(0, 42);
+ auto it = c.insert(std::move(dupl));
+ assert(dupl.empty());
+ assert(it != c.end());
+ assert(it->second == 42);
+ }
+
+ assert(c.size() == 11);
+ assert(c.count(0) == 2);
+ for (int i = 1; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ assert(c.find(i)->second == i + 1);
+ }
+}
+
+int main()
+{
+ std::multimap<int, int> m;
+ test(m);
+ std::multimap<int, int, std::less<int>, min_allocator<std::pair<const int, int>>> m2;
+ test(m2);
+}
diff --git a/test/std/containers/associative/multimap/multimap.modifiers/insert_node_type_hint.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/insert_node_type_hint.pass.cpp
new file mode 100644
index 000000000000..82e7d80c06e6
--- /dev/null
+++ b/test/std/containers/associative/multimap/multimap.modifiers/insert_node_type_hint.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <map>
+
+// class multimap
+
+// iterator insert(const_iterator hint, node_type&&);
+
+#include <map>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key,
+ typename Container::mapped_type const& mapped)
+{
+ static Container c;
+ auto it = c.insert({key, mapped});
+ return c.extract(it);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i, i + 1);
+ assert(!node.empty());
+ size_t prev = c.size();
+ auto it = c.insert(c.end(), std::move(node));
+ assert(node.empty());
+ assert(prev + 1 == c.size());
+ assert(it == c.find(i));
+ assert(it->first == i);
+ assert(it->second == i + 1);
+ }
+
+ assert(c.size() == 10);
+
+ for (int i = 0; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ assert(c.find(i)->second == i + 1);
+ }
+}
+
+int main()
+{
+ std::multimap<int, int> m;
+ test(m);
+ std::multimap<int, int, std::less<int>, min_allocator<std::pair<const int, int>>> m2;
+ test(m2);
+}
diff --git a/test/std/containers/associative/multiset/extract_iterator.pass.cpp b/test/std/containers/associative/multiset/extract_iterator.pass.cpp
new file mode 100644
index 000000000000..0f41169e9fe0
--- /dev/null
+++ b/test/std/containers/associative/multiset/extract_iterator.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <set>
+
+// class multiset
+
+// node_type extract(const_iterator);
+
+#include <set>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container>
+void test(Container& c)
+{
+ size_t sz = c.size();
+
+ for (auto first = c.cbegin(); first != c.cend();)
+ {
+ auto key_value = *first;
+ typename Container::node_type t = c.extract(first++);
+ --sz;
+ assert(t.value() == key_value);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+}
+
+int main()
+{
+ {
+ using set_type = std::multiset<int>;
+ set_type m = {1, 2, 3, 4, 5, 6};
+ test(m);
+ }
+
+ {
+ std::multiset<Counter<int>> m = {1, 2, 3, 4, 5, 6};
+ assert(Counter_base::gConstructed == 6);
+ test(m);
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_set = std::multiset<int, std::less<int>, min_allocator<int>>;
+ min_alloc_set m = {1, 2, 3, 4, 5, 6};
+ test(m);
+ }
+}
diff --git a/test/std/containers/associative/multiset/extract_key.pass.cpp b/test/std/containers/associative/multiset/extract_key.pass.cpp
new file mode 100644
index 000000000000..9ad0184100b6
--- /dev/null
+++ b/test/std/containers/associative/multiset/extract_key.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <set>
+
+// class multiset
+
+// node_type extract(key_type const&);
+
+#include <set>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container, class KeyTypeIter>
+void test(Container& c, KeyTypeIter first, KeyTypeIter last)
+{
+ size_t sz = c.size();
+ assert((size_t)std::distance(first, last) == sz);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(!t.empty());
+ --sz;
+ assert(t.value() == *copy);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(t.empty());
+ }
+}
+
+int main()
+{
+ {
+ std::multiset<int> m = {1, 2, 3, 4, 5, 6};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+
+ {
+ std::multiset<Counter<int>> m = {1, 2, 3, 4, 5, 6};
+ {
+ Counter<int> keys[] = {1, 2, 3, 4, 5, 6};
+ assert(Counter_base::gConstructed == 6+6);
+ test(m, std::begin(keys), std::end(keys));
+ }
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_set = std::multiset<int, std::less<int>, min_allocator<int>>;
+ min_alloc_set m = {1, 2, 3, 4, 5, 6};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+}
diff --git a/test/std/containers/associative/multiset/insert_node_type.pass.cpp b/test/std/containers/associative/multiset/insert_node_type.pass.cpp
new file mode 100644
index 000000000000..ca51ec9f0930
--- /dev/null
+++ b/test/std/containers/associative/multiset/insert_node_type.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <set>
+
+// class multiset
+
+// iterator insert(node_type&&);
+
+#include <set>
+#include <type_traits>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key)
+{
+ static Container c;
+ auto it = c.insert(key);
+ return c.extract(it);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i);
+ assert(!node.empty());
+ typename Container::iterator it = c.insert(std::move(node));
+ assert(node.empty());
+ assert(it == c.find(i) && it != c.end());
+ assert(*it == i);
+ assert(node.empty());
+ }
+
+ assert(c.size() == 10);
+
+ { // Insert empty node.
+ typename Container::node_type def;
+ auto it = c.insert(std::move(def));
+ assert(def.empty());
+ assert(it == c.end());
+ }
+
+ { // Insert duplicate node.
+ typename Container::node_type dupl = nf(0);
+ auto it = c.insert(std::move(dupl));
+ assert(*it == 0);
+ }
+
+ assert(c.size() == 11);
+
+ assert(c.count(0) == 2);
+ for (int i = 1; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ }
+}
+
+int main()
+{
+ std::multiset<int> m;
+ test(m);
+ std::multiset<int, std::less<int>, min_allocator<int>> m2;
+ test(m2);
+}
diff --git a/test/std/containers/associative/multiset/insert_node_type_hint.pass.cpp b/test/std/containers/associative/multiset/insert_node_type_hint.pass.cpp
new file mode 100644
index 000000000000..9d0af0653f6c
--- /dev/null
+++ b/test/std/containers/associative/multiset/insert_node_type_hint.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <set>
+
+// class multiset
+
+// iterator insert(const_iterator hint, node_type&&);
+
+#include <set>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key)
+{
+ static Container c;
+ auto it = c.insert(key);
+ return c.extract(it);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i);
+ assert(!node.empty());
+ size_t prev = c.size();
+ auto it = c.insert(c.end(), std::move(node));
+ assert(prev + 1 == c.size());
+ assert(*it == i);
+ }
+
+ assert(c.size() == 10);
+
+ for (int i = 0; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ }
+}
+
+int main()
+{
+ std::multiset<int> m;
+ test(m);
+ std::multiset<int, std::less<int>, min_allocator<int>> m2;
+ test(m2);
+}
diff --git a/test/std/containers/associative/set/extract_iterator.pass.cpp b/test/std/containers/associative/set/extract_iterator.pass.cpp
new file mode 100644
index 000000000000..ffcf71486883
--- /dev/null
+++ b/test/std/containers/associative/set/extract_iterator.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <set>
+
+// class set
+
+// node_type extract(const_iterator);
+
+#include <set>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container>
+void test(Container& c)
+{
+ size_t sz = c.size();
+
+ for (auto first = c.cbegin(); first != c.cend();)
+ {
+ auto key_value = *first;
+ typename Container::node_type t = c.extract(first++);
+ --sz;
+ assert(t.value() == key_value);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+}
+
+int main()
+{
+ {
+ using set_type = std::set<int>;
+ set_type m = {1, 2, 3, 4, 5, 6};
+ test(m);
+ }
+
+ {
+ std::set<Counter<int>> m = {1, 2, 3, 4, 5, 6};
+ assert(Counter_base::gConstructed == 6);
+ test(m);
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_set = std::set<int, std::less<int>, min_allocator<int>>;
+ min_alloc_set m = {1, 2, 3, 4, 5, 6};
+ test(m);
+ }
+}
diff --git a/test/std/containers/associative/set/extract_key.pass.cpp b/test/std/containers/associative/set/extract_key.pass.cpp
new file mode 100644
index 000000000000..1fb7ab9116eb
--- /dev/null
+++ b/test/std/containers/associative/set/extract_key.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <set>
+
+// class set
+
+// node_type extract(key_type const&);
+
+#include <set>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container, class KeyTypeIter>
+void test(Container& c, KeyTypeIter first, KeyTypeIter last)
+{
+ size_t sz = c.size();
+ assert((size_t)std::distance(first, last) == sz);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(!t.empty());
+ --sz;
+ assert(t.value() == *copy);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(t.empty());
+ }
+}
+
+int main()
+{
+ {
+ std::set<int> m = {1, 2, 3, 4, 5, 6};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+
+ {
+ std::set<Counter<int>> m = {1, 2, 3, 4, 5, 6};
+ {
+ Counter<int> keys[] = {1, 2, 3, 4, 5, 6};
+ assert(Counter_base::gConstructed == 6+6);
+ test(m, std::begin(keys), std::end(keys));
+ }
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_set = std::set<int, std::less<int>, min_allocator<int>>;
+ min_alloc_set m = {1, 2, 3, 4, 5, 6};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+}
diff --git a/test/std/containers/associative/set/insert_node_type.pass.cpp b/test/std/containers/associative/set/insert_node_type.pass.cpp
new file mode 100644
index 000000000000..4186f20e771f
--- /dev/null
+++ b/test/std/containers/associative/set/insert_node_type.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <set>
+
+// class set
+
+// insert_return_type insert(node_type&&);
+
+#include <set>
+#include <type_traits>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key)
+{
+ static Container c;
+ auto p = c.insert(key);
+ assert(p.second);
+ return c.extract(p.first);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i);
+ assert(!node.empty());
+ typename Container::insert_return_type irt = c.insert(std::move(node));
+ assert(node.empty());
+ assert(irt.inserted);
+ assert(irt.node.empty());
+ assert(*irt.position == i);
+ }
+
+ assert(c.size() == 10);
+
+ { // Insert empty node.
+ typename Container::node_type def;
+ auto irt = c.insert(std::move(def));
+ assert(def.empty());
+ assert(!irt.inserted);
+ assert(irt.node.empty());
+ assert(irt.position == c.end());
+ }
+
+ { // Insert duplicate node.
+ typename Container::node_type dupl = nf(0);
+ auto irt = c.insert(std::move(dupl));
+ assert(dupl.empty());
+ assert(!irt.inserted);
+ assert(!irt.node.empty());
+ assert(irt.position == c.find(0));
+ assert(irt.node.value() == 0);
+ }
+
+ assert(c.size() == 10);
+
+ for (int i = 0; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ }
+}
+
+int main()
+{
+ std::set<int> m;
+ test(m);
+ std::set<int, std::less<int>, min_allocator<int>> m2;
+ test(m2);
+}
diff --git a/test/std/containers/associative/set/insert_node_type_hint.pass.cpp b/test/std/containers/associative/set/insert_node_type_hint.pass.cpp
new file mode 100644
index 000000000000..761ceef6a4a1
--- /dev/null
+++ b/test/std/containers/associative/set/insert_node_type_hint.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <set>
+
+// class set
+
+// iterator insert(const_iterator hint, node_type&&);
+
+#include <set>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key)
+{
+ static Container c;
+ auto p = c.insert(key);
+ assert(p.second);
+ return c.extract(p.first);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i);
+ assert(!node.empty());
+ size_t prev = c.size();
+ auto it = c.insert(c.end(), std::move(node));
+ assert(node.empty());
+ assert(prev + 1 == c.size());
+ assert(*it == i);
+ }
+
+ assert(c.size() == 10);
+
+ for (int i = 0; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ }
+}
+
+int main()
+{
+ std::set<int> m;
+ test(m);
+ std::set<int, std::less<int>, min_allocator<int>> m2;
+ test(m2);
+}
diff --git a/test/std/containers/container.node/node_handle.pass.cpp b/test/std/containers/container.node/node_handle.pass.cpp
new file mode 100644
index 000000000000..6314ec1fb771
--- /dev/null
+++ b/test/std/containers/container.node/node_handle.pass.cpp
@@ -0,0 +1,145 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include <unordered_set>
+#include <unordered_map>
+#include <set>
+#include <map>
+#include "min_allocator.h"
+
+using namespace std;
+
+// [container.node.overview] Table 83.
+template <class K, class T, class C1, class C2, class H1, class H2, class E1, class E2, class A_set, class A_map>
+struct node_compatibility_table
+{
+ static constexpr bool value =
+ is_same_v<typename map<K, T, C1, A_map>::node_type, typename map<K, T, C2, A_map>::node_type> &&
+ is_same_v<typename map<K, T, C1, A_map>::node_type, typename multimap<K, T, C2, A_map>::node_type> &&
+ is_same_v<typename set<K, C1, A_set>::node_type, typename set<K, C2, A_set>::node_type> &&
+ is_same_v<typename set<K, C1, A_set>::node_type, typename multiset<K, C2, A_set>::node_type> &&
+ is_same_v<typename unordered_map<K, T, H1, E1, A_map>::node_type, typename unordered_map<K, T, H2, E2, A_map>::node_type> &&
+ is_same_v<typename unordered_map<K, T, H1, E1, A_map>::node_type, typename unordered_multimap<K, T, H2, E2, A_map>::node_type> &&
+ is_same_v<typename unordered_set<K, H1, E1, A_set>::node_type, typename unordered_set<K, H2, E2, A_set>::node_type> &&
+ is_same_v<typename unordered_set<K, H1, E1, A_set>::node_type, typename unordered_multiset<K, H2, E2, A_set>::node_type>;
+};
+
+template <class T> struct my_hash
+{
+ using argument_type = T;
+ using result_type = size_t;
+ my_hash() = default;
+ size_t operator()(const T&) const {return 0;}
+};
+
+template <class T> struct my_compare
+{
+ my_compare() = default;
+ bool operator()(const T&, const T&) const {return true;}
+};
+
+template <class T> struct my_equal
+{
+ my_equal() = default;
+ bool operator()(const T&, const T&) const {return true;}
+};
+
+struct Static
+{
+ Static() = default;
+ Static(const Static&) = delete;
+ Static(Static&&) = delete;
+ Static& operator=(const Static&) = delete;
+ Static& operator=(Static&&) = delete;
+};
+
+namespace std
+{
+template <> struct hash<Static>
+{
+ using argument_type = Static;
+ using result_type = size_t;
+ hash() = default;
+ size_t operator()(const Static&) const;
+};
+}
+
+static_assert(node_compatibility_table<
+ int, int, std::less<int>, std::less<int>, std::hash<int>,
+ std::hash<int>, std::equal_to<int>, std::equal_to<int>,
+ std::allocator<int>,
+ std::allocator<std::pair<const int, int>>>::value,
+ "");
+
+static_assert(
+ node_compatibility_table<int, int, std::less<int>, my_compare<int>,
+ std::hash<int>, my_hash<int>, std::equal_to<int>,
+ my_equal<int>, allocator<int>,
+ allocator<std::pair<const int, int>>>::value,
+ "");
+
+static_assert(node_compatibility_table<
+ Static, int, my_compare<Static>, std::less<Static>,
+ my_hash<Static>, std::hash<Static>, my_equal<Static>,
+ std::equal_to<Static>, min_allocator<Static>,
+ min_allocator<std::pair<const Static, int>>>::value,
+ "");
+
+template <class Container>
+void test_node_handle_operations()
+{
+ Container c;
+
+ typename Container::node_type nt1, nt2 = c.extract(c.emplace().first);
+ assert(nt2.get_allocator() == c.get_allocator());
+ assert(!nt2.empty());
+ assert(nt1.empty());
+ std::swap(nt1, nt2);
+ assert(nt1.get_allocator() == c.get_allocator());
+ assert(nt2.empty());
+}
+
+template <class Container>
+void test_node_handle_operations_multi()
+{
+ Container c;
+
+ typename Container::node_type nt1, nt2 = c.extract(c.emplace());
+ assert(nt2.get_allocator() == c.get_allocator());
+ assert(!nt2.empty());
+ assert(nt1.empty());
+ std::swap(nt1, nt2);
+ assert(nt1.get_allocator() == c.get_allocator());
+ assert(nt2.empty());
+}
+
+template <class Container>
+void test_insert_return_type()
+{
+ using irt_type = typename Container::insert_return_type;
+}
+
+int main()
+{
+ test_node_handle_operations<std::map<int, int>>();
+ test_node_handle_operations_multi<std::multimap<int, int>>();
+ test_node_handle_operations<std::set<int>>();
+ test_node_handle_operations_multi<std::multiset<int>>();
+ test_node_handle_operations<std::unordered_map<int, int>>();
+ test_node_handle_operations_multi<std::unordered_multimap<int, int>>();
+ test_node_handle_operations<std::unordered_set<int>>();
+ test_node_handle_operations_multi<std::unordered_multiset<int>>();
+
+ test_insert_return_type<std::map<int, int>>();
+ test_insert_return_type<std::set<int>>();
+ test_insert_return_type<std::unordered_map<int, int>>();
+ test_insert_return_type<std::unordered_set<int>>();
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.modifiers/extract_iterator.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/extract_iterator.pass.cpp
new file mode 100644
index 000000000000..4cc13ded23f8
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.modifiers/extract_iterator.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <unordered_map>
+
+// class unordered_map
+
+// node_type extract(const_iterator);
+
+#include <unordered_map>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container>
+void test(Container& c)
+{
+ size_t sz = c.size();
+
+ auto some_key = c.cbegin()->first;
+
+ for (auto first = c.cbegin(); first != c.cend();)
+ {
+ auto key_value = first->first;
+ typename Container::node_type t = c.extract(first++);
+ --sz;
+ assert(t.key() == key_value);
+ t.key() = some_key;
+ assert(t.key() == some_key);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+}
+
+int main()
+{
+ {
+ using map_type = std::unordered_map<int, int>;
+ map_type m = {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ test(m);
+ }
+
+ {
+ std::unordered_map<Counter<int>, Counter<int>> m =
+ {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ assert(Counter_base::gConstructed == 12);
+ test(m);
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_map =
+ std::unordered_map<int, int, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, int>>>;
+ min_alloc_map m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}};
+ test(m);
+ }
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.modifiers/extract_key.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/extract_key.pass.cpp
new file mode 100644
index 000000000000..25aa24888868
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.modifiers/extract_key.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <unordered_map>
+
+// class unordered_map
+
+// node_type extract(key_type const&);
+
+#include <unordered_map>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container, class KeyTypeIter>
+void test(Container& c, KeyTypeIter first, KeyTypeIter last)
+{
+ size_t sz = c.size();
+ assert((size_t)std::distance(first, last) == sz);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(!t.empty());
+ --sz;
+ assert(t.key() == *copy);
+ t.key() = *first; // We should be able to mutate key.
+ assert(t.key() == *first);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(t.empty());
+ }
+}
+
+int main()
+{
+ {
+ std::unordered_map<int, int> m = {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+
+ {
+ std::unordered_map<Counter<int>, Counter<int>> m =
+ {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ {
+ Counter<int> keys[] = {1, 2, 3, 4, 5, 6};
+ assert(Counter_base::gConstructed == 12+6);
+ test(m, std::begin(keys), std::end(keys));
+ }
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_map =
+ std::unordered_map<int, int, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, int>>>;
+ min_alloc_map m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.modifiers/insert_node_type.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_node_type.pass.cpp
new file mode 100644
index 000000000000..d434864885fe
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_node_type.pass.cpp
@@ -0,0 +1,84 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <unordered_map>
+
+// class unordered_map
+
+// insert_return_type insert(node_type&&);
+
+#include <unordered_map>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key,
+ typename Container::mapped_type const& mapped)
+{
+ static Container c;
+ auto p = c.insert({key, mapped});
+ assert(p.second);
+ return c.extract(p.first);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i, i + 1);
+ assert(!node.empty());
+ typename Container::insert_return_type irt = c.insert(std::move(node));
+ assert(node.empty());
+ assert(irt.inserted);
+ assert(irt.node.empty());
+ assert(irt.position->first == i && irt.position->second == i + 1);
+ }
+
+ assert(c.size() == 10);
+
+ { // Insert empty node.
+ typename Container::node_type def;
+ auto irt = c.insert(std::move(def));
+ assert(def.empty());
+ assert(!irt.inserted);
+ assert(irt.node.empty());
+ assert(irt.position == c.end());
+ }
+
+ { // Insert duplicate node.
+ typename Container::node_type dupl = nf(0, 42);
+ auto irt = c.insert(std::move(dupl));
+ assert(dupl.empty());
+ assert(!irt.inserted);
+ assert(!irt.node.empty());
+ assert(irt.position == c.find(0));
+ assert(irt.node.key() == 0 && irt.node.mapped() == 42);
+ }
+
+ assert(c.size() == 10);
+
+ for (int i = 0; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ assert(c[i] == i + 1);
+ }
+}
+
+int main()
+{
+ std::unordered_map<int, int> m;
+ test(m);
+ std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, int>>> m2;
+ test(m2);
+}
diff --git a/test/std/containers/unord/unord.map/unord.map.modifiers/insert_node_type_hint.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_node_type_hint.pass.cpp
new file mode 100644
index 000000000000..ef98453b6271
--- /dev/null
+++ b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_node_type_hint.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <unordered_map>
+
+// class unordered_map
+
+// iterator insert(const_iterator hint, node_type&&);
+
+#include <unordered_map>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key,
+ typename Container::mapped_type const& mapped)
+{
+ static Container c;
+ auto p = c.insert({key, mapped});
+ assert(p.second);
+ return c.extract(p.first);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i, i + 1);
+ assert(!node.empty());
+ size_t prev = c.size();
+ auto it = c.insert(c.end(), std::move(node));
+ assert(node.empty());
+ assert(prev + 1 == c.size());
+ assert(it->first == i);
+ assert(it->second == i + 1);
+ }
+
+ assert(c.size() == 10);
+
+ for (int i = 0; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ assert(c[i] == i + 1);
+ }
+}
+
+int main()
+{
+ std::unordered_map<int, int> m;
+ test(m);
+ std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, int>>> m2;
+ test(m2);
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/extract_iterator.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/extract_iterator.pass.cpp
new file mode 100644
index 000000000000..adb2ddb2ba80
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/extract_iterator.pass.cpp
@@ -0,0 +1,67 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <unordered_map>
+
+// class unordered_multimap
+
+// node_type extract(const_iterator);
+
+#include <unordered_map>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container>
+void test(Container& c)
+{
+ size_t sz = c.size();
+
+ auto some_key = c.cbegin()->first;
+
+ for (auto first = c.cbegin(); first != c.cend();)
+ {
+ auto key_value = first->first;
+ typename Container::node_type t = c.extract(first++);
+ --sz;
+ assert(t.key() == key_value);
+ t.key() = some_key;
+ assert(t.key() == some_key);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+}
+
+int main()
+{
+ {
+ using map_type = std::unordered_multimap<int, int>;
+ map_type m = {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ test(m);
+ }
+
+ {
+ std::unordered_multimap<Counter<int>, Counter<int>> m =
+ {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ assert(Counter_base::gConstructed == 12);
+ test(m);
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_map =
+ std::unordered_multimap<int, int, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, int>>>;
+ min_alloc_map m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}};
+ test(m);
+ }
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/extract_key.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/extract_key.pass.cpp
new file mode 100644
index 000000000000..8cf26fc77507
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/extract_key.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <unordered_map>
+
+// class unordered_multimap
+
+// node_type extract(key_type const&);
+
+#include <unordered_map>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container, class KeyTypeIter>
+void test(Container& c, KeyTypeIter first, KeyTypeIter last)
+{
+ size_t sz = c.size();
+ assert((size_t)std::distance(first, last) == sz);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(!t.empty());
+ --sz;
+ assert(t.key() == *copy);
+ t.key() = *first; // We should be able to mutate key.
+ assert(t.key() == *first);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(t.empty());
+ }
+}
+
+int main()
+{
+ {
+ std::unordered_multimap<int, int> m =
+ {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+
+ {
+ std::unordered_multimap<Counter<int>, Counter<int>> m =
+ {{1,1}, {2,2}, {3,3}, {4,4}, {5,5}, {6,6}};
+ {
+ Counter<int> keys[] = {1, 2, 3, 4, 5, 6};
+ assert(Counter_base::gConstructed == 12+6);
+ test(m, std::begin(keys), std::end(keys));
+ }
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_map =
+ std::unordered_multimap<int, int, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, int>>>;
+ min_alloc_map m = {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {5, 5}, {6, 6}};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_node_type.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_node_type.pass.cpp
new file mode 100644
index 000000000000..93c0462b3244
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_node_type.pass.cpp
@@ -0,0 +1,77 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <unordered_map>
+
+// class unordered_multimap
+
+// iterator insert(node_type&&);
+
+#include <unordered_map>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key,
+ typename Container::mapped_type const& mapped)
+{
+ static Container c;
+ auto it = c.insert({key, mapped});
+ return c.extract(it);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i, i + 1);
+ assert(!node.empty());
+ typename Container::iterator it = c.insert(std::move(node));
+ assert(node.empty());
+ assert(it == c.find(i) && it != c.end());
+ assert(it->first == i && it->second == i + 1);
+ }
+
+ assert(c.size() == 10);
+
+ { // Insert empty node.
+ typename Container::node_type def;
+ auto it = c.insert(std::move(def));
+ assert(def.empty());
+ assert(it == c.end());
+ }
+
+ { // Insert duplicate node.
+ typename Container::node_type dupl = nf(0, 42);
+ auto it = c.insert(std::move(dupl));
+ assert(dupl.empty());
+ assert(it != c.end() && it->second == 42);
+ }
+
+ assert(c.size() == 11);
+ assert(c.count(0) == 2);
+ for (int i = 1; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ assert(c.find(i)->second == i + 1);
+ }
+}
+
+int main()
+{
+ std::unordered_multimap<int, int> m;
+ test(m);
+ std::unordered_multimap<int, int, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, int>>> m2;
+ test(m2);
+}
diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_node_type_hint.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_node_type_hint.pass.cpp
new file mode 100644
index 000000000000..99a47cabb517
--- /dev/null
+++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_node_type_hint.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <unordered_map>
+
+// class unordered_multimap
+
+// iterator insert(const_iterator hint, node_type&&);
+
+#include <unordered_map>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key,
+ typename Container::mapped_type const& mapped)
+{
+ static Container c;
+ auto it = c.insert({key, mapped});
+ return c.extract(it);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i, i + 1);
+ assert(!node.empty());
+ size_t prev = c.size();
+ auto it = c.insert(c.end(), std::move(node));
+ assert(node.empty());
+ assert(prev + 1 == c.size());
+ assert(it->first == i);
+ assert(it->second == i + 1);
+ }
+
+ assert(c.size() == 10);
+
+ for (int i = 0; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ assert(c.find(i)->second == i + 1);
+ }
+}
+
+int main()
+{
+ std::unordered_multimap<int, int> m;
+ test(m);
+ std::unordered_multimap<int, int, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, int>>> m2;
+ test(m2);
+}
diff --git a/test/std/containers/unord/unord.multiset/extract_iterator.pass.cpp b/test/std/containers/unord/unord.multiset/extract_iterator.pass.cpp
new file mode 100644
index 000000000000..1595c55a4236
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/extract_iterator.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <unordered_set>
+
+// class unordered_multiset
+
+// node_type extract(const_iterator);
+
+#include <unordered_set>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container>
+void test(Container& c)
+{
+ size_t sz = c.size();
+
+ for (auto first = c.cbegin(); first != c.cend();)
+ {
+ auto key_value = *first;
+ typename Container::node_type t = c.extract(first++);
+ --sz;
+ assert(t.value() == key_value);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+}
+
+int main()
+{
+ {
+ using set_type = std::unordered_multiset<int>;
+ set_type m = {1, 2, 3, 4, 5, 6};
+ test(m);
+ }
+
+ {
+ std::unordered_multiset<Counter<int>> m = {1, 2, 3, 4, 5, 6};
+ assert(Counter_base::gConstructed == 6);
+ test(m);
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_set = std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>>;
+ min_alloc_set m = {1, 2, 3, 4, 5, 6};
+ test(m);
+ }
+}
diff --git a/test/std/containers/unord/unord.multiset/extract_key.pass.cpp b/test/std/containers/unord/unord.multiset/extract_key.pass.cpp
new file mode 100644
index 000000000000..ffe46fb30f17
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/extract_key.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <unordered_multiset>
+
+// class unordered_multiset
+
+// node_type extract(key_type const&);
+
+#include <unordered_set>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container, class KeyTypeIter>
+void test(Container& c, KeyTypeIter first, KeyTypeIter last)
+{
+ size_t sz = c.size();
+ assert((size_t)std::distance(first, last) == sz);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(!t.empty());
+ --sz;
+ assert(t.value() == *copy);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(t.empty());
+ }
+}
+
+int main()
+{
+ {
+ std::unordered_multiset<int> m = {1, 2, 3, 4, 5, 6};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+
+ {
+ std::unordered_multiset<Counter<int>> m = {1, 2, 3, 4, 5, 6};
+ {
+ Counter<int> keys[] = {1, 2, 3, 4, 5, 6};
+ assert(Counter_base::gConstructed == 6+6);
+ test(m, std::begin(keys), std::end(keys));
+ }
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_set = std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>>;
+ min_alloc_set m = {1, 2, 3, 4, 5, 6};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+}
diff --git a/test/std/containers/unord/unord.multiset/insert_node_type.pass.cpp b/test/std/containers/unord/unord.multiset/insert_node_type.pass.cpp
new file mode 100644
index 000000000000..c3d4cd2a0e8c
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/insert_node_type.pass.cpp
@@ -0,0 +1,76 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <unordered_set>
+
+// class unordered_multiset
+
+// iterator insert(node_type&&);
+
+#include <unordered_set>
+#include <type_traits>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key)
+{
+ static Container c;
+ auto it = c.insert(key);
+ return c.extract(it);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i);
+ assert(!node.empty());
+ typename Container::iterator it = c.insert(std::move(node));
+ assert(node.empty());
+ assert(it == c.find(i) && it != c.end());
+ assert(*it == i);
+ assert(node.empty());
+ }
+
+ assert(c.size() == 10);
+
+ { // Insert empty node.
+ typename Container::node_type def;
+ auto it = c.insert(std::move(def));
+ assert(def.empty());
+ assert(it == c.end());
+ }
+
+ { // Insert duplicate node.
+ typename Container::node_type dupl = nf(0);
+ auto it = c.insert(std::move(dupl));
+ assert(*it == 0);
+ }
+
+ assert(c.size() == 11);
+ assert(c.count(0) == 2);
+ for (int i = 1; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ }
+}
+
+int main()
+{
+ std::unordered_multiset<int> m;
+ test(m);
+ std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> m2;
+ test(m2);
+}
diff --git a/test/std/containers/unord/unord.multiset/insert_node_type_hint.pass.cpp b/test/std/containers/unord/unord.multiset/insert_node_type_hint.pass.cpp
new file mode 100644
index 000000000000..79712d3ded79
--- /dev/null
+++ b/test/std/containers/unord/unord.multiset/insert_node_type_hint.pass.cpp
@@ -0,0 +1,59 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <unordered_set>
+
+// class unordered_multiset
+
+// iterator insert(const_iterator hint, node_type&&);
+
+#include <unordered_set>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key)
+{
+ static Container c;
+ auto it = c.insert(key);
+ return c.extract(it);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i);
+ assert(!node.empty());
+ size_t prev = c.size();
+ auto it = c.insert(c.end(), std::move(node));
+ assert(prev + 1 == c.size());
+ assert(*it == i);
+ }
+
+ assert(c.size() == 10);
+
+ for (int i = 0; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ }
+}
+
+int main()
+{
+ std::unordered_multiset<int> m;
+ test(m);
+ std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> m2;
+ test(m2);
+}
diff --git a/test/std/containers/unord/unord.set/extract_iterator.pass.cpp b/test/std/containers/unord/unord.set/extract_iterator.pass.cpp
new file mode 100644
index 000000000000..40feb0e2f85b
--- /dev/null
+++ b/test/std/containers/unord/unord.set/extract_iterator.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <unordered_set>
+
+// class unordered_set
+
+// node_type extract(const_iterator);
+
+#include <unordered_set>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container>
+void test(Container& c)
+{
+ size_t sz = c.size();
+
+ for (auto first = c.cbegin(); first != c.cend();)
+ {
+ auto key_value = *first;
+ typename Container::node_type t = c.extract(first++);
+ --sz;
+ assert(t.value() == key_value);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+}
+
+int main()
+{
+ {
+ using set_type = std::unordered_set<int>;
+ set_type m = {1, 2, 3, 4, 5, 6};
+ test(m);
+ }
+
+ {
+ std::unordered_set<Counter<int>> m = {1, 2, 3, 4, 5, 6};
+ assert(Counter_base::gConstructed == 6);
+ test(m);
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_set = std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>>;
+ min_alloc_set m = {1, 2, 3, 4, 5, 6};
+ test(m);
+ }
+}
diff --git a/test/std/containers/unord/unord.set/extract_key.pass.cpp b/test/std/containers/unord/unord.set/extract_key.pass.cpp
new file mode 100644
index 000000000000..f686342b298e
--- /dev/null
+++ b/test/std/containers/unord/unord.set/extract_key.pass.cpp
@@ -0,0 +1,71 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <unordered_set>
+
+// class unordered_set
+
+// node_type extract(key_type const&);
+
+#include <unordered_set>
+#include "min_allocator.h"
+#include "Counter.h"
+
+template <class Container, class KeyTypeIter>
+void test(Container& c, KeyTypeIter first, KeyTypeIter last)
+{
+ size_t sz = c.size();
+ assert((size_t)std::distance(first, last) == sz);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(!t.empty());
+ --sz;
+ assert(t.value() == *copy);
+ assert(t.get_allocator() == c.get_allocator());
+ assert(sz == c.size());
+ }
+
+ assert(c.size() == 0);
+
+ for (KeyTypeIter copy = first; copy != last; ++copy)
+ {
+ typename Container::node_type t = c.extract(*copy);
+ assert(t.empty());
+ }
+}
+
+int main()
+{
+ {
+ std::unordered_set<int> m = {1, 2, 3, 4, 5, 6};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+
+ {
+ std::unordered_set<Counter<int>> m = {1, 2, 3, 4, 5, 6};
+ {
+ Counter<int> keys[] = {1, 2, 3, 4, 5, 6};
+ assert(Counter_base::gConstructed == 6+6);
+ test(m, std::begin(keys), std::end(keys));
+ }
+ assert(Counter_base::gConstructed == 0);
+ }
+
+ {
+ using min_alloc_set = std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>>;
+ min_alloc_set m = {1, 2, 3, 4, 5, 6};
+ int keys[] = {1, 2, 3, 4, 5, 6};
+ test(m, std::begin(keys), std::end(keys));
+ }
+}
diff --git a/test/std/containers/unord/unord.set/insert_node_type.pass.cpp b/test/std/containers/unord/unord.set/insert_node_type.pass.cpp
new file mode 100644
index 000000000000..6c91b539356e
--- /dev/null
+++ b/test/std/containers/unord/unord.set/insert_node_type.pass.cpp
@@ -0,0 +1,83 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <unordered_set>
+
+// class unordered_set
+
+// insert_return_type insert(node_type&&);
+
+#include <unordered_set>
+#include <type_traits>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key)
+{
+ static Container c;
+ auto p = c.insert(key);
+ assert(p.second);
+ return c.extract(p.first);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i);
+ assert(!node.empty());
+ typename Container::insert_return_type irt = c.insert(std::move(node));
+ assert(node.empty());
+ assert(irt.inserted);
+ assert(irt.node.empty());
+ assert(*irt.position == i);
+ }
+
+ assert(c.size() == 10);
+
+ { // Insert empty node.
+ typename Container::node_type def;
+ auto irt = c.insert(std::move(def));
+ assert(def.empty());
+ assert(!irt.inserted);
+ assert(irt.node.empty());
+ assert(irt.position == c.end());
+ }
+
+ { // Insert duplicate node.
+ typename Container::node_type dupl = nf(0);
+ auto irt = c.insert(std::move(dupl));
+ assert(dupl.empty());
+ assert(!irt.inserted);
+ assert(!irt.node.empty());
+ assert(irt.position == c.find(0));
+ assert(irt.node.value() == 0);
+ }
+
+ assert(c.size() == 10);
+
+ for (int i = 0; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ }
+}
+
+int main()
+{
+ std::unordered_set<int> m;
+ test(m);
+ std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> m2;
+ test(m2);
+}
diff --git a/test/std/containers/unord/unord.set/insert_node_type_hint.pass.cpp b/test/std/containers/unord/unord.set/insert_node_type_hint.pass.cpp
new file mode 100644
index 000000000000..626f27271da4
--- /dev/null
+++ b/test/std/containers/unord/unord.set/insert_node_type_hint.pass.cpp
@@ -0,0 +1,61 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// <unordered_set>
+
+// class unordered_set
+
+// iterator insert(const_iterator hint, node_type&&);
+
+#include <unordered_set>
+#include "min_allocator.h"
+
+template <class Container>
+typename Container::node_type
+node_factory(typename Container::key_type const& key)
+{
+ static Container c;
+ auto p = c.insert(key);
+ assert(p.second);
+ return c.extract(p.first);
+}
+
+template <class Container>
+void test(Container& c)
+{
+ auto* nf = &node_factory<Container>;
+
+ for (int i = 0; i != 10; ++i)
+ {
+ typename Container::node_type node = nf(i);
+ assert(!node.empty());
+ size_t prev = c.size();
+ auto it = c.insert(c.end(), std::move(node));
+ assert(node.empty());
+ assert(prev + 1 == c.size());
+ assert(*it == i);
+ }
+
+ assert(c.size() == 10);
+
+ for (int i = 0; i != 10; ++i)
+ {
+ assert(c.count(i) == 1);
+ }
+}
+
+int main()
+{
+ std::unordered_set<int> m;
+ test(m);
+ std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> m2;
+ test(m2);
+}