summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/containers/associative
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/containers/associative')
-rw-r--r--libcxx/test/std/containers/associative/map/compare.pass.cpp32
-rw-r--r--libcxx/test/std/containers/associative/map/map.access/at.pass.cpp154
-rw-r--r--libcxx/test/std/containers/associative/map/map.access/empty.pass.cpp43
-rw-r--r--libcxx/test/std/containers/associative/map/map.access/index_key.pass.cpp105
-rw-r--r--libcxx/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp58
-rw-r--r--libcxx/test/std/containers/associative/map/map.access/index_tuple.pass.cpp33
-rw-r--r--libcxx/test/std/containers/associative/map/map.access/iterator.pass.cpp227
-rw-r--r--libcxx/test/std/containers/associative/map/map.access/max_size.pass.cpp35
-rw-r--r--libcxx/test/std/containers/associative/map/map.access/size.pass.cpp59
-rw-r--r--libcxx/test/std/containers/associative/map/map.cons/alloc.pass.cpp42
-rw-r--r--libcxx/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp75
-rw-r--r--libcxx/test/std/containers/associative/map/map.cons/compare.pass.cpp40
-rw-r--r--libcxx/test/std/containers/associative/map/map.cons/compare_alloc.pass.cpp45
-rw-r--r--libcxx/test/std/containers/associative/map/map.cons/copy.pass.cpp131
-rw-r--r--libcxx/test/std/containers/associative/map/map.cons/copy_alloc.pass.cpp95
-rw-r--r--libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp182
-rw-r--r--libcxx/test/std/containers/associative/map/map.cons/default.pass.cpp40
-rw-r--r--libcxx/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp53
-rw-r--r--libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp29
-rw-r--r--libcxx/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp51
-rw-r--r--libcxx/test/std/containers/associative/map/map.cons/initializer_list.pass.cpp67
-rw-r--r--libcxx/test/std/containers/associative/map/map.cons/initializer_list_compare.pass.cpp69
-rw-r--r--libcxx/test/std/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp100
-rw-r--r--libcxx/test/std/containers/associative/map/map.cons/iter_iter.pass.cpp68
-rw-r--r--libcxx/test/std/containers/associative/map/map.cons/iter_iter_comp.pass.cpp73
-rw-r--r--libcxx/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp108
-rw-r--r--libcxx/test/std/containers/associative/map/map.cons/move.pass.cpp120
-rw-r--r--libcxx/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp186
-rw-r--r--libcxx/test/std/containers/associative/map/map.cons/move_assign.pass.cpp190
-rw-r--r--libcxx/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp53
-rw-r--r--libcxx/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp51
-rw-r--r--libcxx/test/std/containers/associative/map/map.modifiers/clear.pass.cpp63
-rw-r--r--libcxx/test/std/containers/associative/map/map.modifiers/emplace.pass.cpp165
-rw-r--r--libcxx/test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp160
-rw-r--r--libcxx/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp237
-rw-r--r--libcxx/test/std/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp157
-rw-r--r--libcxx/test/std/containers/associative/map/map.modifiers/erase_key.pass.cpp275
-rw-r--r--libcxx/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp89
-rw-r--r--libcxx/test/std/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp71
-rw-r--r--libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp81
-rw-r--r--libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp77
-rw-r--r--libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp87
-rw-r--r--libcxx/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp93
-rw-r--r--libcxx/test/std/containers/associative/map/map.ops/count.pass.cpp173
-rw-r--r--libcxx/test/std/containers/associative/map/map.ops/equal_range.pass.cpp437
-rw-r--r--libcxx/test/std/containers/associative/map/map.ops/find.pass.cpp240
-rw-r--r--libcxx/test/std/containers/associative/map/map.ops/lower_bound.pass.cpp336
-rw-r--r--libcxx/test/std/containers/associative/map/map.ops/upper_bound.pass.cpp335
-rw-r--r--libcxx/test/std/containers/associative/map/map.special/member_swap.pass.cpp201
-rw-r--r--libcxx/test/std/containers/associative/map/map.special/non_member_swap.pass.cpp306
-rw-r--r--libcxx/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp60
-rw-r--r--libcxx/test/std/containers/associative/map/types.pass.cpp70
-rw-r--r--libcxx/test/std/containers/associative/map/version.pass.cpp20
-rw-r--r--libcxx/test/std/containers/associative/multimap/empty.pass.cpp43
-rw-r--r--libcxx/test/std/containers/associative/multimap/iterator.pass.cpp231
-rw-r--r--libcxx/test/std/containers/associative/multimap/max_size.pass.cpp35
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.cons/alloc.pass.cpp42
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp85
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.cons/compare.pass.cpp40
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp45
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.cons/copy.pass.cpp104
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp77
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp125
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.cons/default.pass.cpp40
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp53
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp51
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp83
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp91
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp129
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp112
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp86
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp91
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.cons/move.pass.cpp132
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp186
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp190
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp53
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp51
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.modifiers/clear.pass.cpp63
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp150
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp160
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp279
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp157
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp153
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp81
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp91
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp81
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp101
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp87
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp85
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.ops/count.pass.cpp159
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp264
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.ops/find.pass.cpp209
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp221
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp221
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.special/member_swap.pass.cpp200
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp305
-rw-r--r--libcxx/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp60
-rw-r--r--libcxx/test/std/containers/associative/multimap/scary.pass.cpp24
-rw-r--r--libcxx/test/std/containers/associative/multimap/size.pass.cpp59
-rw-r--r--libcxx/test/std/containers/associative/multimap/types.pass.cpp70
-rw-r--r--libcxx/test/std/containers/associative/multiset/clear.pass.cpp63
-rw-r--r--libcxx/test/std/containers/associative/multiset/count.pass.cpp160
-rw-r--r--libcxx/test/std/containers/associative/multiset/emplace.pass.cpp83
-rw-r--r--libcxx/test/std/containers/associative/multiset/emplace_hint.pass.cpp83
-rw-r--r--libcxx/test/std/containers/associative/multiset/empty.pass.cpp43
-rw-r--r--libcxx/test/std/containers/associative/multiset/equal_range.pass.cpp263
-rw-r--r--libcxx/test/std/containers/associative/multiset/erase_iter.pass.cpp181
-rw-r--r--libcxx/test/std/containers/associative/multiset/erase_iter_iter.pass.cpp141
-rw-r--r--libcxx/test/std/containers/associative/multiset/erase_key.pass.cpp129
-rw-r--r--libcxx/test/std/containers/associative/multiset/find.pass.cpp240
-rw-r--r--libcxx/test/std/containers/associative/multiset/insert_cv.pass.cpp73
-rw-r--r--libcxx/test/std/containers/associative/multiset/insert_initializer_list.pass.cpp61
-rw-r--r--libcxx/test/std/containers/associative/multiset/insert_iter_cv.pass.cpp73
-rw-r--r--libcxx/test/std/containers/associative/multiset/insert_iter_iter.pass.cpp85
-rw-r--r--libcxx/test/std/containers/associative/multiset/insert_iter_rv.pass.cpp76
-rw-r--r--libcxx/test/std/containers/associative/multiset/insert_rv.pass.cpp76
-rw-r--r--libcxx/test/std/containers/associative/multiset/iterator.pass.cpp215
-rw-r--r--libcxx/test/std/containers/associative/multiset/lower_bound.pass.cpp223
-rw-r--r--libcxx/test/std/containers/associative/multiset/max_size.pass.cpp35
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.cons/alloc.pass.cpp29
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp57
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.cons/compare.pass.cpp28
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.cons/compare_alloc.pass.cpp31
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.cons/copy.pass.cpp118
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.cons/copy_alloc.pass.cpp68
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp138
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.cons/default.pass.cpp40
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp53
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp51
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp73
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.cons/initializer_list_compare.pass.cpp38
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.cons/initializer_list_compare_alloc.pass.cpp41
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp83
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp92
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.cons/iter_iter_comp.pass.cpp53
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.cons/move.pass.cpp119
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp141
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp186
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp53
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp51
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.special/member_swap.pass.cpp201
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.special/non_member_swap.pass.cpp177
-rw-r--r--libcxx/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp60
-rw-r--r--libcxx/test/std/containers/associative/multiset/scary.pass.cpp24
-rw-r--r--libcxx/test/std/containers/associative/multiset/size.pass.cpp59
-rw-r--r--libcxx/test/std/containers/associative/multiset/types.pass.cpp70
-rw-r--r--libcxx/test/std/containers/associative/multiset/upper_bound.pass.cpp222
-rw-r--r--libcxx/test/std/containers/associative/set/clear.pass.cpp63
-rw-r--r--libcxx/test/std/containers/associative/set/count.pass.cpp168
-rw-r--r--libcxx/test/std/containers/associative/set/emplace.pass.cpp90
-rw-r--r--libcxx/test/std/containers/associative/set/emplace_hint.pass.cpp83
-rw-r--r--libcxx/test/std/containers/associative/set/empty.pass.cpp43
-rw-r--r--libcxx/test/std/containers/associative/set/equal_range.pass.cpp370
-rw-r--r--libcxx/test/std/containers/associative/set/erase_iter.pass.cpp181
-rw-r--r--libcxx/test/std/containers/associative/set/erase_iter_iter.pass.cpp141
-rw-r--r--libcxx/test/std/containers/associative/set/erase_key.pass.cpp203
-rw-r--r--libcxx/test/std/containers/associative/set/find.pass.cpp240
-rw-r--r--libcxx/test/std/containers/associative/set/insert_cv.pass.cpp81
-rw-r--r--libcxx/test/std/containers/associative/set/insert_initializer_list.pass.cpp61
-rw-r--r--libcxx/test/std/containers/associative/set/insert_iter_cv.pass.cpp73
-rw-r--r--libcxx/test/std/containers/associative/set/insert_iter_iter.pass.cpp73
-rw-r--r--libcxx/test/std/containers/associative/set/insert_iter_rv.pass.cpp76
-rw-r--r--libcxx/test/std/containers/associative/set/insert_rv.pass.cpp84
-rw-r--r--libcxx/test/std/containers/associative/set/iterator.pass.cpp211
-rw-r--r--libcxx/test/std/containers/associative/set/lower_bound.pass.cpp337
-rw-r--r--libcxx/test/std/containers/associative/set/max_size.pass.cpp35
-rw-r--r--libcxx/test/std/containers/associative/set/set.cons/alloc.pass.cpp29
-rw-r--r--libcxx/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp57
-rw-r--r--libcxx/test/std/containers/associative/set/set.cons/compare.pass.cpp28
-rw-r--r--libcxx/test/std/containers/associative/set/set.cons/compare_alloc.pass.cpp31
-rw-r--r--libcxx/test/std/containers/associative/set/set.cons/copy.pass.cpp94
-rw-r--r--libcxx/test/std/containers/associative/set/set.cons/copy_alloc.pass.cpp56
-rw-r--r--libcxx/test/std/containers/associative/set/set.cons/copy_assign.pass.cpp109
-rw-r--r--libcxx/test/std/containers/associative/set/set.cons/default.pass.cpp40
-rw-r--r--libcxx/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp53
-rw-r--r--libcxx/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp51
-rw-r--r--libcxx/test/std/containers/associative/set/set.cons/initializer_list.pass.cpp55
-rw-r--r--libcxx/test/std/containers/associative/set/set.cons/initializer_list_compare.pass.cpp38
-rw-r--r--libcxx/test/std/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp63
-rw-r--r--libcxx/test/std/containers/associative/set/set.cons/iter_iter.pass.cpp71
-rw-r--r--libcxx/test/std/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp84
-rw-r--r--libcxx/test/std/containers/associative/set/set.cons/iter_iter_comp.pass.cpp47
-rw-r--r--libcxx/test/std/containers/associative/set/set.cons/move.pass.cpp107
-rw-r--r--libcxx/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp141
-rw-r--r--libcxx/test/std/containers/associative/set/set.cons/move_assign.pass.cpp186
-rw-r--r--libcxx/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp53
-rw-r--r--libcxx/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp51
-rw-r--r--libcxx/test/std/containers/associative/set/set.special/member_swap.pass.cpp201
-rw-r--r--libcxx/test/std/containers/associative/set/set.special/non_member_swap.pass.cpp177
-rw-r--r--libcxx/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp60
-rw-r--r--libcxx/test/std/containers/associative/set/size.pass.cpp59
-rw-r--r--libcxx/test/std/containers/associative/set/types.pass.cpp70
-rw-r--r--libcxx/test/std/containers/associative/set/upper_bound.pass.cpp336
-rw-r--r--libcxx/test/std/containers/associative/set/version.pass.cpp20
-rw-r--r--libcxx/test/std/containers/associative/tree_balance_after_insert.pass.cpp1616
-rw-r--r--libcxx/test/std/containers/associative/tree_left_rotate.pass.cpp98
-rw-r--r--libcxx/test/std/containers/associative/tree_remove.pass.cpp1648
-rw-r--r--libcxx/test/std/containers/associative/tree_right_rotate.pass.cpp98
198 files changed, 24901 insertions, 0 deletions
diff --git a/libcxx/test/std/containers/associative/map/compare.pass.cpp b/libcxx/test/std/containers/associative/map/compare.pass.cpp
new file mode 100644
index 00000000000..aa4d5999ff4
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/compare.pass.cpp
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// template <class Key, class T, class Compare = less<Key>,
+// class Allocator = allocator<pair<const Key, T>>>
+// class map
+
+// http://llvm.org/bugs/show_bug.cgi?id=16538
+// http://llvm.org/bugs/show_bug.cgi?id=16549
+
+#include <map>
+
+struct Key {
+ template <typename T> Key(const T&) {}
+ bool operator< (const Key&) const { return false; }
+};
+
+int
+main()
+{
+ std::map<Key, int>::iterator it = std::map<Key, int>().find(Key(0));
+ std::pair<std::map<Key, int>::iterator, bool> result =
+ std::map<Key, int>().insert(std::make_pair(Key(0), 0));
+}
diff --git a/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp
new file mode 100644
index 00000000000..86b1e3d2dfa
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.access/at.pass.cpp
@@ -0,0 +1,154 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// mapped_type& at(const key_type& k);
+// const mapped_type& at(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1.5),
+ V(2, 2.5),
+ V(3, 3.5),
+ V(4, 4.5),
+ V(5, 5.5),
+ V(7, 7.5),
+ V(8, 8.5),
+ };
+ std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 7);
+ assert(m.at(1) == 1.5);
+ m.at(1) = -1.5;
+ assert(m.at(1) == -1.5);
+ assert(m.at(2) == 2.5);
+ assert(m.at(3) == 3.5);
+ assert(m.at(4) == 4.5);
+ assert(m.at(5) == 5.5);
+ try
+ {
+ m.at(6);
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ assert(m.at(7) == 7.5);
+ assert(m.at(8) == 8.5);
+ assert(m.size() == 7);
+ }
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1.5),
+ V(2, 2.5),
+ V(3, 3.5),
+ V(4, 4.5),
+ V(5, 5.5),
+ V(7, 7.5),
+ V(8, 8.5),
+ };
+ const std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 7);
+ assert(m.at(1) == 1.5);
+ assert(m.at(2) == 2.5);
+ assert(m.at(3) == 3.5);
+ assert(m.at(4) == 4.5);
+ assert(m.at(5) == 5.5);
+ try
+ {
+ m.at(6);
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ assert(m.at(7) == 7.5);
+ assert(m.at(8) == 8.5);
+ assert(m.size() == 7);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1.5),
+ V(2, 2.5),
+ V(3, 3.5),
+ V(4, 4.5),
+ V(5, 5.5),
+ V(7, 7.5),
+ V(8, 8.5),
+ };
+ std::map<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 7);
+ assert(m.at(1) == 1.5);
+ m.at(1) = -1.5;
+ assert(m.at(1) == -1.5);
+ assert(m.at(2) == 2.5);
+ assert(m.at(3) == 3.5);
+ assert(m.at(4) == 4.5);
+ assert(m.at(5) == 5.5);
+ try
+ {
+ m.at(6);
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ assert(m.at(7) == 7.5);
+ assert(m.at(8) == 8.5);
+ assert(m.size() == 7);
+ }
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1.5),
+ V(2, 2.5),
+ V(3, 3.5),
+ V(4, 4.5),
+ V(5, 5.5),
+ V(7, 7.5),
+ V(8, 8.5),
+ };
+ const std::map<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 7);
+ assert(m.at(1) == 1.5);
+ assert(m.at(2) == 2.5);
+ assert(m.at(3) == 3.5);
+ assert(m.at(4) == 4.5);
+ assert(m.at(5) == 5.5);
+ try
+ {
+ m.at(6);
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ assert(m.at(7) == 7.5);
+ assert(m.at(8) == 8.5);
+ assert(m.size() == 7);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.access/empty.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/empty.pass.cpp
new file mode 100644
index 00000000000..b11e94c8042
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.access/empty.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// bool empty() const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::map<int, double> M;
+ M m;
+ assert(m.empty());
+ m.insert(M::value_type(1, 1.5));
+ assert(!m.empty());
+ m.clear();
+ assert(m.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ M m;
+ assert(m.empty());
+ m.insert(M::value_type(1, 1.5));
+ assert(!m.empty());
+ m.clear();
+ assert(m.empty());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.access/index_key.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/index_key.pass.cpp
new file mode 100644
index 00000000000..ab1144c60af
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.access/index_key.pass.cpp
@@ -0,0 +1,105 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// mapped_type& operator[](const key_type& k);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1.5),
+ V(2, 2.5),
+ V(3, 3.5),
+ V(4, 4.5),
+ V(5, 5.5),
+ V(7, 7.5),
+ V(8, 8.5),
+ };
+ std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 7);
+ assert(m[1] == 1.5);
+ assert(m.size() == 7);
+ m[1] = -1.5;
+ assert(m[1] == -1.5);
+ assert(m.size() == 7);
+ assert(m[6] == 0);
+ assert(m.size() == 8);
+ m[6] = 6.5;
+ assert(m[6] == 6.5);
+ assert(m.size() == 8);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1.5),
+ V(2, 2.5),
+ V(3, 3.5),
+ V(4, 4.5),
+ V(5, 5.5),
+ V(7, 7.5),
+ V(8, 8.5),
+ };
+ std::map<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 7);
+ assert(m[1] == 1.5);
+ assert(m.size() == 7);
+ const int i = 1;
+ m[i] = -1.5;
+ assert(m[1] == -1.5);
+ assert(m.size() == 7);
+ assert(m[6] == 0);
+ assert(m.size() == 8);
+ m[6] = 6.5;
+ assert(m[6] == 6.5);
+ assert(m.size() == 8);
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1.5),
+ V(2, 2.5),
+ V(3, 3.5),
+ V(4, 4.5),
+ V(5, 5.5),
+ V(7, 7.5),
+ V(8, 8.5),
+ };
+ std::map<int, double, std::less<>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+
+ assert(m.size() == 7);
+ assert(m[1] == 1.5);
+ assert(m.size() == 7);
+ m[1] = -1.5;
+ assert(m[1] == -1.5);
+ assert(m.size() == 7);
+ assert(m[6] == 0);
+ assert(m.size() == 8);
+ m[6] = 6.5;
+ assert(m[6] == 6.5);
+ assert(m.size() == 8);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp
new file mode 100644
index 00000000000..a58d50d8499
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp
@@ -0,0 +1,58 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// mapped_type& operator[](key_type&& k);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::pair<MoveOnly, double> V;
+ std::map<MoveOnly, double> m;
+ assert(m.size() == 0);
+ assert(m[1] == 0.0);
+ assert(m.size() == 1);
+ m[1] = -1.5;
+ assert(m[1] == -1.5);
+ assert(m.size() == 1);
+ assert(m[6] == 0);
+ assert(m.size() == 2);
+ m[6] = 6.5;
+ assert(m[6] == 6.5);
+ assert(m.size() == 2);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<MoveOnly, double> V;
+ std::map<MoveOnly, double, std::less<MoveOnly>, min_allocator<V>> m;
+ assert(m.size() == 0);
+ assert(m[1] == 0.0);
+ assert(m.size() == 1);
+ m[1] = -1.5;
+ assert(m[1] == -1.5);
+ assert(m.size() == 1);
+ assert(m[6] == 0);
+ assert(m.size() == 2);
+ m[6] = 6.5;
+ assert(m[6] == 6.5);
+ assert(m.size() == 2);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.access/index_tuple.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/index_tuple.pass.cpp
new file mode 100644
index 00000000000..9a00829eadd
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.access/index_tuple.pass.cpp
@@ -0,0 +1,33 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// mapped_type& operator[](const key_type& k);
+
+// http://llvm.org/bugs/show_bug.cgi?id=16542
+
+#include <map>
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+#include <tuple>
+
+#endif
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ using namespace std;
+ map<tuple<int,int>, size_t> m;
+ m[make_tuple(2,3)]=7;
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.access/iterator.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/iterator.pass.cpp
new file mode 100644
index 00000000000..552e87d8fc8
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.access/iterator.pass.cpp
@@ -0,0 +1,227 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator begin();
+// const_iterator begin() const;
+// iterator end();
+// const_iterator end() const;
+//
+// reverse_iterator rbegin();
+// const_reverse_iterator rbegin() const;
+// reverse_iterator rend();
+// const_reverse_iterator rend() const;
+//
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+// const_reverse_iterator crbegin() const;
+// const_reverse_iterator crend() const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ V(4, 1),
+ V(4, 1.5),
+ V(4, 2),
+ V(5, 1),
+ V(5, 1.5),
+ V(5, 2),
+ V(6, 1),
+ V(6, 1.5),
+ V(6, 2),
+ V(7, 1),
+ V(7, 1.5),
+ V(7, 2),
+ V(8, 1),
+ V(8, 1.5),
+ V(8, 2)
+ };
+ std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ std::map<int, double>::iterator i;
+ i = m.begin();
+ std::map<int, double>::const_iterator k = i;
+ assert(i == k);
+ for (int j = 1; j <= m.size(); ++j, ++i)
+ {
+ assert(i->first == j);
+ assert(i->second == 1);
+ i->second = 2.5;
+ assert(i->second == 2.5);
+ }
+ }
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ V(4, 1),
+ V(4, 1.5),
+ V(4, 2),
+ V(5, 1),
+ V(5, 1.5),
+ V(5, 2),
+ V(6, 1),
+ V(6, 1.5),
+ V(6, 2),
+ V(7, 1),
+ V(7, 1.5),
+ V(7, 2),
+ V(8, 1),
+ V(8, 1.5),
+ V(8, 2)
+ };
+ const std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.cbegin(), m.cend()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ assert(std::distance(m.crbegin(), m.crend()) == m.size());
+ std::map<int, double>::const_iterator i;
+ i = m.begin();
+ for (int j = 1; j <= m.size(); ++j, ++i)
+ {
+ assert(i->first == j);
+ assert(i->second == 1);
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ V(4, 1),
+ V(4, 1.5),
+ V(4, 2),
+ V(5, 1),
+ V(5, 1.5),
+ V(5, 2),
+ V(6, 1),
+ V(6, 1.5),
+ V(6, 2),
+ V(7, 1),
+ V(7, 1.5),
+ V(7, 2),
+ V(8, 1),
+ V(8, 1.5),
+ V(8, 2)
+ };
+ std::map<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ std::map<int, double, std::less<int>, min_allocator<V>>::iterator i;
+ i = m.begin();
+ std::map<int, double, std::less<int>, min_allocator<V>>::const_iterator k = i;
+ assert(i == k);
+ for (int j = 1; j <= m.size(); ++j, ++i)
+ {
+ assert(i->first == j);
+ assert(i->second == 1);
+ i->second = 2.5;
+ assert(i->second == 2.5);
+ }
+ }
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ V(4, 1),
+ V(4, 1.5),
+ V(4, 2),
+ V(5, 1),
+ V(5, 1.5),
+ V(5, 2),
+ V(6, 1),
+ V(6, 1.5),
+ V(6, 2),
+ V(7, 1),
+ V(7, 1.5),
+ V(7, 2),
+ V(8, 1),
+ V(8, 1.5),
+ V(8, 2)
+ };
+ const std::map<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.cbegin(), m.cend()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ assert(std::distance(m.crbegin(), m.crend()) == m.size());
+ std::map<int, double, std::less<int>, min_allocator<V>>::const_iterator i;
+ i = m.begin();
+ for (int j = 1; j <= m.size(); ++j, ++i)
+ {
+ assert(i->first == j);
+ assert(i->second == 1);
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::map<int, double> C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.access/max_size.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/max_size.pass.cpp
new file mode 100644
index 00000000000..551120d331e
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.access/max_size.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// size_type max_size() const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::map<int, double> M;
+ M m;
+ assert(m.max_size() != 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ M m;
+ assert(m.max_size() != 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.access/size.pass.cpp b/libcxx/test/std/containers/associative/map/map.access/size.pass.cpp
new file mode 100644
index 00000000000..07c12322a46
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.access/size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// size_type size() const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::map<int, double> M;
+ M m;
+ assert(m.size() == 0);
+ m.insert(M::value_type(2, 1.5));
+ assert(m.size() == 1);
+ m.insert(M::value_type(1, 1.5));
+ assert(m.size() == 2);
+ m.insert(M::value_type(3, 1.5));
+ assert(m.size() == 3);
+ m.erase(m.begin());
+ assert(m.size() == 2);
+ m.erase(m.begin());
+ assert(m.size() == 1);
+ m.erase(m.begin());
+ assert(m.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ M m;
+ assert(m.size() == 0);
+ m.insert(M::value_type(2, 1.5));
+ assert(m.size() == 1);
+ m.insert(M::value_type(1, 1.5));
+ assert(m.size() == 2);
+ m.insert(M::value_type(3, 1.5));
+ assert(m.size() == 3);
+ m.erase(m.begin());
+ assert(m.size() == 2);
+ m.erase(m.begin());
+ assert(m.size() == 1);
+ m.erase(m.begin());
+ assert(m.size() == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.cons/alloc.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/alloc.pass.cpp
new file mode 100644
index 00000000000..2292c47ef74
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.cons/alloc.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// explicit map(const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::less<int> C;
+ typedef test_allocator<std::pair<const int, double> > A;
+ std::map<int, double, C, A> m(A(5));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.get_allocator() == A(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::less<int> C;
+ typedef min_allocator<std::pair<const int, double> > A;
+ std::map<int, double, C, A> m(A{});
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.get_allocator() == A());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 00000000000..482d1acff84
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,75 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map& operator=(initializer_list<value_type> il);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::pair<const int, double> V;
+ std::map<int, double> m =
+ {
+ {20, 1},
+ };
+ m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ std::map<int, double, std::less<int>, min_allocator<V>> m =
+ {
+ {20, 1},
+ };
+ m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/associative/map/map.cons/compare.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/compare.pass.cpp
new file mode 100644
index 00000000000..5a213c8e8b8
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.cons/compare.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// explicit map(const key_compare& comp);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_compare<std::less<int> > C;
+ std::map<int, double, C> m(C(3));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(3));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_compare<std::less<int> > C;
+ std::map<int, double, C, min_allocator<std::pair<const int, double>>> m(C(3));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(3));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.cons/compare_alloc.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/compare_alloc.pass.cpp
new file mode 100644
index 00000000000..56b3c3315e0
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.cons/compare_alloc.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<std::pair<const int, double> > A;
+ std::map<int, double, C, A> m(C(4), A(5));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(4));
+ assert(m.get_allocator() == A(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<std::pair<const int, double> > A;
+ std::map<int, double, C, A> m(C(4), A());
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(4));
+ assert(m.get_allocator() == A());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.cons/copy.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/copy.pass.cpp
new file mode 100644
index 00000000000..be527413308
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.cons/copy.pass.cpp
@@ -0,0 +1,131 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(const map& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::map<int, double, C, A> m = mo;
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == V(1, 1));
+ assert(*next(mo.begin()) == V(2, 1));
+ assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef other_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::map<int, double, C, A> m = mo;
+ assert(m.get_allocator() == A(-2));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == V(1, 1));
+ assert(*next(mo.begin()) == V(2, 1));
+ assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::map<int, double, C, A> m = mo;
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == V(1, 1));
+ assert(*next(mo.begin()) == V(2, 1));
+ assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.cons/copy_alloc.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/copy_alloc.pass.cpp
new file mode 100644
index 00000000000..fcbe5976d6d
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.cons/copy_alloc.pass.cpp
@@ -0,0 +1,95 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(const map& m, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::map<int, double, C, A> m(mo, A(3));
+ assert(m.get_allocator() == A(3));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == V(1, 1));
+ assert(*next(mo.begin()) == V(2, 1));
+ assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::map<int, double, C, A> m(mo, A());
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == V(1, 1));
+ assert(*next(mo.begin()) == V(2, 1));
+ assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp
new file mode 100644
index 00000000000..a1bcb30f429
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp
@@ -0,0 +1,182 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map& operator=(const map& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2)
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+ std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+ m = mo;
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A(2));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == V(1, 1));
+ assert(*next(mo.begin()) == V(2, 1));
+ assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+ {
+ typedef std::pair<const int, double> V;
+ const V ar[] =
+ {
+ V(1, 1),
+ V(2, 1),
+ V(3, 1),
+ };
+ std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ std::map<int, double> *p = &m;
+ m = *p;
+
+ assert(m.size() == 3);
+ assert(std::equal(m.begin(), m.end(), ar));
+ }
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2)
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef other_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+ std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+ m = mo;
+ assert(m.get_allocator() == A(2));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A(2));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == V(1, 1));
+ assert(*next(mo.begin()) == V(2, 1));
+ assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2)
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A());
+ m = mo;
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == V(1, 1));
+ assert(*next(mo.begin()) == V(2, 1));
+ assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2)
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A());
+ m = mo;
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == V(1, 1));
+ assert(*next(mo.begin()) == V(2, 1));
+ assert(*next(mo.begin(), 2) == V(3, 1));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.cons/default.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/default.pass.cpp
new file mode 100644
index 00000000000..1832a32fffb
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.cons/default.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map();
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::map<int, double> m;
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> m;
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+ {
+ std::map<int, double> m = {};
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp
new file mode 100644
index 00000000000..6c6b6140f0f
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// map()
+// noexcept(
+// is_nothrow_default_constructible<allocator_type>::value &&
+// is_nothrow_default_constructible<key_compare>::value &&
+// is_nothrow_copy_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp();
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::map<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
new file mode 100644
index 00000000000..8b393d3c91c
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.cons/default_recursive.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map();
+
+#include <map>
+
+#if !__has_feature(cxx_noexcept)
+
+struct X
+{
+ std::map<int, X> m;
+};
+
+#endif
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 00000000000..c60f2e7e8ba
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// ~map() // implied noexcept;
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ ~some_comp() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::map<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/initializer_list.pass.cpp
new file mode 100644
index 00000000000..196943653a1
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.cons/initializer_list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(initializer_list<value_type> il);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::pair<const int, double> V;
+ std::map<int, double> m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ std::map<int, double, std::less<int>, min_allocator<V>> m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/associative/map/map.cons/initializer_list_compare.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/initializer_list_compare.pass.cpp
new file mode 100644
index 00000000000..08f8a529f03
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.cons/initializer_list_compare.pass.cpp
@@ -0,0 +1,69 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(initializer_list<value_type> il, const key_compare& comp);
+
+#include <map>
+#include <cassert>
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::pair<const int, double> V;
+ typedef test_compare<std::less<int> > C;
+ std::map<int, double, C> m({
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ }, C(3));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ assert(m.key_comp() == C(3));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef test_compare<std::less<int> > C;
+ std::map<int, double, C, min_allocator<std::pair<const int, double>>> m({
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ }, C(3));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ assert(m.key_comp() == C(3));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp
new file mode 100644
index 00000000000..765428a631e
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp
@@ -0,0 +1,100 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::pair<const int, double> V;
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<std::pair<const int, double> > A;
+ std::map<int, double, C, A> m({
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ }, C(3), A(6));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ assert(m.key_comp() == C(3));
+ assert(m.get_allocator() == A(6));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<std::pair<const int, double> > A;
+ std::map<int, double, C, A> m({
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ }, C(3), A());
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ assert(m.key_comp() == C(3));
+ assert(m.get_allocator() == A());
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ typedef min_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::map<int, double, C, A> M;
+ A a;
+ M m ({ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ }, a);
+
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ assert(m.get_allocator() == a);
+ }
+#endif
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/associative/map/map.cons/iter_iter.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/iter_iter.pass.cpp
new file mode 100644
index 00000000000..c1029af6889
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.cons/iter_iter.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class InputIterator>
+// map(InputIterator first, InputIterator last);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.cons/iter_iter_comp.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/iter_iter_comp.pass.cpp
new file mode 100644
index 00000000000..837fa8c6cde
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.cons/iter_iter_comp.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class InputIterator>
+// map(InputIterator first, InputIterator last, const key_compare& comp);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ std::map<int, double, C> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ std::map<int, double, C, min_allocator<std::pair<const int, double>>> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp
new file mode 100644
index 00000000000..67fb5d64476
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp
@@ -0,0 +1,108 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class InputIterator>
+// map(InputIterator first, InputIterator last,
+// const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef std::pair<const int, double> V;
+ typedef min_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ A a;
+ std::map<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a );
+
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ assert(m.get_allocator() == a);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.cons/move.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/move.pass.cpp
new file mode 100644
index 00000000000..c06f2ee5021
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.cons/move.pass.cpp
@@ -0,0 +1,120 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(map&& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ typedef std::pair<const int, double> V;
+ {
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::map<int, double, C, A> mo(C(5), A(7));
+ std::map<int, double, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 0);
+ assert(distance(m.begin(), m.end()) == 0);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+ {
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::map<int, double, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::map<int, double, C, A> mo(C(5), A());
+ std::map<int, double, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 0);
+ assert(distance(m.begin(), m.end()) == 0);
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+ {
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::map<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::map<int, double, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp
new file mode 100644
index 00000000000..1845e88b7a5
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp
@@ -0,0 +1,186 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map(map&& m, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<VC> A;
+ typedef std::map<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(7));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<VC> A;
+ typedef std::map<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(5));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef other_allocator<VC> A;
+ typedef std::map<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(5));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef min_allocator<VC> A;
+ typedef std::map<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A());
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A());
+ M m3(std::move(m1), A());
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A());
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/map/map.cons/move_assign.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/move_assign.pass.cpp
new file mode 100644
index 00000000000..6d285fce000
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.cons/move_assign.pass.cpp
@@ -0,0 +1,190 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// map& operator=(map&& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<VC> A;
+ typedef std::map<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(7));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<VC> A;
+ typedef std::map<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(5));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef other_allocator<VC> A;
+ typedef std::map<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(5));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef min_allocator<VC> A;
+ typedef std::map<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A());
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A());
+ M m3(C(3), A());
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A());
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 00000000000..d12f9a9784f
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// map& operator=(map&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value &&
+// is_nothrow_move_assignable<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp& operator=(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::map<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp b/libcxx/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp
new file mode 100644
index 00000000000..6de4b67b326
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// map(map&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+// is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::map<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/clear.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/clear.pass.cpp
new file mode 100644
index 00000000000..c37499df307
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.modifiers/clear.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// void clear();
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::map<int, double> M;
+ typedef std::pair<int, double> P;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ m.clear();
+ assert(m.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ m.clear();
+ assert(m.size() == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/emplace.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/emplace.pass.cpp
new file mode 100644
index 00000000000..81846c6647c
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.modifiers/emplace.pass.cpp
@@ -0,0 +1,165 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class... Args>
+// pair<iterator, bool> emplace(Args&&... args);
+
+#include <map>
+#include <cassert>
+#include <tuple>
+
+#include "../../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::map<int, DefaultOnly> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace();
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 0);
+ assert(m.begin()->second == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r.second);
+ assert(r.first == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(!r.second);
+ assert(r.first == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::map<int, Emplaceable> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.emplace(std::piecewise_construct, std::forward_as_tuple(2),
+ std::forward_as_tuple());
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == Emplaceable());
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(!r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ }
+ {
+ typedef std::map<int, double> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.emplace(M::value_type(2, 3.5));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 3.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace();
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 0);
+ assert(m.begin()->second == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r.second);
+ assert(r.first == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(!r.second);
+ assert(r.first == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::map<int, Emplaceable, std::less<int>, min_allocator<std::pair<const int, Emplaceable>>> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.emplace(std::piecewise_construct, std::forward_as_tuple(2),
+ std::forward_as_tuple());
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == Emplaceable());
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(!r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ }
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.emplace(M::value_type(2, 3.5));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 3.5);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp
new file mode 100644
index 00000000000..15f74b17e78
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class... Args>
+// iterator emplace_hint(const_iterator position, Args&&... args);
+
+#include <map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::map<int, DefaultOnly> M;
+ typedef M::iterator R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace_hint(m.end());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 0);
+ assert(m.begin()->second == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+ r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::map<int, Emplaceable> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(2),
+ std::forward_as_tuple());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == Emplaceable());
+ r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ }
+ {
+ typedef std::map<int, double> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.end(), M::value_type(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 3.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
+ typedef M::iterator R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace_hint(m.end());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 0);
+ assert(m.begin()->second == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+ r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::map<int, Emplaceable, std::less<int>, min_allocator<std::pair<const int, Emplaceable>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(2),
+ std::forward_as_tuple());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == Emplaceable());
+ r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ r = m.emplace_hint(m.end(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ }
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.end(), M::value_type(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 3.5);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp
new file mode 100644
index 00000000000..05fb988e991
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp
@@ -0,0 +1,237 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator erase(const_iterator position);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::map<int, double> M;
+ typedef std::pair<int, double> P;
+ typedef M::iterator I;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(next(m.cbegin(), 3));
+ assert(m.size() == 7);
+ assert(i == next(m.begin(), 3));
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 5);
+ assert(next(m.begin(), 3)->second == 5.5);
+ assert(next(m.begin(), 4)->first == 6);
+ assert(next(m.begin(), 4)->second == 6.5);
+ assert(next(m.begin(), 5)->first == 7);
+ assert(next(m.begin(), 5)->second == 7.5);
+ assert(next(m.begin(), 6)->first == 8);
+ assert(next(m.begin(), 6)->second == 8.5);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 6);
+ assert(i == m.begin());
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 3);
+ assert(next(m.begin())->second == 3.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+ assert(next(m.begin(), 5)->first == 8);
+ assert(next(m.begin(), 5)->second == 8.5);
+
+ i = m.erase(next(m.cbegin(), 5));
+ assert(m.size() == 5);
+ assert(i == m.end());
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 3);
+ assert(next(m.begin())->second == 3.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+
+ i = m.erase(next(m.cbegin(), 1));
+ assert(m.size() == 4);
+ assert(i == next(m.begin()));
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+ assert(next(m.begin(), 2)->first == 6);
+ assert(next(m.begin(), 2)->second == 6.5);
+ assert(next(m.begin(), 3)->first == 7);
+ assert(next(m.begin(), 3)->second == 7.5);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 3);
+ assert(i == next(m.begin(), 2));
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+ assert(next(m.begin(), 2)->first == 7);
+ assert(next(m.begin(), 2)->second == 7.5);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 2));
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 1);
+ assert(i == next(m.begin(), 0));
+ assert(m.begin()->first == 5);
+ assert(m.begin()->second == 5.5);
+
+ i = m.erase(m.cbegin());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ typedef M::iterator I;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(next(m.cbegin(), 3));
+ assert(m.size() == 7);
+ assert(i == next(m.begin(), 3));
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 5);
+ assert(next(m.begin(), 3)->second == 5.5);
+ assert(next(m.begin(), 4)->first == 6);
+ assert(next(m.begin(), 4)->second == 6.5);
+ assert(next(m.begin(), 5)->first == 7);
+ assert(next(m.begin(), 5)->second == 7.5);
+ assert(next(m.begin(), 6)->first == 8);
+ assert(next(m.begin(), 6)->second == 8.5);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 6);
+ assert(i == m.begin());
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 3);
+ assert(next(m.begin())->second == 3.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+ assert(next(m.begin(), 5)->first == 8);
+ assert(next(m.begin(), 5)->second == 8.5);
+
+ i = m.erase(next(m.cbegin(), 5));
+ assert(m.size() == 5);
+ assert(i == m.end());
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 3);
+ assert(next(m.begin())->second == 3.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+
+ i = m.erase(next(m.cbegin(), 1));
+ assert(m.size() == 4);
+ assert(i == next(m.begin()));
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+ assert(next(m.begin(), 2)->first == 6);
+ assert(next(m.begin(), 2)->second == 6.5);
+ assert(next(m.begin(), 3)->first == 7);
+ assert(next(m.begin(), 3)->second == 7.5);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 3);
+ assert(i == next(m.begin(), 2));
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+ assert(next(m.begin(), 2)->first == 7);
+ assert(next(m.begin(), 2)->second == 7.5);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 2));
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 1);
+ assert(i == next(m.begin(), 0));
+ assert(m.begin()->first == 5);
+ assert(m.begin()->second == 5.5);
+
+ i = m.erase(m.cbegin());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp
new file mode 100644
index 00000000000..1b49956d8a5
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::map<int, double> M;
+ typedef std::pair<int, double> P;
+ typedef M::iterator I;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(m.cbegin(), m.cbegin());
+ assert(m.size() == 8);
+ assert(i == m.begin());
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 4);
+ assert(next(m.begin(), 3)->second == 4.5);
+ assert(next(m.begin(), 4)->first == 5);
+ assert(next(m.begin(), 4)->second == 5.5);
+ assert(next(m.begin(), 5)->first == 6);
+ assert(next(m.begin(), 5)->second == 6.5);
+ assert(next(m.begin(), 6)->first == 7);
+ assert(next(m.begin(), 6)->second == 7.5);
+ assert(next(m.begin(), 7)->first == 8);
+ assert(next(m.begin(), 7)->second == 8.5);
+
+ i = m.erase(m.cbegin(), next(m.cbegin(), 2));
+ assert(m.size() == 6);
+ assert(i == m.begin());
+ assert(next(m.begin(), 0)->first == 3);
+ assert(next(m.begin(), 0)->second == 3.5);
+ assert(next(m.begin(), 1)->first == 4);
+ assert(next(m.begin(), 1)->second == 4.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+ assert(next(m.begin(), 5)->first == 8);
+ assert(next(m.begin(), 5)->second == 8.5);
+
+ i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 6));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 2));
+ assert(next(m.begin(), 0)->first == 3);
+ assert(next(m.begin(), 0)->second == 3.5);
+ assert(next(m.begin(), 1)->first == 4);
+ assert(next(m.begin(), 1)->second == 4.5);
+
+ i = m.erase(m.cbegin(), m.cend());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ typedef M::iterator I;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(m.cbegin(), m.cbegin());
+ assert(m.size() == 8);
+ assert(i == m.begin());
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 4);
+ assert(next(m.begin(), 3)->second == 4.5);
+ assert(next(m.begin(), 4)->first == 5);
+ assert(next(m.begin(), 4)->second == 5.5);
+ assert(next(m.begin(), 5)->first == 6);
+ assert(next(m.begin(), 5)->second == 6.5);
+ assert(next(m.begin(), 6)->first == 7);
+ assert(next(m.begin(), 6)->second == 7.5);
+ assert(next(m.begin(), 7)->first == 8);
+ assert(next(m.begin(), 7)->second == 8.5);
+
+ i = m.erase(m.cbegin(), next(m.cbegin(), 2));
+ assert(m.size() == 6);
+ assert(i == m.begin());
+ assert(next(m.begin(), 0)->first == 3);
+ assert(next(m.begin(), 0)->second == 3.5);
+ assert(next(m.begin(), 1)->first == 4);
+ assert(next(m.begin(), 1)->second == 4.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+ assert(next(m.begin(), 5)->first == 8);
+ assert(next(m.begin(), 5)->second == 8.5);
+
+ i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 6));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 2));
+ assert(next(m.begin(), 0)->first == 3);
+ assert(next(m.begin(), 0)->second == 3.5);
+ assert(next(m.begin(), 1)->first == 4);
+ assert(next(m.begin(), 1)->second == 4.5);
+
+ i = m.erase(m.cbegin(), m.cend());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/erase_key.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/erase_key.pass.cpp
new file mode 100644
index 00000000000..e41f5129140
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.modifiers/erase_key.pass.cpp
@@ -0,0 +1,275 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// size_type erase(const key_type& k);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::map<int, double> M;
+ typedef std::pair<int, double> P;
+ typedef M::size_type R;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ R s = m.erase(9);
+ assert(s == 0);
+ assert(m.size() == 8);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 4);
+ assert(next(m.begin(), 3)->second == 4.5);
+ assert(next(m.begin(), 4)->first == 5);
+ assert(next(m.begin(), 4)->second == 5.5);
+ assert(next(m.begin(), 5)->first == 6);
+ assert(next(m.begin(), 5)->second == 6.5);
+ assert(next(m.begin(), 6)->first == 7);
+ assert(next(m.begin(), 6)->second == 7.5);
+ assert(next(m.begin(), 7)->first == 8);
+ assert(next(m.begin(), 7)->second == 8.5);
+
+ s = m.erase(4);
+ assert(m.size() == 7);
+ assert(s == 1);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 5);
+ assert(next(m.begin(), 3)->second == 5.5);
+ assert(next(m.begin(), 4)->first == 6);
+ assert(next(m.begin(), 4)->second == 6.5);
+ assert(next(m.begin(), 5)->first == 7);
+ assert(next(m.begin(), 5)->second == 7.5);
+ assert(next(m.begin(), 6)->first == 8);
+ assert(next(m.begin(), 6)->second == 8.5);
+
+ s = m.erase(1);
+ assert(m.size() == 6);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 3);
+ assert(next(m.begin())->second == 3.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+ assert(next(m.begin(), 5)->first == 8);
+ assert(next(m.begin(), 5)->second == 8.5);
+
+ s = m.erase(8);
+ assert(m.size() == 5);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 3);
+ assert(next(m.begin())->second == 3.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+
+ s = m.erase(3);
+ assert(m.size() == 4);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+ assert(next(m.begin(), 2)->first == 6);
+ assert(next(m.begin(), 2)->second == 6.5);
+ assert(next(m.begin(), 3)->first == 7);
+ assert(next(m.begin(), 3)->second == 7.5);
+
+ s = m.erase(6);
+ assert(m.size() == 3);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+ assert(next(m.begin(), 2)->first == 7);
+ assert(next(m.begin(), 2)->second == 7.5);
+
+ s = m.erase(7);
+ assert(m.size() == 2);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+
+ s = m.erase(2);
+ assert(m.size() == 1);
+ assert(s == 1);
+ assert(m.begin()->first == 5);
+ assert(m.begin()->second == 5.5);
+
+ s = m.erase(5);
+ assert(m.size() == 0);
+ assert(s == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ typedef M::size_type R;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ R s = m.erase(9);
+ assert(s == 0);
+ assert(m.size() == 8);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 4);
+ assert(next(m.begin(), 3)->second == 4.5);
+ assert(next(m.begin(), 4)->first == 5);
+ assert(next(m.begin(), 4)->second == 5.5);
+ assert(next(m.begin(), 5)->first == 6);
+ assert(next(m.begin(), 5)->second == 6.5);
+ assert(next(m.begin(), 6)->first == 7);
+ assert(next(m.begin(), 6)->second == 7.5);
+ assert(next(m.begin(), 7)->first == 8);
+ assert(next(m.begin(), 7)->second == 8.5);
+
+ s = m.erase(4);
+ assert(m.size() == 7);
+ assert(s == 1);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 5);
+ assert(next(m.begin(), 3)->second == 5.5);
+ assert(next(m.begin(), 4)->first == 6);
+ assert(next(m.begin(), 4)->second == 6.5);
+ assert(next(m.begin(), 5)->first == 7);
+ assert(next(m.begin(), 5)->second == 7.5);
+ assert(next(m.begin(), 6)->first == 8);
+ assert(next(m.begin(), 6)->second == 8.5);
+
+ s = m.erase(1);
+ assert(m.size() == 6);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 3);
+ assert(next(m.begin())->second == 3.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+ assert(next(m.begin(), 5)->first == 8);
+ assert(next(m.begin(), 5)->second == 8.5);
+
+ s = m.erase(8);
+ assert(m.size() == 5);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 3);
+ assert(next(m.begin())->second == 3.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+
+ s = m.erase(3);
+ assert(m.size() == 4);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+ assert(next(m.begin(), 2)->first == 6);
+ assert(next(m.begin(), 2)->second == 6.5);
+ assert(next(m.begin(), 3)->first == 7);
+ assert(next(m.begin(), 3)->second == 7.5);
+
+ s = m.erase(6);
+ assert(m.size() == 3);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+ assert(next(m.begin(), 2)->first == 7);
+ assert(next(m.begin(), 2)->second == 7.5);
+
+ s = m.erase(7);
+ assert(m.size() == 2);
+ assert(s == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 2.5);
+ assert(next(m.begin())->first == 5);
+ assert(next(m.begin())->second == 5.5);
+
+ s = m.erase(2);
+ assert(m.size() == 1);
+ assert(s == 1);
+ assert(m.begin()->first == 5);
+ assert(m.begin()->second == 5.5);
+
+ s = m.erase(5);
+ assert(m.size() == 0);
+ assert(s == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp
new file mode 100644
index 00000000000..3d28242fd32
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp
@@ -0,0 +1,89 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// pair<iterator, bool> insert(const value_type& v);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::map<int, double> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.insert(M::value_type(2, 2.5));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(r.first->first == 2);
+ assert(r.first->second == 2.5);
+
+ r = m.insert(M::value_type(1, 1.5));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(r.first->first == 1);
+ assert(r.first->second == 1.5);
+
+ r = m.insert(M::value_type(3, 3.5));
+ assert(r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3.5);
+
+ r = m.insert(M::value_type(3, 3.5));
+ assert(!r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.insert(M::value_type(2, 2.5));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(r.first->first == 2);
+ assert(r.first->second == 2.5);
+
+ r = m.insert(M::value_type(1, 1.5));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(r.first->first == 1);
+ assert(r.first->second == 1.5);
+
+ r = m.insert(M::value_type(3, 3.5));
+ assert(r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3.5);
+
+ r = m.insert(M::value_type(3, 3.5));
+ assert(!r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3.5);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp
new file mode 100644
index 00000000000..ab325ed45bf
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_initializer_list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// void insert(initializer_list<value_type> il);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::pair<const int, double> V;
+ std::map<int, double> m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ m.insert({
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ });
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ std::map<int, double, std::less<int>, min_allocator<V>> m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ m.insert({
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ });
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(2, 1));
+ assert(*next(m.begin(), 2) == V(3, 1));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp
new file mode 100644
index 00000000000..278db4631a8
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator insert(const_iterator position, const value_type& v);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::map<int, double> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.end(), M::value_type(2, 2.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2.5);
+
+ r = m.insert(m.end(), M::value_type(1, 1.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1.5);
+
+ r = m.insert(m.end(), M::value_type(3, 3.5));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+
+ r = m.insert(m.end(), M::value_type(3, 3.5));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.end(), M::value_type(2, 2.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2.5);
+
+ r = m.insert(m.end(), M::value_type(1, 1.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1.5);
+
+ r = m.insert(m.end(), M::value_type(3, 3.5));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+
+ r = m.insert(m.end(), M::value_type(3, 3.5));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp
new file mode 100644
index 00000000000..964738b4a68
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_iter.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class InputIterator>
+// void insert(InputIterator first, InputIterator last);
+
+#include <map>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::map<int, double> M;
+ typedef std::pair<int, double> P;
+ P ar[] =
+ {
+ P(1, 1),
+ P(1, 1.5),
+ P(1, 2),
+ P(2, 1),
+ P(2, 1.5),
+ P(2, 2),
+ P(3, 1),
+ P(3, 1.5),
+ P(3, 2),
+ };
+ M m;
+ m.insert(input_iterator<P*>(ar), input_iterator<P*>(ar + sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 3);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 1);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ P ar[] =
+ {
+ P(1, 1),
+ P(1, 1.5),
+ P(1, 2),
+ P(2, 1),
+ P(2, 1.5),
+ P(2, 2),
+ P(3, 1),
+ P(3, 1.5),
+ P(3, 2),
+ };
+ M m;
+ m.insert(input_iterator<P*>(ar), input_iterator<P*>(ar + sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 3);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 1);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp
new file mode 100644
index 00000000000..22164202932
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class P>
+// iterator insert(const_iterator position, P&& p);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::map<int, MoveOnly> M;
+ typedef std::pair<int, MoveOnly> P;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.end(), P(2, 2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2);
+
+ r = m.insert(m.end(), P(1, 1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1);
+
+ r = m.insert(m.end(), P(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = m.insert(m.end(), P(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M;
+ typedef std::pair<int, MoveOnly> P;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.end(), P(2, 2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2);
+
+ r = m.insert(m.end(), P(1, 1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1);
+
+ r = m.insert(m.end(), P(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = m.insert(m.end(), P(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp
new file mode 100644
index 00000000000..fea88957a70
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp
@@ -0,0 +1,93 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class P>
+// pair<iterator, bool> insert(P&& p);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::map<int, MoveOnly> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.insert(M::value_type(2, 2));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(r.first->first == 2);
+ assert(r.first->second == 2);
+
+ r = m.insert(M::value_type(1, 1));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(r.first->first == 1);
+ assert(r.first->second == 1);
+
+ r = m.insert(M::value_type(3, 3));
+ assert(r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3);
+
+ r = m.insert(M::value_type(3, 3));
+ assert(!r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.insert(M::value_type(2, 2));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(r.first->first == 2);
+ assert(r.first->second == 2);
+
+ r = m.insert(M::value_type(1, 1));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(r.first->first == 1);
+ assert(r.first->second == 1);
+
+ r = m.insert(M::value_type(3, 3));
+ assert(r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3);
+
+ r = m.insert(M::value_type(3, 3));
+ assert(!r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/map/map.ops/count.pass.cpp b/libcxx/test/std/containers/associative/map/map.ops/count.pass.cpp
new file mode 100644
index 00000000000..9668055b8bc
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.ops/count.pass.cpp
@@ -0,0 +1,173 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// size_type count(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double> M;
+ {
+ typedef M::size_type R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(5);
+ assert(r == 1);
+ r = m.count(6);
+ assert(r == 1);
+ r = m.count(7);
+ assert(r == 1);
+ r = m.count(8);
+ assert(r == 1);
+ r = m.count(9);
+ assert(r == 1);
+ r = m.count(10);
+ assert(r == 1);
+ r = m.count(11);
+ assert(r == 1);
+ r = m.count(12);
+ assert(r == 1);
+ r = m.count(4);
+ assert(r == 0);
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+ {
+ typedef M::size_type R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(5);
+ assert(r == 1);
+ r = m.count(6);
+ assert(r == 1);
+ r = m.count(7);
+ assert(r == 1);
+ r = m.count(8);
+ assert(r == 1);
+ r = m.count(9);
+ assert(r == 1);
+ r = m.count(10);
+ assert(r == 1);
+ r = m.count(11);
+ assert(r == 1);
+ r = m.count(12);
+ assert(r == 1);
+ r = m.count(4);
+ assert(r == 0);
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less <>> M;
+ typedef M::size_type R;
+
+ V ar[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(5);
+ assert(r == 1);
+ r = m.count(6);
+ assert(r == 1);
+ r = m.count(7);
+ assert(r == 1);
+ r = m.count(8);
+ assert(r == 1);
+ r = m.count(9);
+ assert(r == 1);
+ r = m.count(10);
+ assert(r == 1);
+ r = m.count(11);
+ assert(r == 1);
+ r = m.count(12);
+ assert(r == 1);
+ r = m.count(4);
+ assert(r == 0);
+ }
+
+ {
+ typedef PrivateConstructor PC;
+ typedef std::map<PC, double, std::less<>> M;
+ typedef M::size_type R;
+
+ M m;
+ m [ PC::make(5) ] = 5;
+ m [ PC::make(6) ] = 6;
+ m [ PC::make(7) ] = 7;
+ m [ PC::make(8) ] = 8;
+ m [ PC::make(9) ] = 9;
+ m [ PC::make(10) ] = 10;
+ m [ PC::make(11) ] = 11;
+ m [ PC::make(12) ] = 12;
+
+ R r = m.count(5);
+ assert(r == 1);
+ r = m.count(6);
+ assert(r == 1);
+ r = m.count(7);
+ assert(r == 1);
+ r = m.count(8);
+ assert(r == 1);
+ r = m.count(9);
+ assert(r == 1);
+ r = m.count(10);
+ assert(r == 1);
+ r = m.count(11);
+ assert(r == 1);
+ r = m.count(12);
+ assert(r == 1);
+ r = m.count(4);
+ assert(r == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.ops/equal_range.pass.cpp b/libcxx/test/std/containers/associative/map/map.ops/equal_range.pass.cpp
new file mode 100644
index 00000000000..dff751c3724
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.ops/equal_range.pass.cpp
@@ -0,0 +1,437 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// pair<iterator,iterator> equal_range(const key_type& k);
+// pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double> M;
+ {
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+ {
+ typedef std::pair<M::const_iterator, M::const_iterator> R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+ {
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+ {
+ typedef std::pair<M::const_iterator, M::const_iterator> R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<>> M;
+ typedef std::pair<M::iterator, M::iterator> R;
+
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+ {
+ typedef PrivateConstructor PC;
+ typedef std::map<PC, double, std::less<>> M;
+ typedef std::pair<M::iterator, M::iterator> R;
+
+ M m;
+ m [ PC::make(5) ] = 5;
+ m [ PC::make(7) ] = 6;
+ m [ PC::make(9) ] = 7;
+ m [ PC::make(11) ] = 8;
+ m [ PC::make(13) ] = 9;
+ m [ PC::make(15) ] = 10;
+ m [ PC::make(17) ] = 11;
+ m [ PC::make(19) ] = 12;
+
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.ops/find.pass.cpp b/libcxx/test/std/containers/associative/map/map.ops/find.pass.cpp
new file mode 100644
index 00000000000..a7578449f5b
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.ops/find.pass.cpp
@@ -0,0 +1,240 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<>> M;
+ typedef M::iterator R;
+
+ V ar[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+
+ {
+ typedef PrivateConstructor PC;
+ typedef std::map<PC, double, std::less<>> M;
+ typedef M::iterator R;
+
+ M m;
+ m [ PC::make(5) ] = 5;
+ m [ PC::make(6) ] = 6;
+ m [ PC::make(7) ] = 7;
+ m [ PC::make(8) ] = 8;
+ m [ PC::make(9) ] = 9;
+ m [ PC::make(10) ] = 10;
+ m [ PC::make(11) ] = 11;
+ m [ PC::make(12) ] = 12;
+
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.ops/lower_bound.pass.cpp b/libcxx/test/std/containers/associative/map/map.ops/lower_bound.pass.cpp
new file mode 100644
index 00000000000..87b84eef070
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.ops/lower_bound.pass.cpp
@@ -0,0 +1,336 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less <>> M;
+ typedef M::iterator R;
+
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+
+ {
+ typedef PrivateConstructor PC;
+ typedef std::map<PC, double, std::less<>> M;
+ typedef M::iterator R;
+
+ M m;
+ m [ PC::make(5) ] = 5;
+ m [ PC::make(7) ] = 6;
+ m [ PC::make(9) ] = 7;
+ m [ PC::make(11) ] = 8;
+ m [ PC::make(13) ] = 9;
+ m [ PC::make(15) ] = 10;
+ m [ PC::make(17) ] = 11;
+ m [ PC::make(19) ] = 12;
+
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.ops/upper_bound.pass.cpp b/libcxx/test/std/containers/associative/map/map.ops/upper_bound.pass.cpp
new file mode 100644
index 00000000000..037ceb962cd
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.ops/upper_bound.pass.cpp
@@ -0,0 +1,335 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<>> M;
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 5),
+ V(7, 6),
+ V(9, 7),
+ V(11, 8),
+ V(13, 9),
+ V(15, 10),
+ V(17, 11),
+ V(19, 12)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+
+ {
+ typedef PrivateConstructor PC;
+ typedef std::map<PC, double, std::less<>> M;
+ typedef M::iterator R;
+
+ M m;
+ m [ PC::make(5) ] = 5;
+ m [ PC::make(7) ] = 6;
+ m [ PC::make(9) ] = 7;
+ m [ PC::make(11) ] = 8;
+ m [ PC::make(13) ] = 9;
+ m [ PC::make(15) ] = 10;
+ m [ PC::make(17) ] = 11;
+ m [ PC::make(19) ] = 12;
+
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.special/member_swap.pass.cpp b/libcxx/test/std/containers/associative/map/map.special/member_swap.pass.cpp
new file mode 100644
index 00000000000..4f7bd5154ed
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.special/member_swap.pass.cpp
@@ -0,0 +1,201 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// void swap(map& m);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double> M;
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.special/non_member_swap.pass.cpp b/libcxx/test/std/containers/associative/map/map.special/non_member_swap.pass.cpp
new file mode 100644
index 00000000000..57588e6ff16
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.special/non_member_swap.pass.cpp
@@ -0,0 +1,306 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map
+
+// template <class Key, class T, class Compare, class Allocator>
+// void
+// swap(map<Key, T, Compare, Allocator>& x, map<Key, T, Compare, Allocator>& y);
+
+#include <map>
+#include <cassert>
+#include "test_allocator.h"
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double> M;
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ typedef test_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::map<int, double, C, A> M;
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ assert(m1.key_comp() == C(2));
+ assert(m1.get_allocator() == A(1));
+ assert(m2.key_comp() == C(1));
+ assert(m2.get_allocator() == A(2));
+ }
+ {
+ typedef other_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::map<int, double, C, A> M;
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ assert(m1.key_comp() == C(2));
+ assert(m1.get_allocator() == A(2));
+ assert(m2.key_comp() == C(1));
+ assert(m2.get_allocator() == A(1));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::map<int, double, std::less<int>, min_allocator<V>> M;
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ typedef min_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::map<int, double, C, A> M;
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A());
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A());
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ assert(m1.key_comp() == C(2));
+ assert(m1.get_allocator() == A());
+ assert(m2.key_comp() == C(1));
+ assert(m2.get_allocator() == A());
+ }
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp
new file mode 100644
index 00000000000..b8b78635166
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/map.special/swap_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// void swap(map& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+
+ some_comp() {}
+ some_comp(const some_comp&) {}
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::map<MoveOnly, MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/types.pass.cpp b/libcxx/test/std/containers/associative/map/types.pass.cpp
new file mode 100644
index 00000000000..d117deff693
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/types.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// template <class Key, class T, class Compare = less<Key>,
+// class Allocator = allocator<pair<const Key, T>>>
+// class map
+// {
+// public:
+// // types:
+// typedef Key key_type;
+// typedef T mapped_type;
+// typedef pair<const key_type, mapped_type> value_type;
+// typedef Compare key_compare;
+// typedef Allocator allocator_type;
+// typedef typename allocator_type::reference reference;
+// typedef typename allocator_type::const_reference const_reference;
+// typedef typename allocator_type::pointer pointer;
+// typedef typename allocator_type::const_pointer const_pointer;
+// typedef typename allocator_type::size_type size_type;
+// typedef typename allocator_type::difference_type difference_type;
+// ...
+// };
+
+#include <map>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::map<int, double> C;
+ static_assert((std::is_same<C::key_type, int>::value), "");
+ static_assert((std::is_same<C::mapped_type, double>::value), "");
+ static_assert((std::is_same<C::value_type, std::pair<const int, double> >::value), "");
+ static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::allocator_type, std::allocator<std::pair<const int, double> > >::value), "");
+ static_assert((std::is_same<C::reference, std::pair<const int, double>&>::value), "");
+ static_assert((std::is_same<C::const_reference, const std::pair<const int, double>&>::value), "");
+ static_assert((std::is_same<C::pointer, std::pair<const int, double>*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const std::pair<const int, double>*>::value), "");
+ static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C;
+ static_assert((std::is_same<C::key_type, int>::value), "");
+ static_assert((std::is_same<C::mapped_type, double>::value), "");
+ static_assert((std::is_same<C::value_type, std::pair<const int, double> >::value), "");
+ static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<std::pair<const int, double> > >::value), "");
+ static_assert((std::is_same<C::reference, std::pair<const int, double>&>::value), "");
+ static_assert((std::is_same<C::const_reference, const std::pair<const int, double>&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<std::pair<const int, double>>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const std::pair<const int, double>>>::value), "");
+// min_allocator doesn't have a size_type, so one gets synthesized
+ static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/map/version.pass.cpp b/libcxx/test/std/containers/associative/map/version.pass.cpp
new file mode 100644
index 00000000000..b2e3fa43e78
--- /dev/null
+++ b/libcxx/test/std/containers/associative/map/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+#include <map>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/associative/multimap/empty.pass.cpp b/libcxx/test/std/containers/associative/multimap/empty.pass.cpp
new file mode 100644
index 00000000000..2384960d10d
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/empty.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// bool empty() const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> M;
+ M m;
+ assert(m.empty());
+ m.insert(M::value_type(1, 1.5));
+ assert(!m.empty());
+ m.clear();
+ assert(m.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ M m;
+ assert(m.empty());
+ m.insert(M::value_type(1, 1.5));
+ assert(!m.empty());
+ m.clear();
+ assert(m.empty());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/iterator.pass.cpp b/libcxx/test/std/containers/associative/multimap/iterator.pass.cpp
new file mode 100644
index 00000000000..2763129acc2
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/iterator.pass.cpp
@@ -0,0 +1,231 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator begin();
+// const_iterator begin() const;
+// iterator end();
+// const_iterator end() const;
+//
+// reverse_iterator rbegin();
+// const_reverse_iterator rbegin() const;
+// reverse_iterator rend();
+// const_reverse_iterator rend() const;
+//
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+// const_reverse_iterator crbegin() const;
+// const_reverse_iterator crend() const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ V(4, 1),
+ V(4, 1.5),
+ V(4, 2),
+ V(5, 1),
+ V(5, 1.5),
+ V(5, 2),
+ V(6, 1),
+ V(6, 1.5),
+ V(6, 2),
+ V(7, 1),
+ V(7, 1.5),
+ V(7, 2),
+ V(8, 1),
+ V(8, 1.5),
+ V(8, 2)
+ };
+ std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ std::multimap<int, double>::iterator i;
+ i = m.begin();
+ std::multimap<int, double>::const_iterator k = i;
+ assert(i == k);
+ for (int j = 1; j <= 8; ++j)
+ for (double d = 1; d <= 2; d += .5, ++i)
+ {
+ assert(i->first == j);
+ assert(i->second == d);
+ i->second = 2.5;
+ assert(i->second == 2.5);
+ }
+ }
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ V(4, 1),
+ V(4, 1.5),
+ V(4, 2),
+ V(5, 1),
+ V(5, 1.5),
+ V(5, 2),
+ V(6, 1),
+ V(6, 1.5),
+ V(6, 2),
+ V(7, 1),
+ V(7, 1.5),
+ V(7, 2),
+ V(8, 1),
+ V(8, 1.5),
+ V(8, 2)
+ };
+ const std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.cbegin(), m.cend()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ assert(std::distance(m.crbegin(), m.crend()) == m.size());
+ std::multimap<int, double>::const_iterator i;
+ i = m.begin();
+ for (int j = 1; j <= 8; ++j)
+ for (double d = 1; d <= 2; d += .5, ++i)
+ {
+ assert(i->first == j);
+ assert(i->second == d);
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ V(4, 1),
+ V(4, 1.5),
+ V(4, 2),
+ V(5, 1),
+ V(5, 1.5),
+ V(5, 2),
+ V(6, 1),
+ V(6, 1.5),
+ V(6, 2),
+ V(7, 1),
+ V(7, 1.5),
+ V(7, 2),
+ V(8, 1),
+ V(8, 1.5),
+ V(8, 2)
+ };
+ std::multimap<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ std::multimap<int, double, std::less<int>, min_allocator<V>>::iterator i;
+ i = m.begin();
+ std::multimap<int, double, std::less<int>, min_allocator<V>>::const_iterator k = i;
+ assert(i == k);
+ for (int j = 1; j <= 8; ++j)
+ for (double d = 1; d <= 2; d += .5, ++i)
+ {
+ assert(i->first == j);
+ assert(i->second == d);
+ i->second = 2.5;
+ assert(i->second == 2.5);
+ }
+ }
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ V(4, 1),
+ V(4, 1.5),
+ V(4, 2),
+ V(5, 1),
+ V(5, 1.5),
+ V(5, 2),
+ V(6, 1),
+ V(6, 1.5),
+ V(6, 2),
+ V(7, 1),
+ V(7, 1.5),
+ V(7, 2),
+ V(8, 1),
+ V(8, 1.5),
+ V(8, 2)
+ };
+ const std::multimap<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.cbegin(), m.cend()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ assert(std::distance(m.crbegin(), m.crend()) == m.size());
+ std::multimap<int, double, std::less<int>, min_allocator<V>>::const_iterator i;
+ i = m.begin();
+ for (int j = 1; j <= 8; ++j)
+ for (double d = 1; d <= 2; d += .5, ++i)
+ {
+ assert(i->first == j);
+ assert(i->second == d);
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::multimap<int, double> C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/max_size.pass.cpp b/libcxx/test/std/containers/associative/multimap/max_size.pass.cpp
new file mode 100644
index 00000000000..ccd8b10638c
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/max_size.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// size_type max_size() const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> M;
+ M m;
+ assert(m.max_size() != 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ M m;
+ assert(m.max_size() != 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/alloc.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/alloc.pass.cpp
new file mode 100644
index 00000000000..87bf0447e5b
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/alloc.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// explicit multimap(const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::less<int> C;
+ typedef test_allocator<std::pair<const int, double> > A;
+ std::multimap<int, double, C, A> m(A(5));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.get_allocator() == A(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::less<int> C;
+ typedef min_allocator<std::pair<const int, double> > A;
+ std::multimap<int, double, C, A> m(A{});
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.get_allocator() == A());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 00000000000..0c899183252
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/assign_initializer_list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap& operator=(initializer_list<value_type> il);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::multimap<int, double> C;
+ typedef C::value_type V;
+ C m = {{20, 1}};
+ m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1, 1));
+ assert(*++i == V(1, 1.5));
+ assert(*++i == V(1, 2));
+ assert(*++i == V(2, 1));
+ assert(*++i == V(2, 1.5));
+ assert(*++i == V(2, 2));
+ assert(*++i == V(3, 1));
+ assert(*++i == V(3, 1.5));
+ assert(*++i == V(3, 2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C;
+ typedef C::value_type V;
+ C m = {{20, 1}};
+ m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1, 1));
+ assert(*++i == V(1, 1.5));
+ assert(*++i == V(1, 2));
+ assert(*++i == V(2, 1));
+ assert(*++i == V(2, 1.5));
+ assert(*++i == V(2, 2));
+ assert(*++i == V(3, 1));
+ assert(*++i == V(3, 1.5));
+ assert(*++i == V(3, 2));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/compare.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/compare.pass.cpp
new file mode 100644
index 00000000000..9a4e0f987fd
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/compare.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// explicit multimap(const key_compare& comp);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_compare<std::less<int> > C;
+ std::multimap<int, double, C> m(C(3));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(3));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_compare<std::less<int> > C;
+ std::multimap<int, double, C, min_allocator<std::pair<const int, double>>> m(C(3));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(3));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp
new file mode 100644
index 00000000000..1224884939c
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp
@@ -0,0 +1,45 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<std::pair<const int, double> > A;
+ std::multimap<int, double, C, A> m(C(4), A(5));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(4));
+ assert(m.get_allocator() == A(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<std::pair<const int, double> > A;
+ std::multimap<int, double, C, A> m(C(4), A());
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(4));
+ assert(m.get_allocator() == A());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/copy.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/copy.pass.cpp
new file mode 100644
index 00000000000..3d6626eaadb
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/copy.pass.cpp
@@ -0,0 +1,104 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(const multimap& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::multimap<int, double, C, A> m = mo;
+ assert(m == mo);
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef other_allocator<V> A;
+ std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::multimap<int, double, C, A> m = mo;
+ assert(m == mo);
+ assert(m.get_allocator() == A(-2));
+ assert(m.key_comp() == C(5));
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::multimap<int, double, C, A> m = mo;
+ assert(m == mo);
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp
new file mode 100644
index 00000000000..22594e32d71
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/copy_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(const multimap& m, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::multimap<int, double, C, A> m(mo, A(3));
+ assert(m == mo);
+ assert(m.get_allocator() == A(3));
+ assert(m.key_comp() == C(5));
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::multimap<int, double, C, A> m(mo, A());
+ assert(m == mo);
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp
new file mode 100644
index 00000000000..2bdc4d6a70a
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp
@@ -0,0 +1,125 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap& operator=(const multimap& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+ std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+ m = mo;
+ assert(m == mo);
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+
+ assert(mo.get_allocator() == A(2));
+ assert(mo.key_comp() == C(5));
+ }
+ {
+ typedef std::pair<const int, double> V;
+ const V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ std::multimap<int, double> *p = &m;
+ m = *p;
+ assert(m.size() == sizeof(ar)/sizeof(ar[0]));
+ assert(std::equal(m.begin(), m.end(), ar));
+ }
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef other_allocator<V> A;
+ std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+ std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+ m = mo;
+ assert(m == mo);
+ assert(m.get_allocator() == A(2));
+ assert(m.key_comp() == C(5));
+
+ assert(mo.get_allocator() == A(2));
+ assert(mo.key_comp() == C(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A());
+ m = mo;
+ assert(m == mo);
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/default.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/default.pass.cpp
new file mode 100644
index 00000000000..1c3ab8ce6c4
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/default.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap();
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::multimap<int, double> m;
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> m;
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+ {
+ std::multimap<int, double> m = {};
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp
new file mode 100644
index 00000000000..315efd15276
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// multimap()
+// noexcept(
+// is_nothrow_default_constructible<allocator_type>::value &&
+// is_nothrow_default_constructible<key_compare>::value &&
+// is_nothrow_copy_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp();
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::multimap<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 00000000000..50d8f42a9ab
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// ~multimap() // implied noexcept;
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ ~some_comp() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::multimap<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp
new file mode 100644
index 00000000000..937a202a55e
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/initializer_list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::multimap<int, double> C;
+ typedef C::value_type V;
+ C m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1, 1));
+ assert(*++i == V(1, 1.5));
+ assert(*++i == V(1, 2));
+ assert(*++i == V(2, 1));
+ assert(*++i == V(2, 1.5));
+ assert(*++i == V(2, 2));
+ assert(*++i == V(3, 1));
+ assert(*++i == V(3, 1.5));
+ assert(*++i == V(3, 2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C;
+ typedef C::value_type V;
+ C m =
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ };
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1, 1));
+ assert(*++i == V(1, 1.5));
+ assert(*++i == V(1, 2));
+ assert(*++i == V(2, 1));
+ assert(*++i == V(2, 1.5));
+ assert(*++i == V(2, 2));
+ assert(*++i == V(3, 1));
+ assert(*++i == V(3, 1.5));
+ assert(*++i == V(3, 2));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp
new file mode 100644
index 00000000000..e6677039c90
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <map>
+#include <cassert>
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef test_compare<std::less<int> > Cmp;
+ typedef std::multimap<int, double, Cmp> C;
+ typedef C::value_type V;
+ C m(
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ },
+ Cmp(4)
+ );
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1, 1));
+ assert(*++i == V(1, 1.5));
+ assert(*++i == V(1, 2));
+ assert(*++i == V(2, 1));
+ assert(*++i == V(2, 1.5));
+ assert(*++i == V(2, 2));
+ assert(*++i == V(3, 1));
+ assert(*++i == V(3, 1.5));
+ assert(*++i == V(3, 2));
+ assert(m.key_comp() == Cmp(4));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_compare<std::less<int> > Cmp;
+ typedef std::multimap<int, double, Cmp, min_allocator<std::pair<const int, double>>> C;
+ typedef C::value_type V;
+ C m(
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ },
+ Cmp(4)
+ );
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1, 1));
+ assert(*++i == V(1, 1.5));
+ assert(*++i == V(1, 2));
+ assert(*++i == V(2, 1));
+ assert(*++i == V(2, 1.5));
+ assert(*++i == V(2, 2));
+ assert(*++i == V(3, 1));
+ assert(*++i == V(3, 1.5));
+ assert(*++i == V(3, 2));
+ assert(m.key_comp() == Cmp(4));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp
new file mode 100644
index 00000000000..0e73f72793e
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp
@@ -0,0 +1,129 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef test_compare<std::less<int> > Cmp;
+ typedef test_allocator<std::pair<const int, double> > A;
+ typedef std::multimap<int, double, Cmp, A> C;
+ typedef C::value_type V;
+ C m(
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ },
+ Cmp(4), A(5)
+ );
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1, 1));
+ assert(*++i == V(1, 1.5));
+ assert(*++i == V(1, 2));
+ assert(*++i == V(2, 1));
+ assert(*++i == V(2, 1.5));
+ assert(*++i == V(2, 2));
+ assert(*++i == V(3, 1));
+ assert(*++i == V(3, 1.5));
+ assert(*++i == V(3, 2));
+ assert(m.key_comp() == Cmp(4));
+ assert(m.get_allocator() == A(5));
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#if __cplusplus >= 201103L
+ {
+ typedef test_compare<std::less<int> > Cmp;
+ typedef min_allocator<std::pair<const int, double> > A;
+ typedef std::multimap<int, double, Cmp, A> C;
+ typedef C::value_type V;
+ C m(
+ {
+ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ },
+ Cmp(4), A()
+ );
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1, 1));
+ assert(*++i == V(1, 1.5));
+ assert(*++i == V(1, 2));
+ assert(*++i == V(2, 1));
+ assert(*++i == V(2, 1.5));
+ assert(*++i == V(2, 2));
+ assert(*++i == V(3, 1));
+ assert(*++i == V(3, 1.5));
+ assert(*++i == V(3, 2));
+ assert(m.key_comp() == Cmp(4));
+ assert(m.get_allocator() == A());
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef test_compare<std::less<int> > C;
+ typedef std::pair<const int, double> V;
+ typedef min_allocator<V> A;
+ typedef std::multimap<int, double, C, A> M;
+ A a;
+ M m ({ {1, 1},
+ {1, 1.5},
+ {1, 2},
+ {2, 1},
+ {2, 1.5},
+ {2, 2},
+ {3, 1},
+ {3, 1.5},
+ {3, 2}
+ }, a);
+
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ M::const_iterator i = m.cbegin();
+ assert(*i == V(1, 1));
+ assert(*++i == V(1, 1.5));
+ assert(*++i == V(1, 2));
+ assert(*++i == V(2, 1));
+ assert(*++i == V(2, 1.5));
+ assert(*++i == V(2, 2));
+ assert(*++i == V(3, 1));
+ assert(*++i == V(3, 1.5));
+ assert(*++i == V(3, 2));
+ assert(m.get_allocator() == a);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp
new file mode 100644
index 00000000000..fa062e2be0b
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class InputIterator>
+// multimap(InputIterator first, InputIterator last);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ std::multimap<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(1, 1.5));
+ assert(*next(m.begin(), 2) == V(1, 2));
+ assert(*next(m.begin(), 3) == V(2, 1));
+ assert(*next(m.begin(), 4) == V(2, 1.5));
+ assert(*next(m.begin(), 5) == V(2, 2));
+ assert(*next(m.begin(), 6) == V(3, 1));
+ assert(*next(m.begin(), 7) == V(3, 1.5));
+ assert(*next(m.begin(), 8) == V(3, 2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ std::multimap<int, double, std::less<int>, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(1, 1.5));
+ assert(*next(m.begin(), 2) == V(1, 2));
+ assert(*next(m.begin(), 3) == V(2, 1));
+ assert(*next(m.begin(), 4) == V(2, 1.5));
+ assert(*next(m.begin(), 5) == V(2, 2));
+ assert(*next(m.begin(), 6) == V(3, 1));
+ assert(*next(m.begin(), 7) == V(3, 1.5));
+ assert(*next(m.begin(), 8) == V(3, 2));
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef min_allocator<std::pair<const int, double>> A;
+ A a;
+ std::multimap<int, double, std::less<int>, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a);
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(1, 1.5));
+ assert(*next(m.begin(), 2) == V(1, 2));
+ assert(*next(m.begin(), 3) == V(2, 1));
+ assert(*next(m.begin(), 4) == V(2, 1.5));
+ assert(*next(m.begin(), 5) == V(2, 2));
+ assert(*next(m.begin(), 6) == V(3, 1));
+ assert(*next(m.begin(), 7) == V(3, 1.5));
+ assert(*next(m.begin(), 8) == V(3, 2));
+ assert(m.get_allocator() == a);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp
new file mode 100644
index 00000000000..d6de59428dd
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp
@@ -0,0 +1,86 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class InputIterator>
+// multimap(InputIterator first, InputIterator last,
+// const key_compare& comp);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ std::multimap<int, double, C> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(1, 1.5));
+ assert(*next(m.begin(), 2) == V(1, 2));
+ assert(*next(m.begin(), 3) == V(2, 1));
+ assert(*next(m.begin(), 4) == V(2, 1.5));
+ assert(*next(m.begin(), 5) == V(2, 2));
+ assert(*next(m.begin(), 6) == V(3, 1));
+ assert(*next(m.begin(), 7) == V(3, 1.5));
+ assert(*next(m.begin(), 8) == V(3, 2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ std::multimap<int, double, C, min_allocator<V>> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(1, 1.5));
+ assert(*next(m.begin(), 2) == V(1, 2));
+ assert(*next(m.begin(), 3) == V(2, 1));
+ assert(*next(m.begin(), 4) == V(2, 1.5));
+ assert(*next(m.begin(), 5) == V(2, 2));
+ assert(*next(m.begin(), 6) == V(3, 1));
+ assert(*next(m.begin(), 7) == V(3, 1.5));
+ assert(*next(m.begin(), 8) == V(3, 2));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp
new file mode 100644
index 00000000000..259fbd145ff
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class InputIterator>
+// multimap(InputIterator first, InputIterator last,
+// const key_compare& comp, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(1, 1.5));
+ assert(*next(m.begin(), 2) == V(1, 2));
+ assert(*next(m.begin(), 3) == V(2, 1));
+ assert(*next(m.begin(), 4) == V(2, 1.5));
+ assert(*next(m.begin(), 5) == V(2, 2));
+ assert(*next(m.begin(), 6) == V(3, 1));
+ assert(*next(m.begin(), 7) == V(3, 1.5));
+ assert(*next(m.begin(), 8) == V(3, 2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<const int, double> V;
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::multimap<int, double, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(1, 1.5));
+ assert(*next(m.begin(), 2) == V(1, 2));
+ assert(*next(m.begin(), 3) == V(2, 1));
+ assert(*next(m.begin(), 4) == V(2, 1.5));
+ assert(*next(m.begin(), 5) == V(2, 2));
+ assert(*next(m.begin(), 6) == V(3, 1));
+ assert(*next(m.begin(), 7) == V(3, 1.5));
+ assert(*next(m.begin(), 8) == V(3, 2));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/move.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/move.pass.cpp
new file mode 100644
index 00000000000..aed08867c3c
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/move.pass.cpp
@@ -0,0 +1,132 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(multimap&& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ typedef std::pair<const int, double> V;
+ {
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::multimap<int, double, C, A> mo(C(5), A(7));
+ std::multimap<int, double, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 0);
+ assert(distance(m.begin(), m.end()) == 0);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+ {
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::multimap<int, double, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(1, 1.5));
+ assert(*next(m.begin(), 2) == V(1, 2));
+ assert(*next(m.begin(), 3) == V(2, 1));
+ assert(*next(m.begin(), 4) == V(2, 1.5));
+ assert(*next(m.begin(), 5) == V(2, 2));
+ assert(*next(m.begin(), 6) == V(3, 1));
+ assert(*next(m.begin(), 7) == V(3, 1.5));
+ assert(*next(m.begin(), 8) == V(3, 2));
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::multimap<int, double, C, A> mo(C(5), A());
+ std::multimap<int, double, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 0);
+ assert(distance(m.begin(), m.end()) == 0);
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+ {
+ V ar[] =
+ {
+ V(1, 1),
+ V(1, 1.5),
+ V(1, 2),
+ V(2, 1),
+ V(2, 1.5),
+ V(2, 2),
+ V(3, 1),
+ V(3, 1.5),
+ V(3, 2),
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::multimap<int, double, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::multimap<int, double, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*m.begin() == V(1, 1));
+ assert(*next(m.begin()) == V(1, 1.5));
+ assert(*next(m.begin(), 2) == V(1, 2));
+ assert(*next(m.begin(), 3) == V(2, 1));
+ assert(*next(m.begin(), 4) == V(2, 1.5));
+ assert(*next(m.begin(), 5) == V(2, 2));
+ assert(*next(m.begin(), 6) == V(3, 1));
+ assert(*next(m.begin(), 7) == V(3, 1.5));
+ assert(*next(m.begin(), 8) == V(3, 2));
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp
new file mode 100644
index 00000000000..651993a769f
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp
@@ -0,0 +1,186 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap(multimap&& m, const allocator_type& a);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<VC> A;
+ typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(7));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<VC> A;
+ typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(5));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef other_allocator<VC> A;
+ typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(5));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef min_allocator<VC> A;
+ typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A());
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A());
+ M m3(std::move(m1), A());
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A());
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp
new file mode 100644
index 00000000000..496e5357279
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp
@@ -0,0 +1,190 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// multimap& operator=(multimap&& m);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<VC> A;
+ typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(7));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<VC> A;
+ typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(5));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef other_allocator<VC> A;
+ typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(5));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<MoveOnly, MoveOnly> V;
+ typedef std::pair<const MoveOnly, MoveOnly> VC;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef min_allocator<VC> A;
+ typedef std::multimap<MoveOnly, MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A());
+ V a2[] =
+ {
+ V(1, 1),
+ V(1, 2),
+ V(1, 3),
+ V(2, 1),
+ V(2, 2),
+ V(2, 3),
+ V(3, 1),
+ V(3, 2),
+ V(3, 3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A());
+ M m3(C(3), A());
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A());
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 00000000000..b2488180c5e
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// multimap& operator=(multimap&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value &&
+// is_nothrow_move_assignable<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp& operator=(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::multimap<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp
new file mode 100644
index 00000000000..84316a1ea06
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// multimap(multimap&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+// is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::multimap<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/clear.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/clear.pass.cpp
new file mode 100644
index 00000000000..fe9b8c8ba12
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/clear.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// void clear();
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> M;
+ typedef std::pair<int, double> P;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ m.clear();
+ assert(m.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ m.clear();
+ assert(m.size() == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp
new file mode 100644
index 00000000000..03da4af5937
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp
@@ -0,0 +1,150 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class... Args>
+// iterator emplace(Args&&... args);
+
+#include <map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::multimap<int, DefaultOnly> M;
+ typedef M::iterator R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace();
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 0);
+ assert(m.begin()->second == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin(), 2));
+ assert(m.size() == 3);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == DefaultOnly());
+ assert(DefaultOnly::count == 3);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::multimap<int, Emplaceable> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace(std::piecewise_construct, std::forward_as_tuple(2),
+ std::forward_as_tuple());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == Emplaceable());
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple(3, 3.5));
+ assert(r == next(m.begin()));
+ assert(m.size() == 3);
+ assert(r->first == 1);
+ assert(r->second == Emplaceable(3, 3.5));
+ }
+ {
+ typedef std::multimap<int, double> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace(M::value_type(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 3.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
+ typedef M::iterator R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace();
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 0);
+ assert(m.begin()->second == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin(), 2));
+ assert(m.size() == 3);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == DefaultOnly());
+ assert(DefaultOnly::count == 3);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::multimap<int, Emplaceable, std::less<int>, min_allocator<std::pair<const int, Emplaceable>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace(std::piecewise_construct, std::forward_as_tuple(2),
+ std::forward_as_tuple());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == Emplaceable());
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ r = m.emplace(std::piecewise_construct, std::forward_as_tuple(1),
+ std::forward_as_tuple(3, 3.5));
+ assert(r == next(m.begin()));
+ assert(m.size() == 3);
+ assert(r->first == 1);
+ assert(r->second == Emplaceable(3, 3.5));
+ }
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace(M::value_type(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 3.5);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp
new file mode 100644
index 00000000000..846d5999a17
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class... Args>
+// iterator emplace_hint(const_iterator position, Args&&... args);
+
+#include <map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::multimap<int, DefaultOnly> M;
+ typedef M::iterator R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace_hint(m.cend());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 0);
+ assert(m.begin()->second == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+ r = m.emplace_hint(m.cend(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ r = m.emplace_hint(m.cend(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin(), 2));
+ assert(m.size() == 3);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == DefaultOnly());
+ assert(DefaultOnly::count == 3);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::multimap<int, Emplaceable> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.cend(), std::piecewise_construct,
+ std::forward_as_tuple(2),
+ std::forward_as_tuple());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == Emplaceable());
+ r = m.emplace_hint(m.cbegin(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ r = m.emplace_hint(m.cbegin(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple(3, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 3);
+ assert(r->first == 1);
+ assert(r->second == Emplaceable(3, 3.5));
+ }
+ {
+ typedef std::multimap<int, double> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.cend(), M::value_type(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 3.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M;
+ typedef M::iterator R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace_hint(m.cend());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 0);
+ assert(m.begin()->second == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+ r = m.emplace_hint(m.cend(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ r = m.emplace_hint(m.cend(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple());
+ assert(r == next(m.begin(), 2));
+ assert(m.size() == 3);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == DefaultOnly());
+ assert(DefaultOnly::count == 3);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::multimap<int, Emplaceable, std::less<int>, min_allocator<std::pair<const int, Emplaceable>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.cend(), std::piecewise_construct,
+ std::forward_as_tuple(2),
+ std::forward_as_tuple());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == Emplaceable());
+ r = m.emplace_hint(m.cbegin(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == Emplaceable(2, 3.5));
+ r = m.emplace_hint(m.cbegin(), std::piecewise_construct,
+ std::forward_as_tuple(1),
+ std::forward_as_tuple(3, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 3);
+ assert(r->first == 1);
+ assert(r->second == Emplaceable(3, 3.5));
+ }
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.cend(), M::value_type(2, 3.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(m.begin()->first == 2);
+ assert(m.begin()->second == 3.5);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp
new file mode 100644
index 00000000000..d91295b48c6
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp
@@ -0,0 +1,279 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator erase(const_iterator position);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> M;
+ typedef std::pair<int, double> P;
+ typedef M::iterator I;
+ P ar[] =
+ {
+ P(1, 1),
+ P(1, 1.5),
+ P(1, 2),
+ P(2, 1),
+ P(2, 1.5),
+ P(2, 2),
+ P(3, 1),
+ P(3, 1.5),
+ P(3, 2),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 9);
+ I i = m.erase(next(m.cbegin(), 3));
+ assert(m.size() == 8);
+ assert(i == next(m.begin(), 3));
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == 1.5);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == 2);
+ assert(next(m.begin(), 3)->first == 2);
+ assert(next(m.begin(), 3)->second == 1.5);
+ assert(next(m.begin(), 4)->first == 2);
+ assert(next(m.begin(), 4)->second == 2);
+ assert(next(m.begin(), 5)->first == 3);
+ assert(next(m.begin(), 5)->second == 1);
+ assert(next(m.begin(), 6)->first == 3);
+ assert(next(m.begin(), 6)->second == 1.5);
+ assert(next(m.begin(), 7)->first == 3);
+ assert(next(m.begin(), 7)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 7);
+ assert(i == m.begin());
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 1);
+ assert(next(m.begin(), 1)->second == 2);
+ assert(next(m.begin(), 2)->first == 2);
+ assert(next(m.begin(), 2)->second == 1.5);
+ assert(next(m.begin(), 3)->first == 2);
+ assert(next(m.begin(), 3)->second == 2);
+ assert(next(m.begin(), 4)->first == 3);
+ assert(next(m.begin(), 4)->second == 1);
+ assert(next(m.begin(), 5)->first == 3);
+ assert(next(m.begin(), 5)->second == 1.5);
+ assert(next(m.begin(), 6)->first == 3);
+ assert(next(m.begin(), 6)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 5));
+ assert(m.size() == 6);
+ assert(i == prev(m.end()));
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 1);
+ assert(next(m.begin(), 1)->second == 2);
+ assert(next(m.begin(), 2)->first == 2);
+ assert(next(m.begin(), 2)->second == 1.5);
+ assert(next(m.begin(), 3)->first == 2);
+ assert(next(m.begin(), 3)->second == 2);
+ assert(next(m.begin(), 4)->first == 3);
+ assert(next(m.begin(), 4)->second == 1);
+ assert(next(m.begin(), 5)->first == 3);
+ assert(next(m.begin(), 5)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 1));
+ assert(m.size() == 5);
+ assert(i == next(m.begin()));
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 2);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 2);
+ assert(next(m.begin(), 2)->second == 2);
+ assert(next(m.begin(), 3)->first == 3);
+ assert(next(m.begin(), 3)->second == 1);
+ assert(next(m.begin(), 4)->first == 3);
+ assert(next(m.begin(), 4)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 4);
+ assert(i == next(m.begin(), 2));
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 2);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 1);
+ assert(next(m.begin(), 3)->first == 3);
+ assert(next(m.begin(), 3)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 3);
+ assert(i == next(m.begin(), 2));
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 2);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 0));
+ assert(next(m.begin(), 0)->first == 2);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 3);
+ assert(next(m.begin(), 1)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 1));
+ assert(m.size() == 1);
+ assert(i == m.end());
+ assert(next(m.begin(), 0)->first == 2);
+ assert(next(m.begin(), 0)->second == 1.5);
+
+ i = m.erase(m.cbegin());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ typedef M::iterator I;
+ P ar[] =
+ {
+ P(1, 1),
+ P(1, 1.5),
+ P(1, 2),
+ P(2, 1),
+ P(2, 1.5),
+ P(2, 2),
+ P(3, 1),
+ P(3, 1.5),
+ P(3, 2),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 9);
+ I i = m.erase(next(m.cbegin(), 3));
+ assert(m.size() == 8);
+ assert(i == next(m.begin(), 3));
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == 1.5);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == 2);
+ assert(next(m.begin(), 3)->first == 2);
+ assert(next(m.begin(), 3)->second == 1.5);
+ assert(next(m.begin(), 4)->first == 2);
+ assert(next(m.begin(), 4)->second == 2);
+ assert(next(m.begin(), 5)->first == 3);
+ assert(next(m.begin(), 5)->second == 1);
+ assert(next(m.begin(), 6)->first == 3);
+ assert(next(m.begin(), 6)->second == 1.5);
+ assert(next(m.begin(), 7)->first == 3);
+ assert(next(m.begin(), 7)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 7);
+ assert(i == m.begin());
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 1);
+ assert(next(m.begin(), 1)->second == 2);
+ assert(next(m.begin(), 2)->first == 2);
+ assert(next(m.begin(), 2)->second == 1.5);
+ assert(next(m.begin(), 3)->first == 2);
+ assert(next(m.begin(), 3)->second == 2);
+ assert(next(m.begin(), 4)->first == 3);
+ assert(next(m.begin(), 4)->second == 1);
+ assert(next(m.begin(), 5)->first == 3);
+ assert(next(m.begin(), 5)->second == 1.5);
+ assert(next(m.begin(), 6)->first == 3);
+ assert(next(m.begin(), 6)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 5));
+ assert(m.size() == 6);
+ assert(i == prev(m.end()));
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 1);
+ assert(next(m.begin(), 1)->second == 2);
+ assert(next(m.begin(), 2)->first == 2);
+ assert(next(m.begin(), 2)->second == 1.5);
+ assert(next(m.begin(), 3)->first == 2);
+ assert(next(m.begin(), 3)->second == 2);
+ assert(next(m.begin(), 4)->first == 3);
+ assert(next(m.begin(), 4)->second == 1);
+ assert(next(m.begin(), 5)->first == 3);
+ assert(next(m.begin(), 5)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 1));
+ assert(m.size() == 5);
+ assert(i == next(m.begin()));
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 2);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 2);
+ assert(next(m.begin(), 2)->second == 2);
+ assert(next(m.begin(), 3)->first == 3);
+ assert(next(m.begin(), 3)->second == 1);
+ assert(next(m.begin(), 4)->first == 3);
+ assert(next(m.begin(), 4)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 4);
+ assert(i == next(m.begin(), 2));
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 2);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 1);
+ assert(next(m.begin(), 3)->first == 3);
+ assert(next(m.begin(), 3)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 3);
+ assert(i == next(m.begin(), 2));
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 2);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 0));
+ assert(next(m.begin(), 0)->first == 2);
+ assert(next(m.begin(), 0)->second == 1.5);
+ assert(next(m.begin(), 1)->first == 3);
+ assert(next(m.begin(), 1)->second == 2);
+
+ i = m.erase(next(m.cbegin(), 1));
+ assert(m.size() == 1);
+ assert(i == m.end());
+ assert(next(m.begin(), 0)->first == 2);
+ assert(next(m.begin(), 0)->second == 1.5);
+
+ i = m.erase(m.cbegin());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp
new file mode 100644
index 00000000000..4d378949311
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp
@@ -0,0 +1,157 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> M;
+ typedef std::pair<int, double> P;
+ typedef M::iterator I;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(m.cbegin(), m.cbegin());
+ assert(m.size() == 8);
+ assert(i == m.begin());
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 4);
+ assert(next(m.begin(), 3)->second == 4.5);
+ assert(next(m.begin(), 4)->first == 5);
+ assert(next(m.begin(), 4)->second == 5.5);
+ assert(next(m.begin(), 5)->first == 6);
+ assert(next(m.begin(), 5)->second == 6.5);
+ assert(next(m.begin(), 6)->first == 7);
+ assert(next(m.begin(), 6)->second == 7.5);
+ assert(next(m.begin(), 7)->first == 8);
+ assert(next(m.begin(), 7)->second == 8.5);
+
+ i = m.erase(m.cbegin(), next(m.cbegin(), 2));
+ assert(m.size() == 6);
+ assert(i == m.begin());
+ assert(next(m.begin(), 0)->first == 3);
+ assert(next(m.begin(), 0)->second == 3.5);
+ assert(next(m.begin(), 1)->first == 4);
+ assert(next(m.begin(), 1)->second == 4.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+ assert(next(m.begin(), 5)->first == 8);
+ assert(next(m.begin(), 5)->second == 8.5);
+
+ i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 6));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 2));
+ assert(next(m.begin(), 0)->first == 3);
+ assert(next(m.begin(), 0)->second == 3.5);
+ assert(next(m.begin(), 1)->first == 4);
+ assert(next(m.begin(), 1)->second == 4.5);
+
+ i = m.erase(m.cbegin(), m.cend());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ typedef M::iterator I;
+ P ar[] =
+ {
+ P(1, 1.5),
+ P(2, 2.5),
+ P(3, 3.5),
+ P(4, 4.5),
+ P(5, 5.5),
+ P(6, 6.5),
+ P(7, 7.5),
+ P(8, 8.5),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(m.cbegin(), m.cbegin());
+ assert(m.size() == 8);
+ assert(i == m.begin());
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1.5);
+ assert(next(m.begin())->first == 2);
+ assert(next(m.begin())->second == 2.5);
+ assert(next(m.begin(), 2)->first == 3);
+ assert(next(m.begin(), 2)->second == 3.5);
+ assert(next(m.begin(), 3)->first == 4);
+ assert(next(m.begin(), 3)->second == 4.5);
+ assert(next(m.begin(), 4)->first == 5);
+ assert(next(m.begin(), 4)->second == 5.5);
+ assert(next(m.begin(), 5)->first == 6);
+ assert(next(m.begin(), 5)->second == 6.5);
+ assert(next(m.begin(), 6)->first == 7);
+ assert(next(m.begin(), 6)->second == 7.5);
+ assert(next(m.begin(), 7)->first == 8);
+ assert(next(m.begin(), 7)->second == 8.5);
+
+ i = m.erase(m.cbegin(), next(m.cbegin(), 2));
+ assert(m.size() == 6);
+ assert(i == m.begin());
+ assert(next(m.begin(), 0)->first == 3);
+ assert(next(m.begin(), 0)->second == 3.5);
+ assert(next(m.begin(), 1)->first == 4);
+ assert(next(m.begin(), 1)->second == 4.5);
+ assert(next(m.begin(), 2)->first == 5);
+ assert(next(m.begin(), 2)->second == 5.5);
+ assert(next(m.begin(), 3)->first == 6);
+ assert(next(m.begin(), 3)->second == 6.5);
+ assert(next(m.begin(), 4)->first == 7);
+ assert(next(m.begin(), 4)->second == 7.5);
+ assert(next(m.begin(), 5)->first == 8);
+ assert(next(m.begin(), 5)->second == 8.5);
+
+ i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 6));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 2));
+ assert(next(m.begin(), 0)->first == 3);
+ assert(next(m.begin(), 0)->second == 3.5);
+ assert(next(m.begin(), 1)->first == 4);
+ assert(next(m.begin(), 1)->second == 4.5);
+
+ i = m.erase(m.cbegin(), m.cend());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp
new file mode 100644
index 00000000000..33821d3e359
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp
@@ -0,0 +1,153 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// size_type erase(const key_type& k);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> M;
+ typedef std::pair<int, double> P;
+ typedef M::size_type I;
+ P ar[] =
+ {
+ P(1, 1),
+ P(1, 1.5),
+ P(1, 2),
+ P(2, 1),
+ P(2, 1.5),
+ P(2, 2),
+ P(3, 1),
+ P(3, 1.5),
+ P(3, 2),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 9);
+ I i = m.erase(2);
+ assert(m.size() == 6);
+ assert(i == 3);
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1);
+ assert(next(m.begin(), 1)->first == 1);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == 2);
+ assert(next(m.begin(), 3)->first == 3);
+ assert(next(m.begin(), 3)->second == 1);
+ assert(next(m.begin(), 4)->first == 3);
+ assert(next(m.begin(), 4)->second == 1.5);
+ assert(next(m.begin(), 5)->first == 3);
+ assert(next(m.begin(), 5)->second == 2);
+
+ i = m.erase(2);
+ assert(m.size() == 6);
+ assert(i == 0);
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1);
+ assert(next(m.begin(), 1)->first == 1);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == 2);
+ assert(next(m.begin(), 3)->first == 3);
+ assert(next(m.begin(), 3)->second == 1);
+ assert(next(m.begin(), 4)->first == 3);
+ assert(next(m.begin(), 4)->second == 1.5);
+ assert(next(m.begin(), 5)->first == 3);
+ assert(next(m.begin(), 5)->second == 2);
+
+ i = m.erase(3);
+ assert(i == 3);
+ assert(m.size() == 3);
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1);
+ assert(next(m.begin(), 1)->first == 1);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == 2);
+
+ i = m.erase(1);
+ assert(m.size() == 0);
+ assert(i == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ typedef M::size_type I;
+ P ar[] =
+ {
+ P(1, 1),
+ P(1, 1.5),
+ P(1, 2),
+ P(2, 1),
+ P(2, 1.5),
+ P(2, 2),
+ P(3, 1),
+ P(3, 1.5),
+ P(3, 2),
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 9);
+ I i = m.erase(2);
+ assert(m.size() == 6);
+ assert(i == 3);
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1);
+ assert(next(m.begin(), 1)->first == 1);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == 2);
+ assert(next(m.begin(), 3)->first == 3);
+ assert(next(m.begin(), 3)->second == 1);
+ assert(next(m.begin(), 4)->first == 3);
+ assert(next(m.begin(), 4)->second == 1.5);
+ assert(next(m.begin(), 5)->first == 3);
+ assert(next(m.begin(), 5)->second == 2);
+
+ i = m.erase(2);
+ assert(m.size() == 6);
+ assert(i == 0);
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1);
+ assert(next(m.begin(), 1)->first == 1);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == 2);
+ assert(next(m.begin(), 3)->first == 3);
+ assert(next(m.begin(), 3)->second == 1);
+ assert(next(m.begin(), 4)->first == 3);
+ assert(next(m.begin(), 4)->second == 1.5);
+ assert(next(m.begin(), 5)->first == 3);
+ assert(next(m.begin(), 5)->second == 2);
+
+ i = m.erase(3);
+ assert(i == 3);
+ assert(m.size() == 3);
+ assert(next(m.begin(), 0)->first == 1);
+ assert(next(m.begin(), 0)->second == 1);
+ assert(next(m.begin(), 1)->first == 1);
+ assert(next(m.begin(), 1)->second == 1.5);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == 2);
+
+ i = m.erase(1);
+ assert(m.size() == 0);
+ assert(i == 3);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp
new file mode 100644
index 00000000000..d9afc9d0fdf
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator insert(const value_type& v);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(M::value_type(2, 2.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2.5);
+
+ r = m.insert(M::value_type(1, 1.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1.5);
+
+ r = m.insert(M::value_type(3, 3.5));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+
+ r = m.insert(M::value_type(3, 3.5));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(M::value_type(2, 2.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2.5);
+
+ r = m.insert(M::value_type(1, 1.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1.5);
+
+ r = m.insert(M::value_type(3, 3.5));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+
+ r = m.insert(M::value_type(3, 3.5));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp
new file mode 100644
index 00000000000..5e1a1d4125e
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp
@@ -0,0 +1,91 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// void insert(initializer_list<value_type> il);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::multimap<int, double> C;
+ typedef C::value_type V;
+ C m =
+ {
+ {1, 1},
+ {1, 2},
+ {2, 1},
+ {2, 2},
+ {3, 1},
+ {3, 2}
+ };
+ m.insert(
+ {
+ {1, 1.5},
+ {2, 1.5},
+ {3, 1.5},
+ }
+ );
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1, 1));
+ assert(*++i == V(1, 2));
+ assert(*++i == V(1, 1.5));
+ assert(*++i == V(2, 1));
+ assert(*++i == V(2, 2));
+ assert(*++i == V(2, 1.5));
+ assert(*++i == V(3, 1));
+ assert(*++i == V(3, 2));
+ assert(*++i == V(3, 1.5));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C;
+ typedef C::value_type V;
+ C m =
+ {
+ {1, 1},
+ {1, 2},
+ {2, 1},
+ {2, 2},
+ {3, 1},
+ {3, 2}
+ };
+ m.insert(
+ {
+ {1, 1.5},
+ {2, 1.5},
+ {3, 1.5},
+ }
+ );
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1, 1));
+ assert(*++i == V(1, 2));
+ assert(*++i == V(1, 1.5));
+ assert(*++i == V(2, 1));
+ assert(*++i == V(2, 2));
+ assert(*++i == V(2, 1.5));
+ assert(*++i == V(3, 1));
+ assert(*++i == V(3, 2));
+ assert(*++i == V(3, 1.5));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp
new file mode 100644
index 00000000000..b83c802c04c
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator insert(const_iterator position, const value_type& v);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.end(), M::value_type(2, 2.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2.5);
+
+ r = m.insert(m.end(), M::value_type(1, 1.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1.5);
+
+ r = m.insert(m.end(), M::value_type(3, 3.5));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+
+ r = m.insert(prev(m.end()), M::value_type(3, 4.5));
+ assert(r == prev(m.end(), 2));
+ assert(m.size() == 4);
+ assert(r->first == 3);
+ assert(r->second == 4.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.end(), M::value_type(2, 2.5));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2.5);
+
+ r = m.insert(m.end(), M::value_type(1, 1.5));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1.5);
+
+ r = m.insert(m.end(), M::value_type(3, 3.5));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3.5);
+
+ r = m.insert(prev(m.end()), M::value_type(3, 4.5));
+ assert(r == prev(m.end(), 2));
+ assert(m.size() == 4);
+ assert(r->first == 3);
+ assert(r->second == 4.5);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp
new file mode 100644
index 00000000000..70ff7ef6d6b
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp
@@ -0,0 +1,101 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class InputIterator>
+// void insert(InputIterator first, InputIterator last);
+
+#include <map>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> M;
+ typedef std::pair<int, double> P;
+ P ar[] =
+ {
+ P(1, 1),
+ P(1, 1.5),
+ P(1, 2),
+ P(2, 1),
+ P(2, 1.5),
+ P(2, 2),
+ P(3, 1),
+ P(3, 1.5),
+ P(3, 2),
+ };
+ M m;
+ m.insert(input_iterator<P*>(ar), input_iterator<P*>(ar + sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 9);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == 1.5);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == 2);
+ assert(next(m.begin(), 3)->first == 2);
+ assert(next(m.begin(), 3)->second == 1);
+ assert(next(m.begin(), 4)->first == 2);
+ assert(next(m.begin(), 4)->second == 1.5);
+ assert(next(m.begin(), 5)->first == 2);
+ assert(next(m.begin(), 5)->second == 2);
+ assert(next(m.begin(), 6)->first == 3);
+ assert(next(m.begin(), 6)->second == 1);
+ assert(next(m.begin(), 7)->first == 3);
+ assert(next(m.begin(), 7)->second == 1.5);
+ assert(next(m.begin(), 8)->first == 3);
+ assert(next(m.begin(), 8)->second == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ typedef std::pair<int, double> P;
+ P ar[] =
+ {
+ P(1, 1),
+ P(1, 1.5),
+ P(1, 2),
+ P(2, 1),
+ P(2, 1.5),
+ P(2, 2),
+ P(3, 1),
+ P(3, 1.5),
+ P(3, 2),
+ };
+ M m;
+ m.insert(input_iterator<P*>(ar), input_iterator<P*>(ar + sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 9);
+ assert(m.begin()->first == 1);
+ assert(m.begin()->second == 1);
+ assert(next(m.begin())->first == 1);
+ assert(next(m.begin())->second == 1.5);
+ assert(next(m.begin(), 2)->first == 1);
+ assert(next(m.begin(), 2)->second == 2);
+ assert(next(m.begin(), 3)->first == 2);
+ assert(next(m.begin(), 3)->second == 1);
+ assert(next(m.begin(), 4)->first == 2);
+ assert(next(m.begin(), 4)->second == 1.5);
+ assert(next(m.begin(), 5)->first == 2);
+ assert(next(m.begin(), 5)->second == 2);
+ assert(next(m.begin(), 6)->first == 3);
+ assert(next(m.begin(), 6)->second == 1);
+ assert(next(m.begin(), 7)->first == 3);
+ assert(next(m.begin(), 7)->second == 1.5);
+ assert(next(m.begin(), 8)->first == 3);
+ assert(next(m.begin(), 8)->second == 2);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp
new file mode 100644
index 00000000000..60ca7d4a5b4
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp
@@ -0,0 +1,87 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class P>
+// iterator insert(const_iterator position, P&& p);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::multimap<int, MoveOnly> M;
+ typedef std::pair<int, MoveOnly> P;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.cend(), P(2, 2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2);
+
+ r = m.insert(m.cend(), P(1, 1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1);
+
+ r = m.insert(m.cend(), P(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = m.insert(m.cend(), P(3, 2));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(r->first == 3);
+ assert(r->second == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M;
+ typedef std::pair<int, MoveOnly> P;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.cend(), P(2, 2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2);
+
+ r = m.insert(m.cend(), P(1, 1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1);
+
+ r = m.insert(m.cend(), P(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = m.insert(m.cend(), P(3, 2));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(r->first == 3);
+ assert(r->second == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp
new file mode 100644
index 00000000000..2f198f8f7c2
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class P>
+// iterator insert(P&& p);
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::multimap<int, MoveOnly> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(M::value_type(2, 2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2);
+
+ r = m.insert(M::value_type(1, 1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1);
+
+ r = m.insert(M::value_type(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = m.insert(M::value_type(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(r->first == 3);
+ assert(r->second == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(M::value_type(2, 2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(r->first == 2);
+ assert(r->second == 2);
+
+ r = m.insert(M::value_type(1, 1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(r->first == 1);
+ assert(r->second == 1);
+
+ r = m.insert(M::value_type(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = m.insert(M::value_type(3, 3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(r->first == 3);
+ assert(r->second == 3);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.ops/count.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.ops/count.pass.cpp
new file mode 100644
index 00000000000..2f172d11d67
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.ops/count.pass.cpp
@@ -0,0 +1,159 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// size_type count(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ typedef std::pair<const int, double> V;
+ {
+ typedef std::multimap<int, double> M;
+ {
+ typedef M::size_type R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(4);
+ assert(r == 0);
+ r = m.count(5);
+ assert(r == 3);
+ r = m.count(6);
+ assert(r == 0);
+ r = m.count(7);
+ assert(r == 3);
+ r = m.count(8);
+ assert(r == 0);
+ r = m.count(9);
+ assert(r == 3);
+ r = m.count(10);
+ assert(r == 0);
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ {
+ typedef M::size_type R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(4);
+ assert(r == 0);
+ r = m.count(5);
+ assert(r == 3);
+ r = m.count(6);
+ assert(r == 0);
+ r = m.count(7);
+ assert(r == 3);
+ r = m.count(8);
+ assert(r == 0);
+ r = m.count(9);
+ assert(r == 3);
+ r = m.count(10);
+ assert(r == 0);
+ }
+ }
+#endif
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::multimap<int, double, std::less<>> M;
+ typedef M::size_type R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(4);
+ assert(r == 0);
+ r = m.count(5);
+ assert(r == 3);
+ r = m.count(6);
+ assert(r == 0);
+ r = m.count(7);
+ assert(r == 3);
+ r = m.count(8);
+ assert(r == 0);
+ r = m.count(9);
+ assert(r == 3);
+ r = m.count(10);
+ assert(r == 0);
+ }
+
+ {
+ typedef PrivateConstructor PC;
+ typedef std::multimap<PC, double, std::less<>> M;
+ typedef M::size_type R;
+
+ M m;
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 3 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 3 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 3 ));
+
+ R r = m.count(4);
+ assert(r == 0);
+ r = m.count(5);
+ assert(r == 3);
+ r = m.count(6);
+ assert(r == 0);
+ r = m.count(7);
+ assert(r == 3);
+ r = m.count(8);
+ assert(r == 0);
+ r = m.count(9);
+ assert(r == 3);
+ r = m.count(10);
+ assert(r == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp
new file mode 100644
index 00000000000..a408796d1fb
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp
@@ -0,0 +1,264 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// pair<iterator, iterator> equal_range(const key_type& k);
+// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ typedef std::pair<const int, double> V;
+ {
+ typedef std::multimap<int, double> M;
+ {
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(4);
+ assert(r.first == m.begin());
+ assert(r.second == m.begin());
+ r = m.equal_range(5);
+ assert(r.first == m.begin());
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == m.end());
+ assert(r.second == m.end());
+ }
+ {
+ typedef std::pair<M::const_iterator, M::const_iterator> R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(4);
+ assert(r.first == m.begin());
+ assert(r.second == m.begin());
+ r = m.equal_range(5);
+ assert(r.first == m.begin());
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == m.end());
+ assert(r.second == m.end());
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ {
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(4);
+ assert(r.first == m.begin());
+ assert(r.second == m.begin());
+ r = m.equal_range(5);
+ assert(r.first == m.begin());
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == m.end());
+ assert(r.second == m.end());
+ }
+ {
+ typedef std::pair<M::const_iterator, M::const_iterator> R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(4);
+ assert(r.first == m.begin());
+ assert(r.second == m.begin());
+ r = m.equal_range(5);
+ assert(r.first == m.begin());
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == m.end());
+ assert(r.second == m.end());
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::multimap<int, double, std::less<>> M;
+
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(4);
+ assert(r.first == m.begin());
+ assert(r.second == m.begin());
+ r = m.equal_range(5);
+ assert(r.first == m.begin());
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == m.end());
+ assert(r.second == m.end());
+ }
+
+ {
+ typedef PrivateConstructor PC;
+ typedef std::multimap<PC, double, std::less<>> M;
+ typedef std::pair<M::iterator, M::iterator> R;
+
+ M m;
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 3 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 3 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 3 ));
+
+// assert(m.size() == 9);
+ R r = m.equal_range(4);
+ assert(r.first == m.begin());
+ assert(r.second == m.begin());
+ r = m.equal_range(5);
+ assert(r.first == m.begin());
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == m.end());
+ assert(r.second == m.end());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.ops/find.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.ops/find.pass.cpp
new file mode 100644
index 00000000000..fb5afa241ca
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.ops/find.pass.cpp
@@ -0,0 +1,209 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ typedef std::pair<const int, double> V;
+ {
+ typedef std::multimap<int, double> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == m.end());
+ r = m.find(7);
+ assert(r == next(m.begin(), 3));
+ r = m.find(8);
+ assert(r == m.end());
+ r = m.find(9);
+ assert(r == next(m.begin(), 6));
+ r = m.find(10);
+ assert(r == m.end());
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == m.end());
+ r = m.find(7);
+ assert(r == next(m.begin(), 3));
+ r = m.find(8);
+ assert(r == m.end());
+ r = m.find(9);
+ assert(r == next(m.begin(), 6));
+ r = m.find(10);
+ assert(r == m.end());
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == m.end());
+ r = m.find(7);
+ assert(r == next(m.begin(), 3));
+ r = m.find(8);
+ assert(r == m.end());
+ r = m.find(9);
+ assert(r == next(m.begin(), 6));
+ r = m.find(10);
+ assert(r == m.end());
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == m.end());
+ r = m.find(7);
+ assert(r == next(m.begin(), 3));
+ r = m.find(8);
+ assert(r == m.end());
+ r = m.find(9);
+ assert(r == next(m.begin(), 6));
+ r = m.find(10);
+ assert(r == m.end());
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::multimap<int, double, std::less<>> M;
+ typedef M::iterator R;
+
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == m.end());
+ r = m.find(7);
+ assert(r == next(m.begin(), 3));
+ r = m.find(8);
+ assert(r == m.end());
+ r = m.find(9);
+ assert(r == next(m.begin(), 6));
+ r = m.find(10);
+ assert(r == m.end());
+ }
+
+ {
+ typedef PrivateConstructor PC;
+ typedef std::multimap<PC, double, std::less<>> M;
+ typedef M::iterator R;
+
+ M m;
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 3 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 3 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 3 ));
+
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == m.end());
+ r = m.find(7);
+ assert(r == next(m.begin(), 3));
+ r = m.find(8);
+ assert(r == m.end());
+ r = m.find(9);
+ assert(r == next(m.begin(), 6));
+ r = m.find(10);
+ assert(r == m.end());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp
new file mode 100644
index 00000000000..49cf6de853c
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp
@@ -0,0 +1,221 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ typedef std::pair<const int, double> V;
+ {
+ typedef std::multimap<int, double> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(4);
+ assert(r == m.begin());
+ r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(10);
+ assert(r == m.end());
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(4);
+ assert(r == m.begin());
+ r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(10);
+ assert(r == m.end());
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(4);
+ assert(r == m.begin());
+ r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(10);
+ assert(r == m.end());
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(4);
+ assert(r == m.begin());
+ r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(10);
+ assert(r == m.end());
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::multimap<int, double, std::less<>> M;
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(4);
+ assert(r == m.begin());
+ r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(10);
+ assert(r == m.end());
+ }
+
+ {
+ typedef PrivateConstructor PC;
+ typedef std::multimap<PC, double, std::less<>> M;
+ typedef M::iterator R;
+
+ M m;
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 3 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 3 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 3 ));
+
+ R r = m.lower_bound(4);
+ assert(r == m.begin());
+ r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(10);
+ assert(r == m.end());
+ }
+
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp
new file mode 100644
index 00000000000..1920647705f
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp
@@ -0,0 +1,221 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ typedef std::pair<const int, double> V;
+ {
+ typedef std::multimap<int, double> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(4);
+ assert(r == m.begin());
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(10);
+ assert(r == m.end());
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(4);
+ assert(r == m.begin());
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(10);
+ assert(r == m.end());
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(4);
+ assert(r == m.begin());
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(10);
+ assert(r == m.end());
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(4);
+ assert(r == m.begin());
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(10);
+ assert(r == m.end());
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<const int, double> V;
+ typedef std::multimap<int, double, std::less<>> M;
+ typedef M::iterator R;
+ V ar[] =
+ {
+ V(5, 1),
+ V(5, 2),
+ V(5, 3),
+ V(7, 1),
+ V(7, 2),
+ V(7, 3),
+ V(9, 1),
+ V(9, 2),
+ V(9, 3)
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(4);
+ assert(r == m.begin());
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(10);
+ assert(r == m.end());
+ }
+
+ {
+ typedef PrivateConstructor PC;
+ typedef std::multimap<PC, double, std::less<>> M;
+ typedef M::iterator R;
+
+ M m;
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(5), 3 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(7), 3 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 1 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 2 ));
+ m.insert ( std::make_pair<PC, double> ( PC::make(9), 3 ));
+
+ R r = m.upper_bound(4);
+ assert(r == m.begin());
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(10);
+ assert(r == m.end());
+ }
+
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.special/member_swap.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.special/member_swap.pass.cpp
new file mode 100644
index 00000000000..c8f30aa7c71
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.special/member_swap.pass.cpp
@@ -0,0 +1,200 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// void swap(multimap& m);
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ typedef std::pair<const int, double> V;
+ {
+ typedef std::multimap<int, double> M;
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp
new file mode 100644
index 00000000000..effec2be092
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp
@@ -0,0 +1,305 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// template <class Key, class T, class Compare, class Allocator>
+// void
+// swap(multimap<Key, T, Compare, Allocator>& x, multimap<Key, T, Compare, Allocator>& y);
+
+#include <map>
+#include <cassert>
+#include "test_allocator.h"
+#include "../../../test_compare.h"
+#include "min_allocator.h"
+
+int main()
+{
+ typedef std::pair<const int, double> V;
+ {
+ typedef std::multimap<int, double> M;
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ typedef test_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::multimap<int, double, C, A> M;
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ assert(m1.key_comp() == C(2));
+ assert(m1.get_allocator() == A(1));
+ assert(m2.key_comp() == C(1));
+ assert(m2.get_allocator() == A(2));
+ }
+ {
+ typedef other_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::multimap<int, double, C, A> M;
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ assert(m1.key_comp() == C(2));
+ assert(m1.get_allocator() == A(2));
+ assert(m2.key_comp() == C(1));
+ assert(m2.get_allocator() == A(1));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ typedef min_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::multimap<int, double, C, A> M;
+ V ar1[] =
+ {
+ V(1, 1),
+ V(2, 2),
+ V(3, 3),
+ V(4, 4)
+ };
+ V ar2[] =
+ {
+ V(5, 5),
+ V(6, 6),
+ V(7, 7),
+ V(8, 8),
+ V(9, 9),
+ V(10, 10),
+ V(11, 11),
+ V(12, 12)
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A());
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A());
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ assert(m1.key_comp() == C(2));
+ assert(m1.get_allocator() == A());
+ assert(m2.key_comp() == C(1));
+ assert(m2.get_allocator() == A());
+ }
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp
new file mode 100644
index 00000000000..687c44385da
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/multimap.special/swap_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// void swap(multimap& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+
+ some_comp() {}
+ some_comp(const some_comp&) {}
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::multimap<MoveOnly, MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/scary.pass.cpp b/libcxx/test/std/containers/associative/multimap/scary.pass.cpp
new file mode 100644
index 00000000000..b99d9bc2df9
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/scary.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class map class multimap
+
+// Extension: SCARY/N2913 iterator compatibility between map and multimap
+
+#include <map>
+
+int main()
+{
+ typedef std::map<int, int> M1;
+ typedef std::multimap<int, int> M2;
+ M2::iterator i;
+ M1::iterator j = i;
+}
diff --git a/libcxx/test/std/containers/associative/multimap/size.pass.cpp b/libcxx/test/std/containers/associative/multimap/size.pass.cpp
new file mode 100644
index 00000000000..ac71d4c95b6
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// class multimap
+
+// size_type size() const;
+
+#include <map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> M;
+ M m;
+ assert(m.size() == 0);
+ m.insert(M::value_type(2, 1.5));
+ assert(m.size() == 1);
+ m.insert(M::value_type(1, 1.5));
+ assert(m.size() == 2);
+ m.insert(M::value_type(3, 1.5));
+ assert(m.size() == 3);
+ m.erase(m.begin());
+ assert(m.size() == 2);
+ m.erase(m.begin());
+ assert(m.size() == 1);
+ m.erase(m.begin());
+ assert(m.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M;
+ M m;
+ assert(m.size() == 0);
+ m.insert(M::value_type(2, 1.5));
+ assert(m.size() == 1);
+ m.insert(M::value_type(1, 1.5));
+ assert(m.size() == 2);
+ m.insert(M::value_type(3, 1.5));
+ assert(m.size() == 3);
+ m.erase(m.begin());
+ assert(m.size() == 2);
+ m.erase(m.begin());
+ assert(m.size() == 1);
+ m.erase(m.begin());
+ assert(m.size() == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multimap/types.pass.cpp b/libcxx/test/std/containers/associative/multimap/types.pass.cpp
new file mode 100644
index 00000000000..a0f4db056a8
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multimap/types.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <map>
+
+// template <class Key, class T, class Compare = less<Key>,
+// class Allocator = allocator<pair<const Key, T>>>
+// class multimap
+// {
+// public:
+// // types:
+// typedef Key key_type;
+// typedef T mapped_type;
+// typedef pair<const key_type, mapped_type> value_type;
+// typedef Compare key_compare;
+// typedef Allocator allocator_type;
+// typedef typename allocator_type::reference reference;
+// typedef typename allocator_type::const_reference const_reference;
+// typedef typename allocator_type::pointer pointer;
+// typedef typename allocator_type::const_pointer const_pointer;
+// typedef typename allocator_type::size_type size_type;
+// typedef typename allocator_type::difference_type difference_type;
+// ...
+// };
+
+#include <map>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multimap<int, double> C;
+ static_assert((std::is_same<C::key_type, int>::value), "");
+ static_assert((std::is_same<C::mapped_type, double>::value), "");
+ static_assert((std::is_same<C::value_type, std::pair<const int, double> >::value), "");
+ static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::allocator_type, std::allocator<std::pair<const int, double> > >::value), "");
+ static_assert((std::is_same<C::reference, std::pair<const int, double>&>::value), "");
+ static_assert((std::is_same<C::const_reference, const std::pair<const int, double>&>::value), "");
+ static_assert((std::is_same<C::pointer, std::pair<const int, double>*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const std::pair<const int, double>*>::value), "");
+ static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C;
+ static_assert((std::is_same<C::key_type, int>::value), "");
+ static_assert((std::is_same<C::mapped_type, double>::value), "");
+ static_assert((std::is_same<C::value_type, std::pair<const int, double> >::value), "");
+ static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<std::pair<const int, double> > >::value), "");
+ static_assert((std::is_same<C::reference, std::pair<const int, double>&>::value), "");
+ static_assert((std::is_same<C::const_reference, const std::pair<const int, double>&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<std::pair<const int, double>>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const std::pair<const int, double>>>::value), "");
+// min_allocator doesn't have a size_type, so one gets synthesized
+ static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/clear.pass.cpp b/libcxx/test/std/containers/associative/multiset/clear.pass.cpp
new file mode 100644
index 00000000000..3069de5a300
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/clear.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// void clear();
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multiset<int> M;
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ m.clear();
+ assert(m.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ m.clear();
+ assert(m.size() == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/count.pass.cpp b/libcxx/test/std/containers/associative/multiset/count.pass.cpp
new file mode 100644
index 00000000000..93bd6f80eaa
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/count.pass.cpp
@@ -0,0 +1,160 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// size_type count(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::multiset<int> M;
+ {
+ typedef M::size_type R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(4);
+ assert(r == 0);
+ r = m.count(5);
+ assert(r == 4);
+ r = m.count(6);
+ assert(r == 0);
+ r = m.count(7);
+ assert(r == 3);
+ r = m.count(8);
+ assert(r == 0);
+ r = m.count(9);
+ assert(r == 2);
+ r = m.count(10);
+ assert(r == 0);
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ {
+ typedef M::size_type R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(4);
+ assert(r == 0);
+ r = m.count(5);
+ assert(r == 4);
+ r = m.count(6);
+ assert(r == 0);
+ r = m.count(7);
+ assert(r == 3);
+ r = m.count(8);
+ assert(r == 0);
+ r = m.count(9);
+ assert(r == 2);
+ r = m.count(10);
+ assert(r == 0);
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ typedef std::multiset<int, std::less<>> M;
+ typedef M::size_type R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(4);
+ assert(r == 0);
+ r = m.count(5);
+ assert(r == 4);
+ r = m.count(6);
+ assert(r == 0);
+ r = m.count(7);
+ assert(r == 3);
+ r = m.count(8);
+ assert(r == 0);
+ r = m.count(9);
+ assert(r == 2);
+ r = m.count(10);
+ assert(r == 0);
+ }
+
+ {
+ typedef PrivateConstructor V;
+ typedef std::multiset<V, std::less<>> M;
+ typedef M::size_type R;
+
+ M m;
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 9 ));
+
+ R r = m.count(4);
+ assert(r == 0);
+ r = m.count(5);
+ assert(r == 4);
+ r = m.count(6);
+ assert(r == 0);
+ r = m.count(7);
+ assert(r == 3);
+ r = m.count(8);
+ assert(r == 0);
+ r = m.count(9);
+ assert(r == 2);
+ r = m.count(10);
+ assert(r == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/emplace.pass.cpp b/libcxx/test/std/containers/associative/multiset/emplace.pass.cpp
new file mode 100644
index 00000000000..450ee6cd35a
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/emplace.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class... Args>
+// iterator emplace(Args&&... args);
+
+#include <set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::multiset<DefaultOnly> M;
+ typedef M::iterator R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace();
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*m.begin() == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+
+ r = m.emplace();
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(*m.begin() == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::multiset<Emplaceable> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace();
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*m.begin() == Emplaceable());
+ r = m.emplace(2, 3.5);
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(*r == Emplaceable(2, 3.5));
+ r = m.emplace(2, 3.5);
+ assert(r == next(m.begin(), 2));
+ assert(m.size() == 3);
+ assert(*r == Emplaceable(2, 3.5));
+ }
+ {
+ typedef std::multiset<int> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace(M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace(M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/multiset/emplace_hint.pass.cpp b/libcxx/test/std/containers/associative/multiset/emplace_hint.pass.cpp
new file mode 100644
index 00000000000..194adf761c4
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/emplace_hint.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class... Args>
+// iterator emplace_hint(const_iterator position, Args&&... args);
+
+#include <set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::multiset<DefaultOnly> M;
+ typedef M::iterator R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace_hint(m.cend());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*m.begin() == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+
+ r = m.emplace_hint(m.cbegin());
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*m.begin() == DefaultOnly());
+ assert(DefaultOnly::count == 2);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::multiset<Emplaceable> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.cend());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*m.begin() == Emplaceable());
+ r = m.emplace_hint(m.cend(), 2, 3.5);
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(*r == Emplaceable(2, 3.5));
+ r = m.emplace_hint(m.cbegin(), 2, 3.5);
+ assert(r == next(m.begin()));
+ assert(m.size() == 3);
+ assert(*r == Emplaceable(2, 3.5));
+ }
+ {
+ typedef std::multiset<int> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/multiset/empty.pass.cpp b/libcxx/test/std/containers/associative/multiset/empty.pass.cpp
new file mode 100644
index 00000000000..32aef90d418
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/empty.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// bool empty() const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multiset<int> M;
+ M m;
+ assert(m.empty());
+ m.insert(M::value_type(1));
+ assert(!m.empty());
+ m.clear();
+ assert(m.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ M m;
+ assert(m.empty());
+ m.insert(M::value_type(1));
+ assert(!m.empty());
+ m.clear();
+ assert(m.empty());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/equal_range.pass.cpp b/libcxx/test/std/containers/associative/multiset/equal_range.pass.cpp
new file mode 100644
index 00000000000..8c69d0c61ec
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/equal_range.pass.cpp
@@ -0,0 +1,263 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// pair<iterator,iterator> equal_range(const key_type& k);
+// pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::multiset<int> M;
+ {
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 9));
+ assert(r.second == next(m.begin(), 9));
+ }
+ {
+ typedef std::pair<M::const_iterator, M::const_iterator> R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 9));
+ assert(r.second == next(m.begin(), 9));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ {
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 9));
+ assert(r.second == next(m.begin(), 9));
+ }
+ {
+ typedef std::pair<M::const_iterator, M::const_iterator> R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 9));
+ assert(r.second == next(m.begin(), 9));
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ typedef std::multiset<V, std::less<>> M;
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 9));
+ assert(r.second == next(m.begin(), 9));
+ }
+
+ {
+ typedef PrivateConstructor V;
+ typedef std::multiset<V, std::less<>> M;
+ typedef std::pair<M::iterator, M::iterator> R;
+
+ M m;
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 9 ));
+
+ R r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 9));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 9));
+ assert(r.second == next(m.begin(), 9));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/erase_iter.pass.cpp b/libcxx/test/std/containers/associative/multiset/erase_iter.pass.cpp
new file mode 100644
index 00000000000..b6656668d40
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/erase_iter.pass.cpp
@@ -0,0 +1,181 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator erase(const_iterator position);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multiset<int> M;
+ typedef int V;
+ typedef M::iterator I;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(next(m.cbegin(), 3));
+ assert(m.size() == 7);
+ assert(i == next(m.begin(), 3));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 6);
+ assert(*next(m.begin(), 5) == 7);
+ assert(*next(m.begin(), 6) == 8);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 6);
+ assert(i == m.begin());
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+ assert(*next(m.begin(), 5) == 8);
+
+ i = m.erase(next(m.cbegin(), 5));
+ assert(m.size() == 5);
+ assert(i == m.end());
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+
+ i = m.erase(next(m.cbegin(), 1));
+ assert(m.size() == 4);
+ assert(i == next(m.begin()));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 6);
+ assert(*next(m.begin(), 3) == 7);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 3);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 7);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 1);
+ assert(i == next(m.begin(), 0));
+ assert(*next(m.begin(), 0) == 5);
+
+ i = m.erase(m.cbegin());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ typedef int V;
+ typedef M::iterator I;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(next(m.cbegin(), 3));
+ assert(m.size() == 7);
+ assert(i == next(m.begin(), 3));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 6);
+ assert(*next(m.begin(), 5) == 7);
+ assert(*next(m.begin(), 6) == 8);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 6);
+ assert(i == m.begin());
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+ assert(*next(m.begin(), 5) == 8);
+
+ i = m.erase(next(m.cbegin(), 5));
+ assert(m.size() == 5);
+ assert(i == m.end());
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+
+ i = m.erase(next(m.cbegin(), 1));
+ assert(m.size() == 4);
+ assert(i == next(m.begin()));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 6);
+ assert(*next(m.begin(), 3) == 7);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 3);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 7);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 1);
+ assert(i == next(m.begin(), 0));
+ assert(*next(m.begin(), 0) == 5);
+
+ i = m.erase(m.cbegin());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/erase_iter_iter.pass.cpp b/libcxx/test/std/containers/associative/multiset/erase_iter_iter.pass.cpp
new file mode 100644
index 00000000000..e1d7090d816
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/erase_iter_iter.pass.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multiset<int> M;
+ typedef int V;
+ typedef M::iterator I;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(next(m.cbegin(), 5), next(m.cbegin(), 5));
+ assert(m.size() == 8);
+ assert(i == next(m.begin(), 5));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 4);
+ assert(*next(m.begin(), 4) == 5);
+ assert(*next(m.begin(), 5) == 6);
+ assert(*next(m.begin(), 6) == 7);
+ assert(*next(m.begin(), 7) == 8);
+
+ i = m.erase(next(m.cbegin(), 3), next(m.cbegin(), 4));
+ assert(m.size() == 7);
+ assert(i == next(m.begin(), 3));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 6);
+ assert(*next(m.begin(), 5) == 7);
+ assert(*next(m.begin(), 6) == 8);
+
+ i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 5));
+ assert(m.size() == 4);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 7);
+ assert(*next(m.begin(), 3) == 8);
+
+ i = m.erase(next(m.cbegin(), 0), next(m.cbegin(), 2));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 0));
+ assert(*next(m.begin(), 0) == 7);
+ assert(*next(m.begin(), 1) == 8);
+
+ i = m.erase(m.cbegin(), m.cend());
+ assert(m.size() == 0);
+ assert(i == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ typedef int V;
+ typedef M::iterator I;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(next(m.cbegin(), 5), next(m.cbegin(), 5));
+ assert(m.size() == 8);
+ assert(i == next(m.begin(), 5));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 4);
+ assert(*next(m.begin(), 4) == 5);
+ assert(*next(m.begin(), 5) == 6);
+ assert(*next(m.begin(), 6) == 7);
+ assert(*next(m.begin(), 7) == 8);
+
+ i = m.erase(next(m.cbegin(), 3), next(m.cbegin(), 4));
+ assert(m.size() == 7);
+ assert(i == next(m.begin(), 3));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 6);
+ assert(*next(m.begin(), 5) == 7);
+ assert(*next(m.begin(), 6) == 8);
+
+ i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 5));
+ assert(m.size() == 4);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 7);
+ assert(*next(m.begin(), 3) == 8);
+
+ i = m.erase(next(m.cbegin(), 0), next(m.cbegin(), 2));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 0));
+ assert(*next(m.begin(), 0) == 7);
+ assert(*next(m.begin(), 1) == 8);
+
+ i = m.erase(m.cbegin(), m.cend());
+ assert(m.size() == 0);
+ assert(i == m.end());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/erase_key.pass.cpp b/libcxx/test/std/containers/associative/multiset/erase_key.pass.cpp
new file mode 100644
index 00000000000..e9bce1e1b64
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/erase_key.pass.cpp
@@ -0,0 +1,129 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// size_type erase(const key_type& k);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multiset<int> M;
+ typedef int V;
+ typedef M::size_type I;
+ V ar[] =
+ {
+ 3,
+ 3,
+ 3,
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 9);
+ I i = m.erase(6);
+ assert(m.size() == 9);
+ assert(i == 0);
+ assert(*next(m.begin(), 0) == 3);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 5);
+ assert(*next(m.begin(), 5) == 5);
+ assert(*next(m.begin(), 6) == 7);
+ assert(*next(m.begin(), 7) == 7);
+ assert(*next(m.begin(), 8) == 7);
+
+ i = m.erase(5);
+ assert(m.size() == 6);
+ assert(i == 3);
+ assert(*next(m.begin(), 0) == 3);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 7);
+ assert(*next(m.begin(), 4) == 7);
+ assert(*next(m.begin(), 5) == 7);
+
+ i = m.erase(3);
+ assert(m.size() == 3);
+ assert(i == 3);
+ assert(*next(m.begin(), 0) == 7);
+ assert(*next(m.begin(), 1) == 7);
+ assert(*next(m.begin(), 2) == 7);
+
+ i = m.erase(7);
+ assert(m.size() == 0);
+ assert(i == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ typedef int V;
+ typedef M::size_type I;
+ V ar[] =
+ {
+ 3,
+ 3,
+ 3,
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 9);
+ I i = m.erase(6);
+ assert(m.size() == 9);
+ assert(i == 0);
+ assert(*next(m.begin(), 0) == 3);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 5);
+ assert(*next(m.begin(), 5) == 5);
+ assert(*next(m.begin(), 6) == 7);
+ assert(*next(m.begin(), 7) == 7);
+ assert(*next(m.begin(), 8) == 7);
+
+ i = m.erase(5);
+ assert(m.size() == 6);
+ assert(i == 3);
+ assert(*next(m.begin(), 0) == 3);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 7);
+ assert(*next(m.begin(), 4) == 7);
+ assert(*next(m.begin(), 5) == 7);
+
+ i = m.erase(3);
+ assert(m.size() == 3);
+ assert(i == 3);
+ assert(*next(m.begin(), 0) == 7);
+ assert(*next(m.begin(), 1) == 7);
+ assert(*next(m.begin(), 2) == 7);
+
+ i = m.erase(7);
+ assert(m.size() == 0);
+ assert(i == 3);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/find.pass.cpp b/libcxx/test/std/containers/associative/multiset/find.pass.cpp
new file mode 100644
index 00000000000..364460a6ca3
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/find.pass.cpp
@@ -0,0 +1,240 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::multiset<int> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ typedef std::multiset<V, std::less<>> M;
+ typedef M::iterator R;
+
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+
+ {
+ typedef PrivateConstructor V;
+ typedef std::multiset<V, std::less<>> M;
+ typedef M::iterator R;
+
+ M m;
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 6 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 8 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 10 ));
+ m.insert ( V::make ( 11 ));
+ m.insert ( V::make ( 12 ));
+
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/insert_cv.pass.cpp b/libcxx/test/std/containers/associative/multiset/insert_cv.pass.cpp
new file mode 100644
index 00000000000..179715753ab
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/insert_cv.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator insert(const value_type& v);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multiset<int> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(*r == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(*r == 3);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/insert_initializer_list.pass.cpp b/libcxx/test/std/containers/associative/multiset/insert_initializer_list.pass.cpp
new file mode 100644
index 00000000000..7e923f2516d
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/insert_initializer_list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// void insert(initializer_list<value_type> il);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::multiset<int> C;
+ typedef C::value_type V;
+ C m = {10, 8};
+ m.insert({1, 2, 3, 4, 5, 6});
+ assert(m.size() == 8);
+ assert(distance(m.begin(), m.end()) == m.size());
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ assert(*++i == V(8));
+ assert(*++i == V(10));
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> C;
+ typedef C::value_type V;
+ C m = {10, 8};
+ m.insert({1, 2, 3, 4, 5, 6});
+ assert(m.size() == 8);
+ assert(distance(m.begin(), m.end()) == m.size());
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ assert(*++i == V(8));
+ assert(*++i == V(10));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/insert_iter_cv.pass.cpp b/libcxx/test/std/containers/associative/multiset/insert_iter_cv.pass.cpp
new file mode 100644
index 00000000000..7d204024c21
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/insert_iter_cv.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator insert(const_iterator position, const value_type& v);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multiset<int> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(m.cend(), M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(*r == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(m.cend(), M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(*r == 3);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/insert_iter_iter.pass.cpp b/libcxx/test/std/containers/associative/multiset/insert_iter_iter.pass.cpp
new file mode 100644
index 00000000000..189c4549866
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/insert_iter_iter.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class InputIterator>
+// void insert(InputIterator first, InputIterator last);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multiset<int> M;
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ M m;
+ m.insert(input_iterator<const V*>(ar),
+ input_iterator<const V*>(ar + sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ M m;
+ m.insert(input_iterator<const V*>(ar),
+ input_iterator<const V*>(ar + sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/insert_iter_rv.pass.cpp b/libcxx/test/std/containers/associative/multiset/insert_iter_rv.pass.cpp
new file mode 100644
index 00000000000..342c6fd53d7
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/insert_iter_rv.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator insert(const_iterator position, value_type&& v);
+
+#include <set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::multiset<MoveOnly> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(m.cend(), M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(*r == 3);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(m.cend(), M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(*r == 3);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/insert_rv.pass.cpp b/libcxx/test/std/containers/associative/multiset/insert_rv.pass.cpp
new file mode 100644
index 00000000000..1030e0886eb
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/insert_rv.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator insert(value_type&& v);
+
+#include <set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::multiset<MoveOnly> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(*r == 3);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 4);
+ assert(*r == 3);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/iterator.pass.cpp b/libcxx/test/std/containers/associative/multiset/iterator.pass.cpp
new file mode 100644
index 00000000000..d1f0ecfd6aa
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/iterator.pass.cpp
@@ -0,0 +1,215 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator begin();
+// const_iterator begin() const;
+// iterator end();
+// const_iterator end() const;
+//
+// reverse_iterator rbegin();
+// const_reverse_iterator rbegin() const;
+// reverse_iterator rend();
+// const_reverse_iterator rend() const;
+//
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+// const_reverse_iterator crbegin() const;
+// const_reverse_iterator crend() const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3,
+ 4,
+ 4,
+ 4,
+ 5,
+ 5,
+ 5,
+ 6,
+ 6,
+ 6,
+ 7,
+ 7,
+ 7,
+ 8,
+ 8,
+ 8
+ };
+ std::multiset<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ std::multiset<int>::iterator i;
+ i = m.begin();
+ std::multiset<int>::const_iterator k = i;
+ assert(i == k);
+ for (int j = 1; j <= 8; ++j)
+ for (int k = 0; k < 3; ++k, ++i)
+ assert(*i == j);
+ }
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3,
+ 4,
+ 4,
+ 4,
+ 5,
+ 5,
+ 5,
+ 6,
+ 6,
+ 6,
+ 7,
+ 7,
+ 7,
+ 8,
+ 8,
+ 8
+ };
+ const std::multiset<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.cbegin(), m.cend()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ assert(std::distance(m.crbegin(), m.crend()) == m.size());
+ std::multiset<int>::const_iterator i;
+ i = m.begin();
+ for (int j = 1; j <= 8; ++j)
+ for (int k = 0; k < 3; ++k, ++i)
+ assert(*i == j);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3,
+ 4,
+ 4,
+ 4,
+ 5,
+ 5,
+ 5,
+ 6,
+ 6,
+ 6,
+ 7,
+ 7,
+ 7,
+ 8,
+ 8,
+ 8
+ };
+ std::multiset<int, std::less<int>, min_allocator<int>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ std::multiset<int, std::less<int>, min_allocator<int>>::iterator i;
+ i = m.begin();
+ std::multiset<int, std::less<int>, min_allocator<int>>::const_iterator k = i;
+ assert(i == k);
+ for (int j = 1; j <= 8; ++j)
+ for (int k = 0; k < 3; ++k, ++i)
+ assert(*i == j);
+ }
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3,
+ 4,
+ 4,
+ 4,
+ 5,
+ 5,
+ 5,
+ 6,
+ 6,
+ 6,
+ 7,
+ 7,
+ 7,
+ 8,
+ 8,
+ 8
+ };
+ const std::multiset<int, std::less<int>, min_allocator<int>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.cbegin(), m.cend()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ assert(std::distance(m.crbegin(), m.crend()) == m.size());
+ std::multiset<int, std::less<int>, min_allocator<int>>::const_iterator i;
+ i = m.begin();
+ for (int j = 1; j <= 8; ++j)
+ for (int k = 0; k < 3; ++k, ++i)
+ assert(*i == j);
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::multiset<int> C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/lower_bound.pass.cpp b/libcxx/test/std/containers/associative/multiset/lower_bound.pass.cpp
new file mode 100644
index 00000000000..e466791d935
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/lower_bound.pass.cpp
@@ -0,0 +1,223 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::multiset<int> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(5);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(5);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(5);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(5);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ typedef std::multiset<V, std::less<>> M;
+
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+
+ R r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(5);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+
+ {
+ typedef PrivateConstructor V;
+ typedef std::multiset<V, std::less<>> M;
+ typedef M::iterator R;
+
+ M m;
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 9 ));
+
+ R r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(5);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(7);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/max_size.pass.cpp b/libcxx/test/std/containers/associative/multiset/max_size.pass.cpp
new file mode 100644
index 00000000000..5524f771b34
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/max_size.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// size_type max_size() const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multiset<int> M;
+ M m;
+ assert(m.max_size() != 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ M m;
+ assert(m.max_size() != 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/alloc.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/alloc.pass.cpp
new file mode 100644
index 00000000000..0a7572275af
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/alloc.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "test_allocator.h"
+
+int main()
+{
+ typedef std::less<int> C;
+ typedef test_allocator<int> A;
+ std::multiset<int, C, A> m(A(5));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.get_allocator() == A(5));
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 00000000000..7d76581d6d8
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset& operator=(initializer_list<value_type> il);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::multiset<int> C;
+ typedef C::value_type V;
+ C m = {10, 8};
+ m = {1, 2, 3, 4, 5, 6};
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> C;
+ typedef C::value_type V;
+ C m = {10, 8};
+ m = {1, 2, 3, 4, 5, 6};
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/compare.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/compare.pass.cpp
new file mode 100644
index 00000000000..84038ca1e14
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/compare.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// explicit multiset(const value_compare& comp);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+
+int main()
+{
+ typedef test_compare<std::less<int> > C;
+ std::multiset<int, C> m(C(3));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(3));
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/compare_alloc.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/compare_alloc.pass.cpp
new file mode 100644
index 00000000000..76c9f8b2a8a
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/compare_alloc.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(const value_compare& comp, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<int> A;
+ std::multiset<int, C, A> m(C(4), A(5));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(4));
+ assert(m.get_allocator() == A(5));
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/copy.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/copy.pass.cpp
new file mode 100644
index 00000000000..dde36287210
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/copy.pass.cpp
@@ -0,0 +1,118 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(const multiset& m);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::multiset<int, C, A> m = mo;
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 9);
+ assert(distance(mo.begin(), mo.end()) == 9);
+ assert(*next(mo.begin(), 0) == 1);
+ assert(*next(mo.begin(), 1) == 1);
+ assert(*next(mo.begin(), 2) == 1);
+ assert(*next(mo.begin(), 3) == 2);
+ assert(*next(mo.begin(), 4) == 2);
+ assert(*next(mo.begin(), 5) == 2);
+ assert(*next(mo.begin(), 6) == 3);
+ assert(*next(mo.begin(), 7) == 3);
+ assert(*next(mo.begin(), 8) == 3);
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef other_allocator<V> A;
+ std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::multiset<int, C, A> m = mo;
+ assert(m.get_allocator() == A(-2));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 9);
+ assert(distance(mo.begin(), mo.end()) == 9);
+ assert(*next(mo.begin(), 0) == 1);
+ assert(*next(mo.begin(), 1) == 1);
+ assert(*next(mo.begin(), 2) == 1);
+ assert(*next(mo.begin(), 3) == 2);
+ assert(*next(mo.begin(), 4) == 2);
+ assert(*next(mo.begin(), 5) == 2);
+ assert(*next(mo.begin(), 6) == 3);
+ assert(*next(mo.begin(), 7) == 3);
+ assert(*next(mo.begin(), 8) == 3);
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/copy_alloc.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/copy_alloc.pass.cpp
new file mode 100644
index 00000000000..04a769e7332
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/copy_alloc.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(const multiset& m, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::multiset<int, C, A> m(mo, A(3));
+ assert(m.get_allocator() == A(3));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 9);
+ assert(distance(mo.begin(), mo.end()) == 9);
+ assert(*next(mo.begin(), 0) == 1);
+ assert(*next(mo.begin(), 1) == 1);
+ assert(*next(mo.begin(), 2) == 1);
+ assert(*next(mo.begin(), 3) == 2);
+ assert(*next(mo.begin(), 4) == 2);
+ assert(*next(mo.begin(), 5) == 2);
+ assert(*next(mo.begin(), 6) == 3);
+ assert(*next(mo.begin(), 7) == 3);
+ assert(*next(mo.begin(), 8) == 3);
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp
new file mode 100644
index 00000000000..cca636325ff
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/copy_assign.pass.cpp
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset& operator=(const multiset& s);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+ std::multiset<int, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+ m = mo;
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+
+ assert(mo.get_allocator() == A(2));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 9);
+ assert(distance(mo.begin(), mo.end()) == 9);
+ assert(*next(mo.begin(), 0) == 1);
+ assert(*next(mo.begin(), 1) == 1);
+ assert(*next(mo.begin(), 2) == 1);
+ assert(*next(mo.begin(), 3) == 2);
+ assert(*next(mo.begin(), 4) == 2);
+ assert(*next(mo.begin(), 5) == 2);
+ assert(*next(mo.begin(), 6) == 3);
+ assert(*next(mo.begin(), 7) == 3);
+ assert(*next(mo.begin(), 8) == 3);
+ }
+ {
+ typedef int V;
+ const V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ std::multiset<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ std::multiset<int> *p = &m;
+ m = *p;
+ assert(m.size() == 9);
+ assert(std::equal(m.begin(), m.end(), ar));
+ }
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef other_allocator<V> A;
+ std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+ std::multiset<int, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+ m = mo;
+ assert(m.get_allocator() == A(2));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+
+ assert(mo.get_allocator() == A(2));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 9);
+ assert(distance(mo.begin(), mo.end()) == 9);
+ assert(*next(mo.begin(), 0) == 1);
+ assert(*next(mo.begin(), 1) == 1);
+ assert(*next(mo.begin(), 2) == 1);
+ assert(*next(mo.begin(), 3) == 2);
+ assert(*next(mo.begin(), 4) == 2);
+ assert(*next(mo.begin(), 5) == 2);
+ assert(*next(mo.begin(), 6) == 3);
+ assert(*next(mo.begin(), 7) == 3);
+ assert(*next(mo.begin(), 8) == 3);
+ }
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/default.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/default.pass.cpp
new file mode 100644
index 00000000000..5bb0312f012
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/default.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset();
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::multiset<int> m;
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::multiset<int, std::less<int>, min_allocator<int>> m;
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+ {
+ std::multiset<int> m = {};
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp
new file mode 100644
index 00000000000..a0bdb0786c2
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// multiset()
+// noexcept(
+// is_nothrow_default_constructible<allocator_type>::value &&
+// is_nothrow_default_constructible<key_compare>::value &&
+// is_nothrow_copy_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp();
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::multiset<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 00000000000..658af1a89de
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// ~multiset() // implied noexcept;
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ ~some_comp() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::multiset<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp
new file mode 100644
index 00000000000..dadafec7c3b
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::multiset<int> C;
+ typedef C::value_type V;
+ C m = {1, 2, 3, 4, 5, 6};
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> C;
+ typedef C::value_type V;
+ C m = {1, 2, 3, 4, 5, 6};
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> C;
+ typedef C::value_type V;
+ min_allocator<int> a;
+ C m ({1, 2, 3, 4, 5, 6}, a);
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ assert(m.get_allocator() == a);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/initializer_list_compare.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/initializer_list_compare.pass.cpp
new file mode 100644
index 00000000000..c67657aff8a
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/initializer_list_compare.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <set>
+#include <cassert>
+#include "../../../test_compare.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ typedef test_compare<std::less<int> > Cmp;
+ typedef std::multiset<int, Cmp> C;
+ typedef C::value_type V;
+ C m({1, 2, 3, 4, 5, 6}, Cmp(10));
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ assert(m.key_comp() == Cmp(10));
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/initializer_list_compare_alloc.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/initializer_list_compare_alloc.pass.cpp
new file mode 100644
index 00000000000..83114893a1b
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/initializer_list_compare_alloc.pass.cpp
@@ -0,0 +1,41 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ typedef test_compare<std::less<int> > Cmp;
+ typedef test_allocator<int> A;
+ typedef std::multiset<int, Cmp, A> C;
+ typedef C::value_type V;
+ C m({1, 2, 3, 4, 5, 6}, Cmp(10), A(4));
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ assert(m.key_comp() == Cmp(10));
+ assert(m.get_allocator() == A(4));
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp
new file mode 100644
index 00000000000..f6c1fd76de1
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/iter_iter.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class InputIterator>
+// multiset(InputIterator first, InputIterator last);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ std::multiset<V> m(input_iterator<const int*>(ar),
+ input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ std::multiset<V, std::less<V>, min_allocator<V>> m(input_iterator<const int*>(ar),
+ input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp
new file mode 100644
index 00000000000..4ed00c7124c
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp
@@ -0,0 +1,92 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class InputIterator>
+// multiset(InputIterator first, InputIterator last,
+// const value_compare& comp, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<V> > C;
+ typedef test_allocator<V> A;
+ std::multiset<V, C, A> m(input_iterator<const V*>(ar),
+ input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])),
+ C(5), A(7));
+ assert(m.value_comp() == C(5));
+ assert(m.get_allocator() == A(7));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ A a;
+ std::multiset<V, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a);
+
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+ assert(m.get_allocator() == a);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/iter_iter_comp.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/iter_iter_comp.pass.cpp
new file mode 100644
index 00000000000..0bbaaf12eab
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/iter_iter_comp.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// template <class InputIterator>
+// multiset(InputIterator first, InputIterator last, const value_compare& comp);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+
+int main()
+{
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<V> > C;
+ std::multiset<V, C> m(input_iterator<const V*>(ar),
+ input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])), C(5));
+ assert(m.value_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/move.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/move.pass.cpp
new file mode 100644
index 00000000000..40321cd247e
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/move.pass.cpp
@@ -0,0 +1,119 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(multiset&& s);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef int V;
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::multiset<int, C, A> mo(C(5), A(7));
+ std::multiset<int, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 0);
+ assert(distance(m.begin(), m.end()) == 0);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::multiset<int, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::multiset<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::multiset<int, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 9);
+ assert(distance(m.begin(), m.end()) == 9);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 1);
+ assert(*next(m.begin(), 2) == 1);
+ assert(*next(m.begin(), 3) == 2);
+ assert(*next(m.begin(), 4) == 2);
+ assert(*next(m.begin(), 5) == 2);
+ assert(*next(m.begin(), 6) == 3);
+ assert(*next(m.begin(), 7) == 3);
+ assert(*next(m.begin(), 8) == 3);
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp
new file mode 100644
index 00000000000..1a0b065f8b9
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset(multiset&& s, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<V> A;
+ typedef std::multiset<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(7));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<V> A;
+ typedef std::multiset<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(5));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef other_allocator<V> A;
+ typedef std::multiset<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(5));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp
new file mode 100644
index 00000000000..0b0ce44cb8d
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp
@@ -0,0 +1,186 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// multiset& operator=(multiset&& s);
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<V> A;
+ typedef std::multiset<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(7));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<V> A;
+ typedef std::multiset<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(5));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef other_allocator<V> A;
+ typedef std::multiset<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(5));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef min_allocator<V> A;
+ typedef std::multiset<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A());
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A());
+ M m3(C(3), A());
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A());
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 00000000000..cef3f202487
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// multiset& operator=(multiset&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value &&
+// is_nothrow_move_assignable<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp& operator=(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::multiset<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp
new file mode 100644
index 00000000000..e18f3f5f1bf
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// multiset(multiset&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+// is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::multiset<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.special/member_swap.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.special/member_swap.pass.cpp
new file mode 100644
index 00000000000..ce906896b9a
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.special/member_swap.pass.cpp
@@ -0,0 +1,201 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// void swap(multiset& m);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::multiset<int> M;
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.special/non_member_swap.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.special/non_member_swap.pass.cpp
new file mode 100644
index 00000000000..222985a08f7
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.special/non_member_swap.pass.cpp
@@ -0,0 +1,177 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// void swap(multiset& m);
+
+#include <set>
+#include <cassert>
+#include "test_allocator.h"
+#include "../../../test_compare.h"
+
+int main()
+{
+ typedef int V;
+ typedef std::multiset<int> M;
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ typedef test_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::set<int, C, A> M;
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ assert(m1.key_comp() == C(2));
+ assert(m1.get_allocator() == A(1));
+ assert(m2.key_comp() == C(1));
+ assert(m2.get_allocator() == A(2));
+ }
+ {
+ typedef other_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::set<int, C, A> M;
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ assert(m1.key_comp() == C(2));
+ assert(m1.get_allocator() == A(2));
+ assert(m2.key_comp() == C(1));
+ assert(m2.get_allocator() == A(1));
+ }
+}
diff --git a/libcxx/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp
new file mode 100644
index 00000000000..531fe801a16
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/multiset.special/swap_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// void swap(multiset& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+
+ some_comp() {}
+ some_comp(const some_comp&) {}
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::multiset<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/scary.pass.cpp b/libcxx/test/std/containers/associative/multiset/scary.pass.cpp
new file mode 100644
index 00000000000..f5ee32714e8
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/scary.pass.cpp
@@ -0,0 +1,24 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set class multiset
+
+// Extension: SCARY/N2913 iterator compatibility between set and multiset
+
+#include <set>
+
+int main()
+{
+ typedef std::set<int> M1;
+ typedef std::multiset<int> M2;
+ M2::iterator i;
+ M1::iterator j = i;
+}
diff --git a/libcxx/test/std/containers/associative/multiset/size.pass.cpp b/libcxx/test/std/containers/associative/multiset/size.pass.cpp
new file mode 100644
index 00000000000..68099b566df
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// size_type size() const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multiset<int> M;
+ M m;
+ assert(m.size() == 0);
+ m.insert(M::value_type(2));
+ assert(m.size() == 1);
+ m.insert(M::value_type(1));
+ assert(m.size() == 2);
+ m.insert(M::value_type(2));
+ assert(m.size() == 3);
+ m.erase(m.begin());
+ assert(m.size() == 2);
+ m.erase(m.begin());
+ assert(m.size() == 1);
+ m.erase(m.begin());
+ assert(m.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ M m;
+ assert(m.size() == 0);
+ m.insert(M::value_type(2));
+ assert(m.size() == 1);
+ m.insert(M::value_type(1));
+ assert(m.size() == 2);
+ m.insert(M::value_type(2));
+ assert(m.size() == 3);
+ m.erase(m.begin());
+ assert(m.size() == 2);
+ m.erase(m.begin());
+ assert(m.size() == 1);
+ m.erase(m.begin());
+ assert(m.size() == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/types.pass.cpp b/libcxx/test/std/containers/associative/multiset/types.pass.cpp
new file mode 100644
index 00000000000..e1e3ad9100c
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/types.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// template <class Key, class Compare = less<Key>,
+// class Allocator = allocator<Key>>
+// class multiset
+// {
+// public:
+// // types:
+// typedef Key key_type;
+// typedef key_type value_type;
+// typedef Compare key_compare;
+// typedef key_compare value_compare;
+// typedef Allocator allocator_type;
+// typedef typename allocator_type::reference reference;
+// typedef typename allocator_type::const_reference const_reference;
+// typedef typename allocator_type::pointer pointer;
+// typedef typename allocator_type::const_pointer const_pointer;
+// typedef typename allocator_type::size_type size_type;
+// typedef typename allocator_type::difference_type difference_type;
+// ...
+// };
+
+#include <set>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::multiset<int> C;
+ static_assert((std::is_same<C::key_type, int>::value), "");
+ static_assert((std::is_same<C::value_type, int>::value), "");
+ static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::value_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::allocator_type, std::allocator<int> >::value), "");
+ static_assert((std::is_same<C::reference, int&>::value), "");
+ static_assert((std::is_same<C::const_reference, const int&>::value), "");
+ static_assert((std::is_same<C::pointer, int*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const int*>::value), "");
+ static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> C;
+ static_assert((std::is_same<C::key_type, int>::value), "");
+ static_assert((std::is_same<C::value_type, int>::value), "");
+ static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::value_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<int>>::value), "");
+ static_assert((std::is_same<C::reference, int&>::value), "");
+ static_assert((std::is_same<C::const_reference, const int&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<int>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const int>>::value), "");
+// min_allocator doesn't have a size_type, so one gets synthesized
+ static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/multiset/upper_bound.pass.cpp b/libcxx/test/std/containers/associative/multiset/upper_bound.pass.cpp
new file mode 100644
index 00000000000..7ad3d6ced3d
--- /dev/null
+++ b/libcxx/test/std/containers/associative/multiset/upper_bound.pass.cpp
@@ -0,0 +1,222 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class multiset
+
+// iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::multiset<int> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ typedef std::multiset<V, std::less<>> M;
+
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 5,
+ 5,
+ 7,
+ 7,
+ 7,
+ 9,
+ 9,
+ 9
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+
+ {
+ typedef PrivateConstructor V;
+ typedef std::multiset<V, std::less<>> M;
+
+ typedef M::iterator R;
+ M m;
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 9 ));
+
+ R r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(5);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 9));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 9));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/clear.pass.cpp b/libcxx/test/std/containers/associative/set/clear.pass.cpp
new file mode 100644
index 00000000000..4439ad3b1e4
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/clear.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// void clear();
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::set<int> M;
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ m.clear();
+ assert(m.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ m.clear();
+ assert(m.size() == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/count.pass.cpp b/libcxx/test/std/containers/associative/set/count.pass.cpp
new file mode 100644
index 00000000000..32fe0b8bcee
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/count.pass.cpp
@@ -0,0 +1,168 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// size_type count(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::set<int> M;
+ typedef M::size_type R;
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(5);
+ assert(r == 1);
+ r = m.count(6);
+ assert(r == 1);
+ r = m.count(7);
+ assert(r == 1);
+ r = m.count(8);
+ assert(r == 1);
+ r = m.count(9);
+ assert(r == 1);
+ r = m.count(10);
+ assert(r == 1);
+ r = m.count(11);
+ assert(r == 1);
+ r = m.count(12);
+ assert(r == 1);
+ r = m.count(4);
+ assert(r == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ typedef M::size_type R;
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(5);
+ assert(r == 1);
+ r = m.count(6);
+ assert(r == 1);
+ r = m.count(7);
+ assert(r == 1);
+ r = m.count(8);
+ assert(r == 1);
+ r = m.count(9);
+ assert(r == 1);
+ r = m.count(10);
+ assert(r == 1);
+ r = m.count(11);
+ assert(r == 1);
+ r = m.count(12);
+ assert(r == 1);
+ r = m.count(4);
+ assert(r == 0);
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ typedef std::set<int, std::less<>> M;
+ typedef M::size_type R;
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.count(5);
+ assert(r == 1);
+ r = m.count(6);
+ assert(r == 1);
+ r = m.count(7);
+ assert(r == 1);
+ r = m.count(8);
+ assert(r == 1);
+ r = m.count(9);
+ assert(r == 1);
+ r = m.count(10);
+ assert(r == 1);
+ r = m.count(11);
+ assert(r == 1);
+ r = m.count(12);
+ assert(r == 1);
+ r = m.count(4);
+ assert(r == 0);
+ }
+ {
+ typedef PrivateConstructor V;
+ typedef std::set<V, std::less<>> M;
+ typedef M::size_type R;
+
+ M m;
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 6 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 8 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 10 ));
+ m.insert ( V::make ( 11 ));
+ m.insert ( V::make ( 12 ));
+
+ R r = m.count(5);
+ assert(r == 1);
+ r = m.count(6);
+ assert(r == 1);
+ r = m.count(7);
+ assert(r == 1);
+ r = m.count(8);
+ assert(r == 1);
+ r = m.count(9);
+ assert(r == 1);
+ r = m.count(10);
+ assert(r == 1);
+ r = m.count(11);
+ assert(r == 1);
+ r = m.count(12);
+ assert(r == 1);
+ r = m.count(4);
+ assert(r == 0);
+ }
+#endif
+
+}
diff --git a/libcxx/test/std/containers/associative/set/emplace.pass.cpp b/libcxx/test/std/containers/associative/set/emplace.pass.cpp
new file mode 100644
index 00000000000..5ebab4d24b9
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/emplace.pass.cpp
@@ -0,0 +1,90 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class... Args>
+// pair<iterator, bool> emplace(Args&&... args);
+
+#include <set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::set<DefaultOnly> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace();
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(*m.begin() == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+
+ r = m.emplace();
+ assert(!r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(*m.begin() == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::set<Emplaceable> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.emplace();
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(*m.begin() == Emplaceable());
+ r = m.emplace(2, 3.5);
+ assert(r.second);
+ assert(r.first == next(m.begin()));
+ assert(m.size() == 2);
+ assert(*r.first == Emplaceable(2, 3.5));
+ r = m.emplace(2, 3.5);
+ assert(!r.second);
+ assert(r.first == next(m.begin()));
+ assert(m.size() == 2);
+ assert(*r.first == Emplaceable(2, 3.5));
+ }
+ {
+ typedef std::set<int> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.emplace(M::value_type(2));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(*r.first == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.emplace(M::value_type(2));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(*r.first == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/set/emplace_hint.pass.cpp b/libcxx/test/std/containers/associative/set/emplace_hint.pass.cpp
new file mode 100644
index 00000000000..5fdeb4ffef3
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/emplace_hint.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class... Args>
+// iterator emplace_hint(const_iterator position, Args&&... args);
+
+#include <set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::set<DefaultOnly> M;
+ typedef M::iterator R;
+ M m;
+ assert(DefaultOnly::count == 0);
+ R r = m.emplace_hint(m.cend());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*m.begin() == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+
+ r = m.emplace_hint(m.cbegin());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*m.begin() == DefaultOnly());
+ assert(DefaultOnly::count == 1);
+ }
+ assert(DefaultOnly::count == 0);
+ {
+ typedef std::set<Emplaceable> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.cend());
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*m.begin() == Emplaceable());
+ r = m.emplace_hint(m.cend(), 2, 3.5);
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(*r == Emplaceable(2, 3.5));
+ r = m.emplace_hint(m.cbegin(), 2, 3.5);
+ assert(r == next(m.begin()));
+ assert(m.size() == 2);
+ assert(*r == Emplaceable(2, 3.5));
+ }
+ {
+ typedef std::set<int> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.emplace_hint(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/set/empty.pass.cpp b/libcxx/test/std/containers/associative/set/empty.pass.cpp
new file mode 100644
index 00000000000..eb1080263f4
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/empty.pass.cpp
@@ -0,0 +1,43 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// bool empty() const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::set<int> M;
+ M m;
+ assert(m.empty());
+ m.insert(M::value_type(1));
+ assert(!m.empty());
+ m.clear();
+ assert(m.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ M m;
+ assert(m.empty());
+ m.insert(M::value_type(1));
+ assert(!m.empty());
+ m.clear();
+ assert(m.empty());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/equal_range.pass.cpp b/libcxx/test/std/containers/associative/set/equal_range.pass.cpp
new file mode 100644
index 00000000000..8a180ef4924
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/equal_range.pass.cpp
@@ -0,0 +1,370 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// pair<iterator,iterator> equal_range(const key_type& k);
+// pair<const_iterator,const_iterator> equal_range(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::set<int> M;
+ {
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+ {
+ typedef std::pair<M::const_iterator, M::const_iterator> R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ typedef std::set<V, std::less<>> M;
+ {
+ typedef std::pair<M::iterator, M::iterator> R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+ }
+ {
+ typedef PrivateConstructor V;
+ typedef std::set<V, std::less<>> M;
+ typedef std::pair<M::iterator, M::iterator> R;
+
+ M m;
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 11 ));
+ m.insert ( V::make ( 13 ));
+ m.insert ( V::make ( 15 ));
+ m.insert ( V::make ( 17 ));
+ m.insert ( V::make ( 19 ));
+
+ R r = m.equal_range(5);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(7);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(9);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(11);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(13);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(15);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(17);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(19);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 8));
+ r = m.equal_range(4);
+ assert(r.first == next(m.begin(), 0));
+ assert(r.second == next(m.begin(), 0));
+ r = m.equal_range(6);
+ assert(r.first == next(m.begin(), 1));
+ assert(r.second == next(m.begin(), 1));
+ r = m.equal_range(8);
+ assert(r.first == next(m.begin(), 2));
+ assert(r.second == next(m.begin(), 2));
+ r = m.equal_range(10);
+ assert(r.first == next(m.begin(), 3));
+ assert(r.second == next(m.begin(), 3));
+ r = m.equal_range(12);
+ assert(r.first == next(m.begin(), 4));
+ assert(r.second == next(m.begin(), 4));
+ r = m.equal_range(14);
+ assert(r.first == next(m.begin(), 5));
+ assert(r.second == next(m.begin(), 5));
+ r = m.equal_range(16);
+ assert(r.first == next(m.begin(), 6));
+ assert(r.second == next(m.begin(), 6));
+ r = m.equal_range(18);
+ assert(r.first == next(m.begin(), 7));
+ assert(r.second == next(m.begin(), 7));
+ r = m.equal_range(20);
+ assert(r.first == next(m.begin(), 8));
+ assert(r.second == next(m.begin(), 8));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/erase_iter.pass.cpp b/libcxx/test/std/containers/associative/set/erase_iter.pass.cpp
new file mode 100644
index 00000000000..21666c36401
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/erase_iter.pass.cpp
@@ -0,0 +1,181 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator erase(const_iterator position);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::set<int> M;
+ typedef int V;
+ typedef M::iterator I;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(next(m.cbegin(), 3));
+ assert(m.size() == 7);
+ assert(i == next(m.begin(), 3));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 6);
+ assert(*next(m.begin(), 5) == 7);
+ assert(*next(m.begin(), 6) == 8);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 6);
+ assert(i == m.begin());
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+ assert(*next(m.begin(), 5) == 8);
+
+ i = m.erase(next(m.cbegin(), 5));
+ assert(m.size() == 5);
+ assert(i == m.end());
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+
+ i = m.erase(next(m.cbegin(), 1));
+ assert(m.size() == 4);
+ assert(i == next(m.begin()));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 6);
+ assert(*next(m.begin(), 3) == 7);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 3);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 7);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 1);
+ assert(i == next(m.begin(), 0));
+ assert(*next(m.begin(), 0) == 5);
+
+ i = m.erase(m.cbegin());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ typedef int V;
+ typedef M::iterator I;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(next(m.cbegin(), 3));
+ assert(m.size() == 7);
+ assert(i == next(m.begin(), 3));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 6);
+ assert(*next(m.begin(), 5) == 7);
+ assert(*next(m.begin(), 6) == 8);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 6);
+ assert(i == m.begin());
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+ assert(*next(m.begin(), 5) == 8);
+
+ i = m.erase(next(m.cbegin(), 5));
+ assert(m.size() == 5);
+ assert(i == m.end());
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+
+ i = m.erase(next(m.cbegin(), 1));
+ assert(m.size() == 4);
+ assert(i == next(m.begin()));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 6);
+ assert(*next(m.begin(), 3) == 7);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 3);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 7);
+
+ i = m.erase(next(m.cbegin(), 2));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+
+ i = m.erase(next(m.cbegin(), 0));
+ assert(m.size() == 1);
+ assert(i == next(m.begin(), 0));
+ assert(*next(m.begin(), 0) == 5);
+
+ i = m.erase(m.cbegin());
+ assert(m.size() == 0);
+ assert(i == m.begin());
+ assert(i == m.end());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/erase_iter_iter.pass.cpp b/libcxx/test/std/containers/associative/set/erase_iter_iter.pass.cpp
new file mode 100644
index 00000000000..47995031665
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/erase_iter_iter.pass.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::set<int> M;
+ typedef int V;
+ typedef M::iterator I;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(next(m.cbegin(), 5), next(m.cbegin(), 5));
+ assert(m.size() == 8);
+ assert(i == next(m.begin(), 5));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 4);
+ assert(*next(m.begin(), 4) == 5);
+ assert(*next(m.begin(), 5) == 6);
+ assert(*next(m.begin(), 6) == 7);
+ assert(*next(m.begin(), 7) == 8);
+
+ i = m.erase(next(m.cbegin(), 3), next(m.cbegin(), 4));
+ assert(m.size() == 7);
+ assert(i == next(m.begin(), 3));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 6);
+ assert(*next(m.begin(), 5) == 7);
+ assert(*next(m.begin(), 6) == 8);
+
+ i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 5));
+ assert(m.size() == 4);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 7);
+ assert(*next(m.begin(), 3) == 8);
+
+ i = m.erase(next(m.cbegin(), 0), next(m.cbegin(), 2));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 0));
+ assert(*next(m.begin(), 0) == 7);
+ assert(*next(m.begin(), 1) == 8);
+
+ i = m.erase(m.cbegin(), m.cend());
+ assert(m.size() == 0);
+ assert(i == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ typedef int V;
+ typedef M::iterator I;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(next(m.cbegin(), 5), next(m.cbegin(), 5));
+ assert(m.size() == 8);
+ assert(i == next(m.begin(), 5));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 4);
+ assert(*next(m.begin(), 4) == 5);
+ assert(*next(m.begin(), 5) == 6);
+ assert(*next(m.begin(), 6) == 7);
+ assert(*next(m.begin(), 7) == 8);
+
+ i = m.erase(next(m.cbegin(), 3), next(m.cbegin(), 4));
+ assert(m.size() == 7);
+ assert(i == next(m.begin(), 3));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 6);
+ assert(*next(m.begin(), 5) == 7);
+ assert(*next(m.begin(), 6) == 8);
+
+ i = m.erase(next(m.cbegin(), 2), next(m.cbegin(), 5));
+ assert(m.size() == 4);
+ assert(i == next(m.begin(), 2));
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 7);
+ assert(*next(m.begin(), 3) == 8);
+
+ i = m.erase(next(m.cbegin(), 0), next(m.cbegin(), 2));
+ assert(m.size() == 2);
+ assert(i == next(m.begin(), 0));
+ assert(*next(m.begin(), 0) == 7);
+ assert(*next(m.begin(), 1) == 8);
+
+ i = m.erase(m.cbegin(), m.cend());
+ assert(m.size() == 0);
+ assert(i == m.end());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/erase_key.pass.cpp b/libcxx/test/std/containers/associative/set/erase_key.pass.cpp
new file mode 100644
index 00000000000..9d92bd70d70
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/erase_key.pass.cpp
@@ -0,0 +1,203 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// size_type erase(const key_type& k);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::set<int> M;
+ typedef int V;
+ typedef M::size_type I;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(9);
+ assert(m.size() == 8);
+ assert(i == 0);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 4);
+ assert(*next(m.begin(), 4) == 5);
+ assert(*next(m.begin(), 5) == 6);
+ assert(*next(m.begin(), 6) == 7);
+ assert(*next(m.begin(), 7) == 8);
+
+ i = m.erase(4);
+ assert(m.size() == 7);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 6);
+ assert(*next(m.begin(), 5) == 7);
+ assert(*next(m.begin(), 6) == 8);
+
+ i = m.erase(1);
+ assert(m.size() == 6);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+ assert(*next(m.begin(), 5) == 8);
+
+ i = m.erase(8);
+ assert(m.size() == 5);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+
+ i = m.erase(3);
+ assert(m.size() == 4);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 6);
+ assert(*next(m.begin(), 3) == 7);
+
+ i = m.erase(6);
+ assert(m.size() == 3);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 7);
+
+ i = m.erase(7);
+ assert(m.size() == 2);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+
+ i = m.erase(2);
+ assert(m.size() == 1);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 5);
+
+ i = m.erase(5);
+ assert(m.size() == 0);
+ assert(i == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ typedef int V;
+ typedef M::size_type I;
+ V ar[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8
+ };
+ M m(ar, ar + sizeof(ar)/sizeof(ar[0]));
+ assert(m.size() == 8);
+ I i = m.erase(9);
+ assert(m.size() == 8);
+ assert(i == 0);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 4);
+ assert(*next(m.begin(), 4) == 5);
+ assert(*next(m.begin(), 5) == 6);
+ assert(*next(m.begin(), 6) == 7);
+ assert(*next(m.begin(), 7) == 8);
+
+ i = m.erase(4);
+ assert(m.size() == 7);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 1);
+ assert(*next(m.begin(), 1) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(*next(m.begin(), 3) == 5);
+ assert(*next(m.begin(), 4) == 6);
+ assert(*next(m.begin(), 5) == 7);
+ assert(*next(m.begin(), 6) == 8);
+
+ i = m.erase(1);
+ assert(m.size() == 6);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+ assert(*next(m.begin(), 5) == 8);
+
+ i = m.erase(8);
+ assert(m.size() == 5);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 3);
+ assert(*next(m.begin(), 2) == 5);
+ assert(*next(m.begin(), 3) == 6);
+ assert(*next(m.begin(), 4) == 7);
+
+ i = m.erase(3);
+ assert(m.size() == 4);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 6);
+ assert(*next(m.begin(), 3) == 7);
+
+ i = m.erase(6);
+ assert(m.size() == 3);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+ assert(*next(m.begin(), 2) == 7);
+
+ i = m.erase(7);
+ assert(m.size() == 2);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 2);
+ assert(*next(m.begin(), 1) == 5);
+
+ i = m.erase(2);
+ assert(m.size() == 1);
+ assert(i == 1);
+ assert(*next(m.begin(), 0) == 5);
+
+ i = m.erase(5);
+ assert(m.size() == 0);
+ assert(i == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/find.pass.cpp b/libcxx/test/std/containers/associative/set/find.pass.cpp
new file mode 100644
index 00000000000..d08d2fb1e24
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/find.pass.cpp
@@ -0,0 +1,240 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator find(const key_type& k);
+// const_iterator find(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::set<int> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ typedef std::set<V, std::less<>> M;
+ typedef M::iterator R;
+
+ V ar[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+
+ {
+ typedef PrivateConstructor V;
+ typedef std::set<V, std::less<>> M;
+ typedef M::iterator R;
+
+ M m;
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 6 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 8 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 10 ));
+ m.insert ( V::make ( 11 ));
+ m.insert ( V::make ( 12 ));
+
+ R r = m.find(5);
+ assert(r == m.begin());
+ r = m.find(6);
+ assert(r == next(m.begin()));
+ r = m.find(7);
+ assert(r == next(m.begin(), 2));
+ r = m.find(8);
+ assert(r == next(m.begin(), 3));
+ r = m.find(9);
+ assert(r == next(m.begin(), 4));
+ r = m.find(10);
+ assert(r == next(m.begin(), 5));
+ r = m.find(11);
+ assert(r == next(m.begin(), 6));
+ r = m.find(12);
+ assert(r == next(m.begin(), 7));
+ r = m.find(4);
+ assert(r == next(m.begin(), 8));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/insert_cv.pass.cpp b/libcxx/test/std/containers/associative/set/insert_cv.pass.cpp
new file mode 100644
index 00000000000..18d5c2e0339
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/insert_cv.pass.cpp
@@ -0,0 +1,81 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// pair<iterator, bool> insert(const value_type& v);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::set<int> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.insert(M::value_type(2));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(*r.first == 2);
+
+ r = m.insert(M::value_type(1));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(*r.first == 1);
+
+ r = m.insert(M::value_type(3));
+ assert(r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r.first == 3);
+
+ r = m.insert(M::value_type(3));
+ assert(!r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r.first == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.insert(M::value_type(2));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(*r.first == 2);
+
+ r = m.insert(M::value_type(1));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(*r.first == 1);
+
+ r = m.insert(M::value_type(3));
+ assert(r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r.first == 3);
+
+ r = m.insert(M::value_type(3));
+ assert(!r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r.first == 3);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/insert_initializer_list.pass.cpp b/libcxx/test/std/containers/associative/set/insert_initializer_list.pass.cpp
new file mode 100644
index 00000000000..fc6d612b2eb
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/insert_initializer_list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// void insert(initializer_list<value_type> il);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::set<int> C;
+ typedef C::value_type V;
+ C m = {10, 8};
+ m.insert({1, 2, 3, 4, 5, 6});
+ assert(m.size() == 8);
+ assert(distance(m.begin(), m.end()) == m.size());
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ assert(*++i == V(8));
+ assert(*++i == V(10));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> C;
+ typedef C::value_type V;
+ C m = {10, 8};
+ m.insert({1, 2, 3, 4, 5, 6});
+ assert(m.size() == 8);
+ assert(distance(m.begin(), m.end()) == m.size());
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ assert(*++i == V(8));
+ assert(*++i == V(10));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/associative/set/insert_iter_cv.pass.cpp b/libcxx/test/std/containers/associative/set/insert_iter_cv.pass.cpp
new file mode 100644
index 00000000000..718e720559f
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/insert_iter_cv.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator insert(const_iterator position, const value_type& v);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::set<int> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(m.cend(), M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(m.cend(), M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/insert_iter_iter.pass.cpp b/libcxx/test/std/containers/associative/set/insert_iter_iter.pass.cpp
new file mode 100644
index 00000000000..ff729a0e7b9
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/insert_iter_iter.pass.cpp
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class InputIterator>
+// void insert(InputIterator first, InputIterator last);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::set<int> M;
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ M m;
+ m.insert(input_iterator<const V*>(ar),
+ input_iterator<const V*>(ar + sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ M m;
+ m.insert(input_iterator<const V*>(ar),
+ input_iterator<const V*>(ar + sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/insert_iter_rv.pass.cpp b/libcxx/test/std/containers/associative/set/insert_iter_rv.pass.cpp
new file mode 100644
index 00000000000..c149fa3c68e
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/insert_iter_rv.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator insert(const_iterator position, value_type&& v);
+
+#include <set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::set<MoveOnly> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(m.cend(), M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M;
+ typedef M::iterator R;
+ M m;
+ R r = m.insert(m.cend(), M::value_type(2));
+ assert(r == m.begin());
+ assert(m.size() == 1);
+ assert(*r == 2);
+
+ r = m.insert(m.cend(), M::value_type(1));
+ assert(r == m.begin());
+ assert(m.size() == 2);
+ assert(*r == 1);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+
+ r = m.insert(m.cend(), M::value_type(3));
+ assert(r == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r == 3);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/set/insert_rv.pass.cpp b/libcxx/test/std/containers/associative/set/insert_rv.pass.cpp
new file mode 100644
index 00000000000..39894514ee9
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/insert_rv.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// pair<iterator, bool> insert(value_type&& v);
+
+#include <set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::set<MoveOnly> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.insert(M::value_type(2));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(*r.first == 2);
+
+ r = m.insert(M::value_type(1));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(*r.first == 1);
+
+ r = m.insert(M::value_type(3));
+ assert(r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r.first == 3);
+
+ r = m.insert(M::value_type(3));
+ assert(!r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r.first == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M;
+ typedef std::pair<M::iterator, bool> R;
+ M m;
+ R r = m.insert(M::value_type(2));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 1);
+ assert(*r.first == 2);
+
+ r = m.insert(M::value_type(1));
+ assert(r.second);
+ assert(r.first == m.begin());
+ assert(m.size() == 2);
+ assert(*r.first == 1);
+
+ r = m.insert(M::value_type(3));
+ assert(r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r.first == 3);
+
+ r = m.insert(M::value_type(3));
+ assert(!r.second);
+ assert(r.first == prev(m.end()));
+ assert(m.size() == 3);
+ assert(*r.first == 3);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/set/iterator.pass.cpp b/libcxx/test/std/containers/associative/set/iterator.pass.cpp
new file mode 100644
index 00000000000..ecd950f03a0
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/iterator.pass.cpp
@@ -0,0 +1,211 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator begin();
+// const_iterator begin() const;
+// iterator end();
+// const_iterator end() const;
+//
+// reverse_iterator rbegin();
+// const_reverse_iterator rbegin() const;
+// reverse_iterator rend();
+// const_reverse_iterator rend() const;
+//
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+// const_reverse_iterator crbegin() const;
+// const_reverse_iterator crend() const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3,
+ 4,
+ 4,
+ 4,
+ 5,
+ 5,
+ 5,
+ 6,
+ 6,
+ 6,
+ 7,
+ 7,
+ 7,
+ 8,
+ 8,
+ 8
+ };
+ std::set<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ std::set<int>::iterator i;
+ i = m.begin();
+ std::set<int>::const_iterator k = i;
+ assert(i == k);
+ for (int j = 1; j <= m.size(); ++j, ++i)
+ assert(*i == j);
+ }
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3,
+ 4,
+ 4,
+ 4,
+ 5,
+ 5,
+ 5,
+ 6,
+ 6,
+ 6,
+ 7,
+ 7,
+ 7,
+ 8,
+ 8,
+ 8
+ };
+ const std::set<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.cbegin(), m.cend()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ assert(std::distance(m.crbegin(), m.crend()) == m.size());
+ std::set<int>::const_iterator i;
+ i = m.begin();
+ for (int j = 1; j <= m.size(); ++j, ++i)
+ assert(*i == j);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3,
+ 4,
+ 4,
+ 4,
+ 5,
+ 5,
+ 5,
+ 6,
+ 6,
+ 6,
+ 7,
+ 7,
+ 7,
+ 8,
+ 8,
+ 8
+ };
+ std::set<int, std::less<int>, min_allocator<int>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ std::set<int, std::less<int>, min_allocator<int>>::iterator i;
+ i = m.begin();
+ std::set<int, std::less<int>, min_allocator<int>>::const_iterator k = i;
+ assert(i == k);
+ for (int j = 1; j <= m.size(); ++j, ++i)
+ assert(*i == j);
+ }
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3,
+ 4,
+ 4,
+ 4,
+ 5,
+ 5,
+ 5,
+ 6,
+ 6,
+ 6,
+ 7,
+ 7,
+ 7,
+ 8,
+ 8,
+ 8
+ };
+ const std::set<int, std::less<int>, min_allocator<int>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ assert(std::distance(m.begin(), m.end()) == m.size());
+ assert(std::distance(m.cbegin(), m.cend()) == m.size());
+ assert(std::distance(m.rbegin(), m.rend()) == m.size());
+ assert(std::distance(m.crbegin(), m.crend()) == m.size());
+ std::set<int, std::less<int>, min_allocator<int>>::const_iterator i;
+ i = m.begin();
+ for (int j = 1; j <= m.size(); ++j, ++i)
+ assert(*i == j);
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::set<int> C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/lower_bound.pass.cpp b/libcxx/test/std/containers/associative/set/lower_bound.pass.cpp
new file mode 100644
index 00000000000..df202f31a4c
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/lower_bound.pass.cpp
@@ -0,0 +1,337 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator lower_bound(const key_type& k);
+// const_iterator lower_bound(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::set<int> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ typedef std::set<V, std::less<>> M;
+ typedef M::iterator R;
+
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+
+ {
+ typedef PrivateConstructor V;
+ typedef std::set<V, std::less<>> M;
+ typedef M::iterator R;
+
+ M m;
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 11 ));
+ m.insert ( V::make ( 13 ));
+ m.insert ( V::make ( 15 ));
+ m.insert ( V::make ( 17 ));
+ m.insert ( V::make ( 19 ));
+
+ R r = m.lower_bound(5);
+ assert(r == m.begin());
+ r = m.lower_bound(7);
+ assert(r == next(m.begin()));
+ r = m.lower_bound(9);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(11);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(13);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(15);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(17);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(19);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.lower_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.lower_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.lower_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.lower_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.lower_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.lower_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.lower_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.lower_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+#endif
+
+}
diff --git a/libcxx/test/std/containers/associative/set/max_size.pass.cpp b/libcxx/test/std/containers/associative/set/max_size.pass.cpp
new file mode 100644
index 00000000000..cde4397c717
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/max_size.pass.cpp
@@ -0,0 +1,35 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// size_type max_size() const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::set<int> M;
+ M m;
+ assert(m.max_size() != 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ M m;
+ assert(m.max_size() != 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/alloc.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/alloc.pass.cpp
new file mode 100644
index 00000000000..67433ff88a0
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.cons/alloc.pass.cpp
@@ -0,0 +1,29 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "test_allocator.h"
+
+int main()
+{
+ typedef std::less<int> C;
+ typedef test_allocator<int> A;
+ std::set<int, C, A> m(A(5));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.get_allocator() == A(5));
+}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 00000000000..892ae5a0a79
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,57 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set& operator=(initializer_list<value_type> il);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::set<int> C;
+ typedef C::value_type V;
+ C m = {10, 8};
+ m = {1, 2, 3, 4, 5, 6};
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> C;
+ typedef C::value_type V;
+ C m = {10, 8};
+ m = {1, 2, 3, 4, 5, 6};
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/compare.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/compare.pass.cpp
new file mode 100644
index 00000000000..af94c70671b
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.cons/compare.pass.cpp
@@ -0,0 +1,28 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// explicit set(const value_compare& comp);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+
+int main()
+{
+ typedef test_compare<std::less<int> > C;
+ std::set<int, C> m(C(3));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(3));
+}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/compare_alloc.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/compare_alloc.pass.cpp
new file mode 100644
index 00000000000..22b3328d4d7
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.cons/compare_alloc.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(const value_compare& comp, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<int> A;
+ std::set<int, C, A> m(C(4), A(5));
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ assert(m.key_comp() == C(4));
+ assert(m.get_allocator() == A(5));
+}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/copy.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/copy.pass.cpp
new file mode 100644
index 00000000000..a0e34e48de4
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.cons/copy.pass.cpp
@@ -0,0 +1,94 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(const set& m);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::set<int, C, A> m = mo;
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == 1);
+ assert(*next(mo.begin()) == 2);
+ assert(*next(mo.begin(), 2) == 3);
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef other_allocator<V> A;
+ std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::set<int, C, A> m = mo;
+ assert(m.get_allocator() == A(-2));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == 1);
+ assert(*next(mo.begin()) == 2);
+ assert(*next(mo.begin(), 2) == 3);
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/copy_alloc.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/copy_alloc.pass.cpp
new file mode 100644
index 00000000000..1ad03dc1404
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.cons/copy_alloc.pass.cpp
@@ -0,0 +1,56 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(const set& m, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::set<int, C, A> m(mo, A(3));
+ assert(m.get_allocator() == A(3));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == 1);
+ assert(*next(mo.begin()) == 2);
+ assert(*next(mo.begin(), 2) == 3);
+}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/copy_assign.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/copy_assign.pass.cpp
new file mode 100644
index 00000000000..7f0f0447625
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.cons/copy_assign.pass.cpp
@@ -0,0 +1,109 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set& operator=(const set& s);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+ std::set<int, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+ m = mo;
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+
+ assert(mo.get_allocator() == A(2));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == 1);
+ assert(*next(mo.begin()) == 2);
+ assert(*next(mo.begin(), 2) == 3);
+ }
+ {
+ typedef int V;
+ const V ar[] =
+ {
+ 1,
+ 2,
+ 3
+ };
+ std::set<int> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ std::set<int> *p = &m;
+ m = *p;
+
+ assert(m.size() == 3);
+ assert(std::equal(m.begin(), m.end(), ar));
+ }
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef other_allocator<V> A;
+ std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(2));
+ std::set<int, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0])/2, C(3), A(7));
+ m = mo;
+ assert(m.get_allocator() == A(2));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+
+ assert(mo.get_allocator() == A(2));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 3);
+ assert(distance(mo.begin(), mo.end()) == 3);
+ assert(*mo.begin() == 1);
+ assert(*next(mo.begin()) == 2);
+ assert(*next(mo.begin(), 2) == 3);
+ }
+}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/default.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/default.pass.cpp
new file mode 100644
index 00000000000..746a2d17307
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.cons/default.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set();
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::set<int> m;
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::set<int, std::less<int>, min_allocator<int>> m;
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+ {
+ std::set<int> m = {};
+ assert(m.empty());
+ assert(m.begin() == m.end());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp
new file mode 100644
index 00000000000..4d5754a9e6b
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// set()
+// noexcept(
+// is_nothrow_default_constructible<allocator_type>::value &&
+// is_nothrow_default_constructible<key_compare>::value &&
+// is_nothrow_copy_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp();
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::set<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 00000000000..25f5425c75a
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// ~set() // implied noexcept;
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ ~some_comp() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::set<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/initializer_list.pass.cpp
new file mode 100644
index 00000000000..2ad538e143f
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.cons/initializer_list.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::set<int> C;
+ typedef C::value_type V;
+ C m = {1, 2, 3, 4, 5, 6};
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> C;
+ typedef C::value_type V;
+ C m = {1, 2, 3, 4, 5, 6};
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/initializer_list_compare.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/initializer_list_compare.pass.cpp
new file mode 100644
index 00000000000..a0afa02cf74
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.cons/initializer_list_compare.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(initializer_list<value_type> il, const key_compare& comp = key_compare());
+
+#include <set>
+#include <cassert>
+#include "../../../test_compare.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ typedef test_compare<std::less<int> > Cmp;
+ typedef std::set<int, Cmp> C;
+ typedef C::value_type V;
+ C m({1, 2, 3, 4, 5, 6}, Cmp(10));
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ assert(m.key_comp() == Cmp(10));
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/initializer_list_compare_alloc.pass.cpp
new file mode 100644
index 00000000000..821820a1e0c
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.cons/initializer_list_compare_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
+// set(initializer_list<value_type> il, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef test_compare<std::less<int> > Cmp;
+ typedef test_allocator<int> A;
+ typedef std::set<int, Cmp, A> C;
+ typedef C::value_type V;
+ C m({1, 2, 3, 4, 5, 6}, Cmp(10), A(4));
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ assert(m.key_comp() == Cmp(10));
+ assert(m.get_allocator() == A(4));
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef test_compare<std::less<int> > Cmp;
+ typedef test_allocator<int> A;
+ typedef std::set<int, Cmp, A> C;
+ typedef C::value_type V;
+ C m({1, 2, 3, 4, 5, 6}, A(4));
+ assert(m.size() == 6);
+ assert(distance(m.begin(), m.end()) == 6);
+ C::const_iterator i = m.cbegin();
+ assert(*i == V(1));
+ assert(*++i == V(2));
+ assert(*++i == V(3));
+ assert(*++i == V(4));
+ assert(*++i == V(5));
+ assert(*++i == V(6));
+ assert(m.get_allocator() == A(4));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/iter_iter.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/iter_iter.pass.cpp
new file mode 100644
index 00000000000..7ca7fe14d6c
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.cons/iter_iter.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class InputIterator>
+// set(InputIterator first, InputIterator last);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ std::set<V> m(input_iterator<const int*>(ar),
+ input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ std::set<V, std::less<int>, min_allocator<int>> m(input_iterator<const int*>(ar),
+ input_iterator<const int*>(ar+sizeof(ar)/sizeof(ar[0])));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp
new file mode 100644
index 00000000000..5ccb6e5cbcd
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.cons/iter_iter_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class InputIterator>
+// set(InputIterator first, InputIterator last,
+// const value_compare& comp, const allocator_type& a);
+//
+// template <class InputIterator>
+// set(InputIterator first, InputIterator last,
+// const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<V> > C;
+ typedef test_allocator<V> A;
+ std::set<V, C, A> m(input_iterator<const V*>(ar),
+ input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])),
+ C(5), A(7));
+ assert(m.value_comp() == C(5));
+ assert(m.get_allocator() == A(7));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ A a(7);
+ std::set<V, C, A> m(ar, ar+sizeof(ar)/sizeof(ar[0]), a);
+
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+ assert(m.get_allocator() == a);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/iter_iter_comp.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/iter_iter_comp.pass.cpp
new file mode 100644
index 00000000000..18bc0839003
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.cons/iter_iter_comp.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// template <class InputIterator>
+// set(InputIterator first, InputIterator last, const value_compare& comp);
+
+#include <set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+
+int main()
+{
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<V> > C;
+ std::set<V, C> m(input_iterator<const V*>(ar),
+ input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])), C(5));
+ assert(m.value_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/move.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/move.pass.cpp
new file mode 100644
index 00000000000..4026ec70c3e
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.cons/move.pass.cpp
@@ -0,0 +1,107 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(set&& s);
+
+#include <set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef int V;
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::set<int, C, A> mo(C(5), A(7));
+ std::set<int, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 0);
+ assert(distance(m.begin(), m.end()) == 0);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef test_allocator<V> A;
+ std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A(7));
+ std::set<int, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A(7));
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+
+ assert(mo.get_allocator() == A(7));
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ V ar[] =
+ {
+ 1,
+ 1,
+ 1,
+ 2,
+ 2,
+ 2,
+ 3,
+ 3,
+ 3
+ };
+ typedef test_compare<std::less<int> > C;
+ typedef min_allocator<V> A;
+ std::set<int, C, A> mo(ar, ar+sizeof(ar)/sizeof(ar[0]), C(5), A());
+ std::set<int, C, A> m = std::move(mo);
+ assert(m.get_allocator() == A());
+ assert(m.key_comp() == C(5));
+ assert(m.size() == 3);
+ assert(distance(m.begin(), m.end()) == 3);
+ assert(*m.begin() == 1);
+ assert(*next(m.begin()) == 2);
+ assert(*next(m.begin(), 2) == 3);
+
+ assert(mo.get_allocator() == A());
+ assert(mo.key_comp() == C(5));
+ assert(mo.size() == 0);
+ assert(distance(mo.begin(), mo.end()) == 0);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
new file mode 100644
index 00000000000..c4617f0b481
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp
@@ -0,0 +1,141 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set(set&& s, const allocator_type& a);
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<V> A;
+ typedef std::set<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(7));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<V> A;
+ typedef std::set<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(5));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef other_allocator<V> A;
+ typedef std::set<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(std::move(m1), A(5));
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/move_assign.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/move_assign.pass.cpp
new file mode 100644
index 00000000000..4e08f014ebe
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.cons/move_assign.pass.cpp
@@ -0,0 +1,186 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// set& operator=(set&& s);
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "../../../test_compare.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<V> A;
+ typedef std::set<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(7));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef test_allocator<V> A;
+ typedef std::set<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(5));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(5));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef other_allocator<V> A;
+ typedef std::set<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A(7));
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A(7));
+ M m3(C(3), A(5));
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A(7));
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef MoveOnly V;
+ typedef test_compare<std::less<MoveOnly> > C;
+ typedef min_allocator<V> A;
+ typedef std::set<MoveOnly, C, A> M;
+ typedef std::move_iterator<V*> I;
+ V a1[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m1(I(a1), I(a1+sizeof(a1)/sizeof(a1[0])), C(5), A());
+ V a2[] =
+ {
+ V(1),
+ V(1),
+ V(1),
+ V(2),
+ V(2),
+ V(2),
+ V(3),
+ V(3),
+ V(3)
+ };
+ M m2(I(a2), I(a2+sizeof(a2)/sizeof(a2[0])), C(5), A());
+ M m3(C(3), A());
+ m3 = std::move(m1);
+ assert(m3 == m2);
+ assert(m3.get_allocator() == A());
+ assert(m3.key_comp() == C(5));
+ assert(m1.empty());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 00000000000..17ea74036db
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,53 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// set& operator=(set&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value &&
+// is_nothrow_move_assignable<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp& operator=(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::set<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp b/libcxx/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp
new file mode 100644
index 00000000000..7a8ae7bf2b5
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp
@@ -0,0 +1,51 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// set(set&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+// is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp(const some_comp&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::set<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::set<MoveOnly, some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/set.special/member_swap.pass.cpp b/libcxx/test/std/containers/associative/set/set.special/member_swap.pass.cpp
new file mode 100644
index 00000000000..f72abd7eb4a
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.special/member_swap.pass.cpp
@@ -0,0 +1,201 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// void swap(set& m);
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::set<int> M;
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ m1.swap(m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/set.special/non_member_swap.pass.cpp b/libcxx/test/std/containers/associative/set/set.special/non_member_swap.pass.cpp
new file mode 100644
index 00000000000..c9cffc68a12
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.special/non_member_swap.pass.cpp
@@ -0,0 +1,177 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// void swap(set& m);
+
+#include <set>
+#include <cassert>
+#include "test_allocator.h"
+#include "../../../test_compare.h"
+
+int main()
+{
+ typedef int V;
+ typedef std::set<int> M;
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ }
+ {
+ typedef test_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::set<int, C, A> M;
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ assert(m1.key_comp() == C(2));
+ assert(m1.get_allocator() == A(1));
+ assert(m2.key_comp() == C(1));
+ assert(m2.get_allocator() == A(2));
+ }
+ {
+ typedef other_allocator<V> A;
+ typedef test_compare<std::less<int> > C;
+ typedef std::set<int, C, A> M;
+ V ar1[] =
+ {
+ 1,
+ 2,
+ 3,
+ 4
+ };
+ V ar2[] =
+ {
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12
+ };
+ M m1(ar1, ar1+sizeof(ar1)/sizeof(ar1[0]), C(1), A(1));
+ M m2(ar2, ar2+sizeof(ar2)/sizeof(ar2[0]), C(2), A(2));
+ M m1_save = m1;
+ M m2_save = m2;
+ swap(m1, m2);
+ assert(m1 == m2_save);
+ assert(m2 == m1_save);
+ assert(m1.key_comp() == C(2));
+ assert(m1.get_allocator() == A(2));
+ assert(m2.key_comp() == C(1));
+ assert(m2.get_allocator() == A(1));
+ }
+}
diff --git a/libcxx/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp
new file mode 100644
index 00000000000..c4f169aa512
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/set.special/swap_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// void swap(set& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+
+ some_comp() {}
+ some_comp(const some_comp&) {}
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::set<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::set<MoveOnly, some_comp<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/size.pass.cpp b/libcxx/test/std/containers/associative/set/size.pass.cpp
new file mode 100644
index 00000000000..e7865473550
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// size_type size() const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::set<int> M;
+ M m;
+ assert(m.size() == 0);
+ m.insert(M::value_type(2));
+ assert(m.size() == 1);
+ m.insert(M::value_type(1));
+ assert(m.size() == 2);
+ m.insert(M::value_type(3));
+ assert(m.size() == 3);
+ m.erase(m.begin());
+ assert(m.size() == 2);
+ m.erase(m.begin());
+ assert(m.size() == 1);
+ m.erase(m.begin());
+ assert(m.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ M m;
+ assert(m.size() == 0);
+ m.insert(M::value_type(2));
+ assert(m.size() == 1);
+ m.insert(M::value_type(1));
+ assert(m.size() == 2);
+ m.insert(M::value_type(3));
+ assert(m.size() == 3);
+ m.erase(m.begin());
+ assert(m.size() == 2);
+ m.erase(m.begin());
+ assert(m.size() == 1);
+ m.erase(m.begin());
+ assert(m.size() == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/types.pass.cpp b/libcxx/test/std/containers/associative/set/types.pass.cpp
new file mode 100644
index 00000000000..3362c42aee4
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/types.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// template <class Key, class Compare = less<Key>,
+// class Allocator = allocator<Key>>
+// class set
+// {
+// public:
+// // types:
+// typedef Key key_type;
+// typedef key_type value_type;
+// typedef Compare key_compare;
+// typedef key_compare value_compare;
+// typedef Allocator allocator_type;
+// typedef typename allocator_type::reference reference;
+// typedef typename allocator_type::const_reference const_reference;
+// typedef typename allocator_type::pointer pointer;
+// typedef typename allocator_type::const_pointer const_pointer;
+// typedef typename allocator_type::size_type size_type;
+// typedef typename allocator_type::difference_type difference_type;
+// ...
+// };
+
+#include <set>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::set<int> C;
+ static_assert((std::is_same<C::key_type, int>::value), "");
+ static_assert((std::is_same<C::value_type, int>::value), "");
+ static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::value_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::allocator_type, std::allocator<int> >::value), "");
+ static_assert((std::is_same<C::reference, int&>::value), "");
+ static_assert((std::is_same<C::const_reference, const int&>::value), "");
+ static_assert((std::is_same<C::pointer, int*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const int*>::value), "");
+ static_assert((std::is_same<C::size_type, std::size_t>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::set<int, std::less<int>, min_allocator<int>> C;
+ static_assert((std::is_same<C::key_type, int>::value), "");
+ static_assert((std::is_same<C::value_type, int>::value), "");
+ static_assert((std::is_same<C::key_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::value_compare, std::less<int> >::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<int> >::value), "");
+ static_assert((std::is_same<C::reference, int&>::value), "");
+ static_assert((std::is_same<C::const_reference, const int&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<int>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const int>>::value), "");
+// min_allocator doesn't have a size_type, so one gets synthesized
+ static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), "");
+ static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/upper_bound.pass.cpp b/libcxx/test/std/containers/associative/set/upper_bound.pass.cpp
new file mode 100644
index 00000000000..10a28f06469
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/upper_bound.pass.cpp
@@ -0,0 +1,336 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+// class set
+
+// iterator upper_bound(const key_type& k);
+// const_iterator upper_bound(const key_type& k) const;
+
+#include <set>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "private_constructor.hpp"
+
+int main()
+{
+ {
+ typedef int V;
+ typedef std::set<int> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int V;
+ typedef std::set<int, std::less<int>, min_allocator<int>> M;
+ {
+ typedef M::iterator R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ {
+ typedef M::const_iterator R;
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ const M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int V;
+ typedef std::set<V, std::less<>> M;
+ typedef M::iterator R;
+
+ V ar[] =
+ {
+ 5,
+ 7,
+ 9,
+ 11,
+ 13,
+ 15,
+ 17,
+ 19
+ };
+ M m(ar, ar+sizeof(ar)/sizeof(ar[0]));
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+
+ {
+ typedef PrivateConstructor V;
+ typedef std::set<V, std::less<>> M;
+ typedef M::iterator R;
+
+ M m;
+ m.insert ( V::make ( 5 ));
+ m.insert ( V::make ( 7 ));
+ m.insert ( V::make ( 9 ));
+ m.insert ( V::make ( 11 ));
+ m.insert ( V::make ( 13 ));
+ m.insert ( V::make ( 15 ));
+ m.insert ( V::make ( 17 ));
+ m.insert ( V::make ( 19 ));
+
+ R r = m.upper_bound(5);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(7);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(9);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(11);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(13);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(15);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(17);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(19);
+ assert(r == next(m.begin(), 8));
+ r = m.upper_bound(4);
+ assert(r == next(m.begin(), 0));
+ r = m.upper_bound(6);
+ assert(r == next(m.begin(), 1));
+ r = m.upper_bound(8);
+ assert(r == next(m.begin(), 2));
+ r = m.upper_bound(10);
+ assert(r == next(m.begin(), 3));
+ r = m.upper_bound(12);
+ assert(r == next(m.begin(), 4));
+ r = m.upper_bound(14);
+ assert(r == next(m.begin(), 5));
+ r = m.upper_bound(16);
+ assert(r == next(m.begin(), 6));
+ r = m.upper_bound(18);
+ assert(r == next(m.begin(), 7));
+ r = m.upper_bound(20);
+ assert(r == next(m.begin(), 8));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/associative/set/version.pass.cpp b/libcxx/test/std/containers/associative/set/version.pass.cpp
new file mode 100644
index 00000000000..c3c4d926e5c
--- /dev/null
+++ b/libcxx/test/std/containers/associative/set/version.pass.cpp
@@ -0,0 +1,20 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <set>
+
+#include <set>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/associative/tree_balance_after_insert.pass.cpp b/libcxx/test/std/containers/associative/tree_balance_after_insert.pass.cpp
new file mode 100644
index 00000000000..b0a3e74cab0
--- /dev/null
+++ b/libcxx/test/std/containers/associative/tree_balance_after_insert.pass.cpp
@@ -0,0 +1,1616 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// Not a portable test
+
+// Precondition: __root->__is_black_ == true
+// template <class _NodePtr>
+// void
+// __tree_balance_after_insert(_NodePtr __root, _NodePtr __x)
+
+#include <__tree>
+#include <cassert>
+
+struct Node
+{
+ Node* __left_;
+ Node* __right_;
+ Node* __parent_;
+ bool __is_black_;
+
+ Node() : __left_(), __right_(), __parent_(), __is_black_() {}
+};
+
+void
+test1()
+{
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = &a;
+ b.__right_ = 0;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = 0;
+ d.__right_ = 0;
+ d.__is_black_ = false;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = 0;
+ b.__right_ = &a;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = 0;
+ d.__right_ = 0;
+ d.__is_black_ = false;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == &a);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = 0;
+ b.__right_ = 0;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = &a;
+ d.__right_ = 0;
+ d.__is_black_ = false;
+
+ a.__parent_ = &d;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == &a);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &d);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = 0;
+ b.__right_ = 0;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = 0;
+ d.__right_ = &a;
+ d.__is_black_ = false;
+
+ a.__parent_ = &d;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == &a);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &d);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+ Node i;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = &a;
+ b.__right_ = &g;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = &h;
+ d.__right_ = &i;
+ d.__is_black_ = false;
+
+ a.__parent_ = &b;
+ a.__left_ = &e;
+ a.__right_ = &f;
+ a.__is_black_ = false;
+
+ e.__parent_ = &a;
+ e.__is_black_ = true;
+
+ f.__parent_ = &a;
+ f.__is_black_ = true;
+
+ g.__parent_ = &b;
+ g.__is_black_ = true;
+
+ h.__parent_ = &d;
+ h.__is_black_ = true;
+
+ i.__parent_ = &d;
+ i.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &g);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == &h);
+ assert(d.__right_ == &i);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == &e);
+ assert(a.__right_ == &f);
+ assert(a.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+ Node i;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = &g;
+ b.__right_ = &a;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = &h;
+ d.__right_ = &i;
+ d.__is_black_ = false;
+
+ a.__parent_ = &b;
+ a.__left_ = &e;
+ a.__right_ = &f;
+ a.__is_black_ = false;
+
+ e.__parent_ = &a;
+ e.__is_black_ = true;
+
+ f.__parent_ = &a;
+ f.__is_black_ = true;
+
+ g.__parent_ = &b;
+ g.__is_black_ = true;
+
+ h.__parent_ = &d;
+ h.__is_black_ = true;
+
+ i.__parent_ = &d;
+ i.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &g);
+ assert(b.__right_ == &a);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == &h);
+ assert(d.__right_ == &i);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == &e);
+ assert(a.__right_ == &f);
+ assert(a.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+ Node i;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = &g;
+ b.__right_ = &h;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = &a;
+ d.__right_ = &i;
+ d.__is_black_ = false;
+
+ a.__parent_ = &d;
+ a.__left_ = &e;
+ a.__right_ = &f;
+ a.__is_black_ = false;
+
+ e.__parent_ = &a;
+ e.__is_black_ = true;
+
+ f.__parent_ = &a;
+ f.__is_black_ = true;
+
+ g.__parent_ = &b;
+ g.__is_black_ = true;
+
+ h.__parent_ = &b;
+ h.__is_black_ = true;
+
+ i.__parent_ = &d;
+ i.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &g);
+ assert(b.__right_ == &h);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == &a);
+ assert(d.__right_ == &i);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &d);
+ assert(a.__left_ == &e);
+ assert(a.__right_ == &f);
+ assert(a.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+ Node i;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = &g;
+ b.__right_ = &h;
+ b.__is_black_ = false;
+
+ d.__parent_ = &c;
+ d.__left_ = &i;
+ d.__right_ = &a;
+ d.__is_black_ = false;
+
+ a.__parent_ = &d;
+ a.__left_ = &e;
+ a.__right_ = &f;
+ a.__is_black_ = false;
+
+ e.__parent_ = &a;
+ e.__is_black_ = true;
+
+ f.__parent_ = &a;
+ f.__is_black_ = true;
+
+ g.__parent_ = &b;
+ g.__is_black_ = true;
+
+ h.__parent_ = &b;
+ h.__is_black_ = true;
+
+ i.__parent_ = &d;
+ i.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &c);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &g);
+ assert(b.__right_ == &h);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == &i);
+ assert(d.__right_ == &a);
+ assert(d.__is_black_ == true);
+
+ assert(a.__parent_ == &d);
+ assert(a.__left_ == &e);
+ assert(a.__right_ == &f);
+ assert(a.__is_black_ == false);
+ }
+}
+
+void
+test2()
+{
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &a;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ a.__parent_ = &c;
+ a.__left_ = 0;
+ a.__right_ = &b;
+ a.__is_black_ = false;
+
+ b.__parent_ = &a;
+ b.__left_ = 0;
+ b.__right_ = 0;
+ b.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &a;
+
+ a.__parent_ = &root;
+ a.__left_ = 0;
+ a.__right_ = &c;
+ a.__is_black_ = true;
+
+ c.__parent_ = &a;
+ c.__left_ = &b;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ b.__parent_ = &c;
+ b.__left_ = 0;
+ b.__right_ = 0;
+ b.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &a;
+ c.__right_ = &g;
+ c.__is_black_ = true;
+
+ a.__parent_ = &c;
+ a.__left_ = &d;
+ a.__right_ = &b;
+ a.__is_black_ = false;
+
+ b.__parent_ = &a;
+ b.__left_ = &e;
+ b.__right_ = &f;
+ b.__is_black_ = false;
+
+ d.__parent_ = &a;
+ d.__is_black_ = true;
+
+ e.__parent_ = &b;
+ e.__is_black_ = true;
+
+ f.__parent_ = &b;
+ f.__is_black_ = true;
+
+ g.__parent_ = &c;
+ g.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == &f);
+ assert(c.__right_ == &g);
+ assert(c.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == &d);
+ assert(a.__right_ == &e);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &a);
+ assert(d.__is_black_ == true);
+
+ assert(e.__parent_ == &a);
+ assert(e.__is_black_ == true);
+
+ assert(f.__parent_ == &c);
+ assert(f.__is_black_ == true);
+
+ assert(g.__parent_ == &c);
+ assert(g.__is_black_ == true);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+
+ root.__left_ = &a;
+
+ a.__parent_ = &root;
+ a.__left_ = &d;
+ a.__right_ = &c;
+ a.__is_black_ = true;
+
+ c.__parent_ = &a;
+ c.__left_ = &b;
+ c.__right_ = &g;
+ c.__is_black_ = false;
+
+ b.__parent_ = &c;
+ b.__left_ = &e;
+ b.__right_ = &f;
+ b.__is_black_ = false;
+
+ d.__parent_ = &a;
+ d.__is_black_ = true;
+
+ e.__parent_ = &b;
+ e.__is_black_ = true;
+
+ f.__parent_ = &b;
+ f.__is_black_ = true;
+
+ g.__parent_ = &c;
+ g.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == &f);
+ assert(c.__right_ == &g);
+ assert(c.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == &d);
+ assert(a.__right_ == &e);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &a);
+ assert(d.__is_black_ == true);
+
+ assert(e.__parent_ == &a);
+ assert(e.__is_black_ == true);
+
+ assert(f.__parent_ == &c);
+ assert(f.__is_black_ == true);
+
+ assert(g.__parent_ == &c);
+ assert(g.__is_black_ == true);
+ }
+}
+
+void
+test3()
+{
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = &a;
+ b.__right_ = 0;
+ b.__is_black_ = false;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &a;
+
+ a.__parent_ = &root;
+ a.__left_ = 0;
+ a.__right_ = &b;
+ a.__is_black_ = true;
+
+ b.__parent_ = &a;
+ b.__left_ = 0;
+ b.__right_ = &c;
+ b.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ std::__tree_balance_after_insert(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+
+ root.__left_ = &c;
+
+ c.__parent_ = &root;
+ c.__left_ = &b;
+ c.__right_ = &g;
+ c.__is_black_ = true;
+
+ b.__parent_ = &c;
+ b.__left_ = &a;
+ b.__right_ = &f;
+ b.__is_black_ = false;
+
+ a.__parent_ = &b;
+ a.__left_ = &d;
+ a.__right_ = &e;
+ a.__is_black_ = false;
+
+ d.__parent_ = &a;
+ d.__is_black_ = true;
+
+ e.__parent_ = &a;
+ e.__is_black_ = true;
+
+ f.__parent_ = &b;
+ f.__is_black_ = true;
+
+ g.__parent_ = &c;
+ g.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == &f);
+ assert(c.__right_ == &g);
+ assert(c.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == &d);
+ assert(a.__right_ == &e);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &a);
+ assert(d.__is_black_ == true);
+
+ assert(e.__parent_ == &a);
+ assert(e.__is_black_ == true);
+
+ assert(f.__parent_ == &c);
+ assert(f.__is_black_ == true);
+
+ assert(g.__parent_ == &c);
+ assert(g.__is_black_ == true);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+
+ root.__left_ = &a;
+
+ a.__parent_ = &root;
+ a.__left_ = &d;
+ a.__right_ = &b;
+ a.__is_black_ = true;
+
+ b.__parent_ = &a;
+ b.__left_ = &e;
+ b.__right_ = &c;
+ b.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = &f;
+ c.__right_ = &g;
+ c.__is_black_ = false;
+
+ d.__parent_ = &a;
+ d.__is_black_ = true;
+
+ e.__parent_ = &b;
+ e.__is_black_ = true;
+
+ f.__parent_ = &c;
+ f.__is_black_ = true;
+
+ g.__parent_ = &c;
+ g.__is_black_ = true;
+
+ std::__tree_balance_after_insert(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__left_ == &b);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == &f);
+ assert(c.__right_ == &g);
+ assert(c.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == &d);
+ assert(a.__right_ == &e);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(d.__parent_ == &a);
+ assert(d.__is_black_ == true);
+
+ assert(e.__parent_ == &a);
+ assert(e.__is_black_ == true);
+
+ assert(f.__parent_ == &c);
+ assert(f.__is_black_ == true);
+
+ assert(g.__parent_ == &c);
+ assert(g.__is_black_ == true);
+ }
+}
+
+void
+test4()
+{
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+
+ root.__left_ = &a;
+ a.__parent_ = &root;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &a);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &root);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ a.__right_ = &b;
+ b.__parent_ = &a;
+
+ std::__tree_balance_after_insert(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &a);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &root);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == &b);
+ assert(a.__is_black_ == true);
+
+ assert(b.__parent_ == &a);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == false);
+
+ b.__right_ = &c;
+ c.__parent_ = &b;
+
+ std::__tree_balance_after_insert(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ c.__right_ = &d;
+ d.__parent_ = &c;
+
+ std::__tree_balance_after_insert(root.__left_, &d);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == false);
+
+ d.__right_ = &e;
+ e.__parent_ = &d;
+
+ std::__tree_balance_after_insert(root.__left_, &e);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &d);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ assert(d.__parent_ == &b);
+ assert(d.__left_ == &c);
+ assert(d.__right_ == &e);
+ assert(d.__is_black_ == true);
+
+ assert(c.__parent_ == &d);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(e.__parent_ == &d);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == false);
+
+ e.__right_ = &f;
+ f.__parent_ = &e;
+
+ std::__tree_balance_after_insert(root.__left_, &f);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &d);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ assert(d.__parent_ == &b);
+ assert(d.__left_ == &c);
+ assert(d.__right_ == &e);
+ assert(d.__is_black_ == false);
+
+ assert(c.__parent_ == &d);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ assert(e.__parent_ == &d);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == &f);
+ assert(e.__is_black_ == true);
+
+ assert(f.__parent_ == &e);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == false);
+
+ f.__right_ = &g;
+ g.__parent_ = &f;
+
+ std::__tree_balance_after_insert(root.__left_, &g);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &d);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ assert(d.__parent_ == &b);
+ assert(d.__left_ == &c);
+ assert(d.__right_ == &f);
+ assert(d.__is_black_ == false);
+
+ assert(c.__parent_ == &d);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ assert(f.__parent_ == &d);
+ assert(f.__left_ == &e);
+ assert(f.__right_ == &g);
+ assert(f.__is_black_ == true);
+
+ assert(e.__parent_ == &f);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == false);
+
+ assert(g.__parent_ == &f);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == 0);
+ assert(g.__is_black_ == false);
+
+ g.__right_ = &h;
+ h.__parent_ = &g;
+
+ std::__tree_balance_after_insert(root.__left_, &h);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &d);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(d.__parent_ == &root);
+ assert(d.__left_ == &b);
+ assert(d.__right_ == &f);
+ assert(d.__is_black_ == true);
+
+ assert(b.__parent_ == &d);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ assert(f.__parent_ == &d);
+ assert(f.__left_ == &e);
+ assert(f.__right_ == &g);
+ assert(f.__is_black_ == false);
+
+ assert(e.__parent_ == &f);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == true);
+
+ assert(g.__parent_ == &f);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == false);
+}
+
+void
+test5()
+{
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+
+ root.__left_ = &h;
+ h.__parent_ = &root;
+
+ std::__tree_balance_after_insert(root.__left_, &h);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &h);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(h.__parent_ == &root);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ h.__left_ = &g;
+ g.__parent_ = &h;
+
+ std::__tree_balance_after_insert(root.__left_, &g);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &h);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(h.__parent_ == &root);
+ assert(h.__left_ == &g);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ assert(g.__parent_ == &h);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == 0);
+ assert(g.__is_black_ == false);
+
+ g.__left_ = &f;
+ f.__parent_ = &g;
+
+ std::__tree_balance_after_insert(root.__left_, &f);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &g);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(g.__parent_ == &root);
+ assert(g.__left_ == &f);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(f.__parent_ == &g);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == false);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == false);
+
+ f.__left_ = &e;
+ e.__parent_ = &f;
+
+ std::__tree_balance_after_insert(root.__left_, &e);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &g);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(g.__parent_ == &root);
+ assert(g.__left_ == &f);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(f.__parent_ == &g);
+ assert(f.__left_ == &e);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == true);
+
+ assert(e.__parent_ == &f);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == false);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ e.__left_ = &d;
+ d.__parent_ = &e;
+
+ std::__tree_balance_after_insert(root.__left_, &d);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &g);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(g.__parent_ == &root);
+ assert(g.__left_ == &e);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(e.__parent_ == &g);
+ assert(e.__left_ == &d);
+ assert(e.__right_ == &f);
+ assert(e.__is_black_ == true);
+
+ assert(d.__parent_ == &e);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == false);
+
+ assert(f.__parent_ == &e);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == false);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ d.__left_ = &c;
+ c.__parent_ = &d;
+
+ std::__tree_balance_after_insert(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &g);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(g.__parent_ == &root);
+ assert(g.__left_ == &e);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(e.__parent_ == &g);
+ assert(e.__left_ == &d);
+ assert(e.__right_ == &f);
+ assert(e.__is_black_ == false);
+
+ assert(d.__parent_ == &e);
+ assert(d.__left_ == &c);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ assert(c.__parent_ == &d);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(f.__parent_ == &e);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ c.__left_ = &b;
+ b.__parent_ = &c;
+
+ std::__tree_balance_after_insert(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &g);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(g.__parent_ == &root);
+ assert(g.__left_ == &e);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(e.__parent_ == &g);
+ assert(e.__left_ == &c);
+ assert(e.__right_ == &f);
+ assert(e.__is_black_ == false);
+
+ assert(c.__parent_ == &e);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == false);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == false);
+
+ assert(f.__parent_ == &e);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ b.__left_ = &a;
+ a.__parent_ = &b;
+
+ std::__tree_balance_after_insert(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &e);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(e.__parent_ == &root);
+ assert(e.__left_ == &c);
+ assert(e.__right_ == &g);
+ assert(e.__is_black_ == true);
+
+ assert(c.__parent_ == &e);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == false);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ assert(g.__parent_ == &e);
+ assert(g.__left_ == &f);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == false);
+
+ assert(f.__parent_ == &g);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+}
+
+int main()
+{
+ test1();
+ test2();
+ test3();
+ test4();
+ test5();
+}
diff --git a/libcxx/test/std/containers/associative/tree_left_rotate.pass.cpp b/libcxx/test/std/containers/associative/tree_left_rotate.pass.cpp
new file mode 100644
index 00000000000..774cbc68798
--- /dev/null
+++ b/libcxx/test/std/containers/associative/tree_left_rotate.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// Not a portable test
+
+// Precondition: __x->__right_ != nullptr
+// template <class _NodePtr>
+// void
+// __tree_left_rotate(_NodePtr __x);
+
+#include <__tree>
+#include <cassert>
+
+struct Node
+{
+ Node* __left_;
+ Node* __right_;
+ Node* __parent_;
+
+ Node() : __left_(), __right_(), __parent_() {}
+};
+
+void
+test1()
+{
+ Node root;
+ Node x;
+ Node y;
+ root.__left_ = &x;
+ x.__left_ = 0;
+ x.__right_ = &y;
+ x.__parent_ = &root;
+ y.__left_ = 0;
+ y.__right_ = 0;
+ y.__parent_ = &x;
+ std::__tree_left_rotate(&x);
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &y);
+ assert(root.__right_ == 0);
+ assert(y.__parent_ == &root);
+ assert(y.__left_ == &x);
+ assert(y.__right_ == 0);
+ assert(x.__parent_ == &y);
+ assert(x.__left_ == 0);
+ assert(x.__right_ == 0);
+}
+
+void
+test2()
+{
+ Node root;
+ Node x;
+ Node y;
+ Node a;
+ Node b;
+ Node c;
+ root.__left_ = &x;
+ x.__left_ = &a;
+ x.__right_ = &y;
+ x.__parent_ = &root;
+ y.__left_ = &b;
+ y.__right_ = &c;
+ y.__parent_ = &x;
+ a.__parent_ = &x;
+ b.__parent_ = &y;
+ c.__parent_ = &y;
+ std::__tree_left_rotate(&x);
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &y);
+ assert(root.__right_ == 0);
+ assert(y.__parent_ == &root);
+ assert(y.__left_ == &x);
+ assert(y.__right_ == &c);
+ assert(x.__parent_ == &y);
+ assert(x.__left_ == &a);
+ assert(x.__right_ == &b);
+ assert(a.__parent_ == &x);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(b.__parent_ == &x);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(c.__parent_ == &y);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
diff --git a/libcxx/test/std/containers/associative/tree_remove.pass.cpp b/libcxx/test/std/containers/associative/tree_remove.pass.cpp
new file mode 100644
index 00000000000..fb14bd929e9
--- /dev/null
+++ b/libcxx/test/std/containers/associative/tree_remove.pass.cpp
@@ -0,0 +1,1648 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// Not a portable test
+
+// Returns __tree_next(__z)
+// template <class _NodePtr>
+// void
+// __tree_remove(_NodePtr __root, _NodePtr __z)
+
+#include <__tree>
+#include <cassert>
+
+struct Node
+{
+ Node* __left_;
+ Node* __right_;
+ Node* __parent_;
+ bool __is_black_;
+
+ Node() : __left_(), __right_(), __parent_(), __is_black_() {}
+};
+
+void
+test1()
+{
+ {
+ // Left
+ // Case 1 -> Case 2 -> x is red turned to black
+ Node root;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node y;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &y;
+ b.__right_ = &d;
+ b.__is_black_ = true;
+
+ y.__parent_ = &b;
+ y.__left_ = 0;
+ y.__right_ = 0;
+ y.__is_black_ = true;
+
+ d.__parent_ = &b;
+ d.__left_ = &c;
+ d.__right_ = &e;
+ d.__is_black_ = false;
+
+ c.__parent_ = &d;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ e.__parent_ = &d;
+ e.__left_ = 0;
+ e.__right_ = 0;
+ e.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &y);
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &d);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(d.__parent_ == &root);
+ assert(d.__left_ == &b);
+ assert(d.__right_ == &e);
+ assert(d.__is_black_ == true);
+
+ assert(b.__parent_ == &d);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(e.__parent_ == &d);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == true);
+ }
+ {
+ // Right
+ // Case 1 -> Case 2 -> x is red turned to black
+ Node root;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node y;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__right_ = &y;
+ b.__left_ = &d;
+ b.__is_black_ = true;
+
+ y.__parent_ = &b;
+ y.__right_ = 0;
+ y.__left_ = 0;
+ y.__is_black_ = true;
+
+ d.__parent_ = &b;
+ d.__right_ = &c;
+ d.__left_ = &e;
+ d.__is_black_ = false;
+
+ c.__parent_ = &d;
+ c.__right_ = 0;
+ c.__left_ = 0;
+ c.__is_black_ = true;
+
+ e.__parent_ = &d;
+ e.__right_ = 0;
+ e.__left_ = 0;
+ e.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &y);
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &d);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(d.__parent_ == &root);
+ assert(d.__right_ == &b);
+ assert(d.__left_ == &e);
+ assert(d.__is_black_ == true);
+
+ assert(b.__parent_ == &d);
+ assert(b.__right_ == 0);
+ assert(b.__left_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__right_ == 0);
+ assert(c.__left_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(e.__parent_ == &d);
+ assert(e.__right_ == 0);
+ assert(e.__left_ == 0);
+ assert(e.__is_black_ == true);
+ }
+ {
+ // Left
+ // Case 1 -> Case 3 -> Case 4
+ Node root;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node y;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &y;
+ b.__right_ = &d;
+ b.__is_black_ = true;
+
+ y.__parent_ = &b;
+ y.__left_ = 0;
+ y.__right_ = 0;
+ y.__is_black_ = true;
+
+ d.__parent_ = &b;
+ d.__left_ = &c;
+ d.__right_ = &e;
+ d.__is_black_ = false;
+
+ c.__parent_ = &d;
+ c.__left_ = &f;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ e.__parent_ = &d;
+ e.__left_ = 0;
+ e.__right_ = 0;
+ e.__is_black_ = true;
+
+ f.__parent_ = &c;
+ f.__left_ = 0;
+ f.__right_ = 0;
+ f.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &y);
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &d);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(d.__parent_ == &root);
+ assert(d.__left_ == &f);
+ assert(d.__right_ == &e);
+ assert(d.__is_black_ == true);
+
+ assert(f.__parent_ == &d);
+ assert(f.__left_ == &b);
+ assert(f.__right_ == &c);
+ assert(f.__is_black_ == false);
+
+ assert(b.__parent_ == &f);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &f);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ assert(e.__parent_ == &d);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == true);
+ }
+ {
+ // Right
+ // Case 1 -> Case 3 -> Case 4
+ Node root;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node y;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__right_ = &y;
+ b.__left_ = &d;
+ b.__is_black_ = true;
+
+ y.__parent_ = &b;
+ y.__right_ = 0;
+ y.__left_ = 0;
+ y.__is_black_ = true;
+
+ d.__parent_ = &b;
+ d.__right_ = &c;
+ d.__left_ = &e;
+ d.__is_black_ = false;
+
+ c.__parent_ = &d;
+ c.__right_ = &f;
+ c.__left_ = 0;
+ c.__is_black_ = true;
+
+ e.__parent_ = &d;
+ e.__right_ = 0;
+ e.__left_ = 0;
+ e.__is_black_ = true;
+
+ f.__parent_ = &c;
+ f.__right_ = 0;
+ f.__left_ = 0;
+ f.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &y);
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &d);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(d.__parent_ == &root);
+ assert(d.__right_ == &f);
+ assert(d.__left_ == &e);
+ assert(d.__is_black_ == true);
+
+ assert(f.__parent_ == &d);
+ assert(f.__right_ == &b);
+ assert(f.__left_ == &c);
+ assert(f.__is_black_ == false);
+
+ assert(b.__parent_ == &f);
+ assert(b.__right_ == 0);
+ assert(b.__left_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &f);
+ assert(c.__right_ == 0);
+ assert(c.__left_ == 0);
+ assert(c.__is_black_ == true);
+
+ assert(e.__parent_ == &d);
+ assert(e.__right_ == 0);
+ assert(e.__left_ == 0);
+ assert(e.__is_black_ == true);
+ }
+}
+
+void
+test2()
+{
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = true;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = true;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = true;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &c);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &a);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &c);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &a);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = true;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &c);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &a);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &a);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &root);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &c);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &a);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &a);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &root);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = true;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &a);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &root);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &a);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &root);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = true;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+ {
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+
+ root.__left_ = &b;
+
+ b.__parent_ = &root;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = false;
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+ }
+}
+
+void
+test3()
+{
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+
+ root.__left_ = &e;
+
+ e.__parent_ = &root;
+ e.__left_ = &c;
+ e.__right_ = &g;
+ e.__is_black_ = true;
+
+ c.__parent_ = &e;
+ c.__left_ = &b;
+ c.__right_ = &d;
+ c.__is_black_ = false;
+
+ g.__parent_ = &e;
+ g.__left_ = &f;
+ g.__right_ = &h;
+ g.__is_black_ = false;
+
+ b.__parent_ = &c;
+ b.__left_ = &a;
+ b.__right_ = 0;
+ b.__is_black_ = true;
+
+ d.__parent_ = &c;
+ d.__left_ = 0;
+ d.__right_ = 0;
+ d.__is_black_ = true;
+
+ f.__parent_ = &g;
+ f.__left_ = 0;
+ f.__right_ = 0;
+ f.__is_black_ = true;
+
+ h.__parent_ = &g;
+ h.__left_ = 0;
+ h.__right_ = 0;
+ h.__is_black_ = true;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = false;
+
+ assert(std::__tree_invariant(root.__left_));
+
+ std::__tree_remove(root.__left_, &h);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &e);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(e.__parent_ == &root);
+ assert(e.__left_ == &c);
+ assert(e.__right_ == &g);
+ assert(e.__is_black_ == true);
+
+ assert(c.__parent_ == &e);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == false);
+
+ assert(g.__parent_ == &e);
+ assert(g.__left_ == &f);
+ assert(g.__right_ == 0);
+ assert(g.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ assert(f.__parent_ == &g);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &g);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &e);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(e.__parent_ == &root);
+ assert(e.__left_ == &c);
+ assert(e.__right_ == &f);
+ assert(e.__is_black_ == true);
+
+ assert(c.__parent_ == &e);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == false);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ assert(f.__parent_ == &e);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &f);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &e);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(e.__parent_ == &c);
+ assert(e.__left_ == &d);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(d.__parent_ == &e);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &e);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &c);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(c.__parent_ == &root);
+ assert(c.__left_ == &b);
+ assert(c.__right_ == &d);
+ assert(c.__is_black_ == true);
+
+ assert(b.__parent_ == &c);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ assert(d.__parent_ == &c);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == 0);
+ assert(d.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &d);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &b);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(b.__parent_ == &root);
+ assert(b.__left_ == &a);
+ assert(b.__right_ == 0);
+ assert(b.__is_black_ == true);
+
+ assert(a.__parent_ == &b);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &a);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(a.__parent_ == &root);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(a.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+}
+
+void
+test4()
+{
+ Node root;
+ Node a;
+ Node b;
+ Node c;
+ Node d;
+ Node e;
+ Node f;
+ Node g;
+ Node h;
+
+ root.__left_ = &d;
+
+ d.__parent_ = &root;
+ d.__left_ = &b;
+ d.__right_ = &f;
+ d.__is_black_ = true;
+
+ b.__parent_ = &d;
+ b.__left_ = &a;
+ b.__right_ = &c;
+ b.__is_black_ = false;
+
+ f.__parent_ = &d;
+ f.__left_ = &e;
+ f.__right_ = &g;
+ f.__is_black_ = false;
+
+ a.__parent_ = &b;
+ a.__left_ = 0;
+ a.__right_ = 0;
+ a.__is_black_ = true;
+
+ c.__parent_ = &b;
+ c.__left_ = 0;
+ c.__right_ = 0;
+ c.__is_black_ = true;
+
+ e.__parent_ = &f;
+ e.__left_ = 0;
+ e.__right_ = 0;
+ e.__is_black_ = true;
+
+ g.__parent_ = &f;
+ g.__left_ = 0;
+ g.__right_ = &h;
+ g.__is_black_ = true;
+
+ h.__parent_ = &g;
+ h.__left_ = 0;
+ h.__right_ = 0;
+ h.__is_black_ = false;
+
+ assert(std::__tree_invariant(root.__left_));
+
+ std::__tree_remove(root.__left_, &a);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &d);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(d.__parent_ == &root);
+ assert(d.__left_ == &b);
+ assert(d.__right_ == &f);
+ assert(d.__is_black_ == true);
+
+ assert(b.__parent_ == &d);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == &c);
+ assert(b.__is_black_ == true);
+
+ assert(f.__parent_ == &d);
+ assert(f.__left_ == &e);
+ assert(f.__right_ == &g);
+ assert(f.__is_black_ == false);
+
+ assert(c.__parent_ == &b);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == false);
+
+ assert(e.__parent_ == &f);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == true);
+
+ assert(g.__parent_ == &f);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &b);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &d);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(d.__parent_ == &root);
+ assert(d.__left_ == &c);
+ assert(d.__right_ == &f);
+ assert(d.__is_black_ == true);
+
+ assert(c.__parent_ == &d);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+ assert(c.__is_black_ == true);
+
+ assert(f.__parent_ == &d);
+ assert(f.__left_ == &e);
+ assert(f.__right_ == &g);
+ assert(f.__is_black_ == false);
+
+ assert(e.__parent_ == &f);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == true);
+
+ assert(g.__parent_ == &f);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &c);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &f);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(f.__parent_ == &root);
+ assert(f.__left_ == &d);
+ assert(f.__right_ == &g);
+ assert(f.__is_black_ == true);
+
+ assert(d.__parent_ == &f);
+ assert(d.__left_ == 0);
+ assert(d.__right_ == &e);
+ assert(d.__is_black_ == true);
+
+ assert(g.__parent_ == &f);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(e.__parent_ == &d);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == false);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &d);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &f);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(f.__parent_ == &root);
+ assert(f.__left_ == &e);
+ assert(f.__right_ == &g);
+ assert(f.__is_black_ == true);
+
+ assert(e.__parent_ == &f);
+ assert(e.__left_ == 0);
+ assert(e.__right_ == 0);
+ assert(e.__is_black_ == true);
+
+ assert(g.__parent_ == &f);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &e);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &g);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(g.__parent_ == &root);
+ assert(g.__left_ == &f);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(f.__parent_ == &g);
+ assert(f.__left_ == 0);
+ assert(f.__right_ == 0);
+ assert(f.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &f);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &g);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(g.__parent_ == &root);
+ assert(g.__left_ == 0);
+ assert(g.__right_ == &h);
+ assert(g.__is_black_ == true);
+
+ assert(h.__parent_ == &g);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == false);
+
+ std::__tree_remove(root.__left_, &g);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &h);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+
+ assert(h.__parent_ == &root);
+ assert(h.__left_ == 0);
+ assert(h.__right_ == 0);
+ assert(h.__is_black_ == true);
+
+ std::__tree_remove(root.__left_, &h);
+
+ assert(std::__tree_invariant(root.__left_));
+
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == 0);
+ assert(root.__right_ == 0);
+ assert(root.__is_black_ == false);
+}
+
+int main()
+{
+ test1();
+ test2();
+ test3();
+ test4();
+}
diff --git a/libcxx/test/std/containers/associative/tree_right_rotate.pass.cpp b/libcxx/test/std/containers/associative/tree_right_rotate.pass.cpp
new file mode 100644
index 00000000000..06ec7b88945
--- /dev/null
+++ b/libcxx/test/std/containers/associative/tree_right_rotate.pass.cpp
@@ -0,0 +1,98 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// Not a portable test
+
+// Precondition: __x->__left_ != nullptr
+// template <class _NodePtr>
+// void
+// __tree_right_rotate(_NodePtr __x);
+
+#include <__tree>
+#include <cassert>
+
+struct Node
+{
+ Node* __left_;
+ Node* __right_;
+ Node* __parent_;
+
+ Node() : __left_(), __right_(), __parent_() {}
+};
+
+void
+test1()
+{
+ Node root;
+ Node x;
+ Node y;
+ root.__left_ = &x;
+ x.__left_ = &y;
+ x.__right_ = 0;
+ x.__parent_ = &root;
+ y.__left_ = 0;
+ y.__right_ = 0;
+ y.__parent_ = &x;
+ std::__tree_right_rotate(&x);
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &y);
+ assert(root.__right_ == 0);
+ assert(y.__parent_ == &root);
+ assert(y.__left_ == 0);
+ assert(y.__right_ == &x);
+ assert(x.__parent_ == &y);
+ assert(x.__left_ == 0);
+ assert(x.__right_ == 0);
+}
+
+void
+test2()
+{
+ Node root;
+ Node x;
+ Node y;
+ Node a;
+ Node b;
+ Node c;
+ root.__left_ = &x;
+ x.__left_ = &y;
+ x.__right_ = &c;
+ x.__parent_ = &root;
+ y.__left_ = &a;
+ y.__right_ = &b;
+ y.__parent_ = &x;
+ a.__parent_ = &y;
+ b.__parent_ = &y;
+ c.__parent_ = &x;
+ std::__tree_right_rotate(&x);
+ assert(root.__parent_ == 0);
+ assert(root.__left_ == &y);
+ assert(root.__right_ == 0);
+ assert(y.__parent_ == &root);
+ assert(y.__left_ == &a);
+ assert(y.__right_ == &x);
+ assert(x.__parent_ == &y);
+ assert(x.__left_ == &b);
+ assert(x.__right_ == &c);
+ assert(a.__parent_ == &y);
+ assert(a.__left_ == 0);
+ assert(a.__right_ == 0);
+ assert(b.__parent_ == &x);
+ assert(b.__left_ == 0);
+ assert(b.__right_ == 0);
+ assert(c.__parent_ == &x);
+ assert(c.__left_ == 0);
+ assert(c.__right_ == 0);
+}
+
+int main()
+{
+ test1();
+ test2();
+}
OpenPOWER on IntegriCloud