summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/containers
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/containers')
-rw-r--r--libcxx/test/std/containers/Copyable.h18
-rw-r--r--libcxx/test/std/containers/Emplaceable.h54
-rw-r--r--libcxx/test/std/containers/MoveOnly.h50
-rw-r--r--libcxx/test/std/containers/NotConstructible.h39
-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
-rw-r--r--libcxx/test/std/containers/container.adaptors/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_alloc.pass.cpp48
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_alloc.pass.cpp48
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp62
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp61
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_copy_alloc.pass.cpp58
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_move_alloc.pass.cpp68
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_copy.pass.cpp36
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_move.pass.cpp42
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp27
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp34
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp40
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_copy.pass.cpp35
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp27
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter.pass.cpp25
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp.pass.cpp27
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_cont.pass.cpp27
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_rcont.pass.cpp32
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_move.pass.cpp41
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp31
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/dtor_noexcept.pass.cpp27
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_assign_noexcept.pass.cpp31
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp31
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/emplace.pass.cpp32
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/empty.pass.cpp27
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/pop.pass.cpp34
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/push.pass.cpp28
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/push_rvalue.pass.cpp32
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/size.pass.cpp27
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/swap.pass.cpp30
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/top.pass.cpp28
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap.pass.cpp32
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp32
-rw-r--r--libcxx/test/std/containers/container.adaptors/priority.queue/types.pass.cpp60
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_alloc.pass.cpp38
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp57
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_queue_alloc.pass.cpp52
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp59
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.pass.cpp60
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_container.pass.cpp37
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_copy.pass.cpp32
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_default.pass.cpp28
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_move.pass.cpp41
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp39
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp30
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.cons/dtor_noexcept.pass.cpp27
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.cons/move_assign_noexcept.pass.cpp30
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp30
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/assign_copy.pass.cpp33
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/assign_move.pass.cpp42
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/back.pass.cpp26
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/back_const.pass.cpp27
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp30
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/empty.pass.cpp25
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/front.pass.cpp26
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/front_const.pass.cpp27
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/pop.pass.cpp37
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/push.pass.cpp32
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp36
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/size.pass.cpp23
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/swap.pass.cpp36
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp58
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.ops/eq.pass.cpp40
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.ops/lt.pass.cpp45
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.special/swap.pass.cpp37
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp31
-rw-r--r--libcxx/test/std/containers/container.adaptors/queue/version.pass.cpp20
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp38
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp57
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_copy_alloc.pass.cpp52
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp59
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp60
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp37
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_copy.pass.cpp32
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp28
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp41
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp39
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp30
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp27
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp30
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp30
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.defn/assign_copy.pass.cpp33
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.defn/assign_move.pass.cpp42
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.defn/emplace.pass.cpp29
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.defn/empty.pass.cpp25
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.defn/pop.pass.cpp34
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.defn/push.pass.cpp29
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.defn/push_rv.pass.cpp33
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.defn/size.pass.cpp23
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.defn/swap.pass.cpp36
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.defn/top.pass.cpp26
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.defn/top_const.pass.cpp27
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.defn/types.pass.cpp59
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.ops/eq.pass.cpp40
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.ops/lt.pass.cpp45
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.special/swap.pass.cpp37
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp31
-rw-r--r--libcxx/test/std/containers/container.adaptors/stack/version.pass.cpp20
-rw-r--r--libcxx/test/std/containers/container.requirements/associative.reqmts/associative.reqmts.except/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/std/containers/container.requirements/associative.reqmts/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/std/containers/container.requirements/container.requirements.dataraces/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/std/containers/container.requirements/container.requirements.general/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/std/containers/container.requirements/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/std/containers/container.requirements/sequence.reqmts/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/std/containers/container.requirements/unord.req/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/std/containers/container.requirements/unord.req/unord.req.except/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/std/containers/containers.general/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/std/containers/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/std/containers/sequences/array/array.cons/default.pass.cpp31
-rw-r--r--libcxx/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp34
-rw-r--r--libcxx/test/std/containers/sequences/array/array.data/data.pass.cpp35
-rw-r--r--libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp35
-rw-r--r--libcxx/test/std/containers/sequences/array/array.fill/fill.pass.cpp36
-rw-r--r--libcxx/test/std/containers/sequences/array/array.size/size.pass.cpp53
-rw-r--r--libcxx/test/std/containers/sequences/array/array.special/swap.pass.cpp43
-rw-r--r--libcxx/test/std/containers/sequences/array/array.swap/swap.pass.cpp43
-rw-r--r--libcxx/test/std/containers/sequences/array/array.tuple/get.fail.cpp25
-rw-r--r--libcxx/test/std/containers/sequences/array/array.tuple/get.pass.cpp52
-rw-r--r--libcxx/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp37
-rw-r--r--libcxx/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp29
-rw-r--r--libcxx/test/std/containers/sequences/array/array.tuple/tuple_element.pass.cpp33
-rw-r--r--libcxx/test/std/containers/sequences/array/array.tuple/tuple_size.pass.cpp28
-rw-r--r--libcxx/test/std/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp18
-rw-r--r--libcxx/test/std/containers/sequences/array/at.pass.cpp67
-rw-r--r--libcxx/test/std/containers/sequences/array/begin.pass.cpp32
-rw-r--r--libcxx/test/std/containers/sequences/array/front_back.pass.cpp62
-rw-r--r--libcxx/test/std/containers/sequences/array/indexing.pass.cpp60
-rw-r--r--libcxx/test/std/containers/sequences/array/iterators.pass.cpp110
-rw-r--r--libcxx/test/std/containers/sequences/array/types.pass.cpp62
-rw-r--r--libcxx/test/std/containers/sequences/array/version.pass.cpp20
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.capacity/access.pass.cpp91
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.capacity/resize_size.pass.cpp86
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp86
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp77
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/alloc.pass.cpp38
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp43
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp109
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp85
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/copy.pass.cpp61
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp51
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/default.pass.cpp41
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp50
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp52
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/initializer_list.pass.cpp41
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp44
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp62
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp51
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/move.pass.cpp72
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/move_alloc.pass.cpp87
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/move_assign.pass.cpp91
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp52
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp50
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/op_equal.pass.cpp63
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp43
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/size.pass.cpp113
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp51
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp67
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.modifiers/emplace.pass.cpp112
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp87
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp87
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp90
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp96
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp63
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp256
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp118
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp159
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp139
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp84
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp84
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.modifiers/push_back.pass.cpp73
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp81
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp80
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.modifiers/push_front.pass.cpp83
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp81
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp90
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.special/copy.pass.cpp88
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.special/copy_backward.pass.cpp87
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.special/move.pass.cpp87
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.special/move_backward.pass.cpp87
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.special/swap.pass.cpp110
-rw-r--r--libcxx/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp60
-rw-r--r--libcxx/test/std/containers/sequences/deque/iterators.pass.cpp79
-rw-r--r--libcxx/test/std/containers/sequences/deque/types.pass.cpp90
-rw-r--r--libcxx/test/std/containers/sequences/deque/version.pass.cpp20
-rw-r--r--libcxx/test/std/containers/sequences/dynarray/dynarray.cons/alloc.pass.cpp86
-rw-r--r--libcxx/test/std/containers/sequences/dynarray/dynarray.cons/default.pass.cpp95
-rw-r--r--libcxx/test/std/containers/sequences/dynarray/dynarray.data/default.pass.cpp67
-rw-r--r--libcxx/test/std/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp48
-rw-r--r--libcxx/test/std/containers/sequences/dynarray/dynarray.overview/at.pass.cpp94
-rw-r--r--libcxx/test/std/containers/sequences/dynarray/dynarray.overview/begin_end.pass.cpp108
-rw-r--r--libcxx/test/std/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp57
-rw-r--r--libcxx/test/std/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp68
-rw-r--r--libcxx/test/std/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp71
-rw-r--r--libcxx/test/std/containers/sequences/dynarray/dynarray.traits/default.pass.cpp31
-rw-r--r--libcxx/test/std/containers/sequences/dynarray/dynarray.zero/default.pass.cpp50
-rw-r--r--libcxx/test/std/containers/sequences/dynarray/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp61
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.fail.cpp30
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp41
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp146
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp70
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp199
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp70
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp78
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp68
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp69
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp67
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp41
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp50
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/default_recursive.pass.cpp25
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp52
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp43
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp48
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp73
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp73
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp52
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp50
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp48
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp54
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/size.fail.cpp35
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp66
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp45
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp50
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp104
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp145
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp62
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp89
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp50
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp155
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp97
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp87
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp75
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp80
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp90
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.pass.cpp73
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp78
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp47
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp73
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp50
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp114
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp84
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp48
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp49
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp155
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp155
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/reverse.pass.cpp42
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp47
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp48
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp75
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp140
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp169
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp120
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp125
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp60
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp259
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp260
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp65
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp60
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/max_size.pass.cpp35
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/types.pass.cpp60
-rw-r--r--libcxx/test/std/containers/sequences/forwardlist/version.pass.cpp20
-rw-r--r--libcxx/test/std/containers/sequences/list/db_back.pass.cpp56
-rw-r--r--libcxx/test/std/containers/sequences/list/db_cback.pass.cpp52
-rw-r--r--libcxx/test/std/containers/sequences/list/db_cfront.pass.cpp52
-rw-r--r--libcxx/test/std/containers/sequences/list/db_front.pass.cpp56
-rw-r--r--libcxx/test/std/containers/sequences/list/db_iterators_6.pass.cpp58
-rw-r--r--libcxx/test/std/containers/sequences/list/db_iterators_7.pass.cpp58
-rw-r--r--libcxx/test/std/containers/sequences/list/db_iterators_8.pass.cpp54
-rw-r--r--libcxx/test/std/containers/sequences/list/db_iterators_9.pass.cpp67
-rw-r--r--libcxx/test/std/containers/sequences/list/iterators.pass.cpp159
-rw-r--r--libcxx/test/std/containers/sequences/list/list.capacity/resize_size.pass.cpp81
-rw-r--r--libcxx/test/std/containers/sequences/list/list.capacity/resize_size_value.pass.cpp53
-rw-r--r--libcxx/test/std/containers/sequences/list/list.cons/assign_copy.pass.cpp44
-rw-r--r--libcxx/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp45
-rw-r--r--libcxx/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp82
-rw-r--r--libcxx/test/std/containers/sequences/list/list.cons/copy.pass.cpp54
-rw-r--r--libcxx/test/std/containers/sequences/list/list.cons/copy_alloc.pass.cpp42
-rw-r--r--libcxx/test/std/containers/sequences/list/list.cons/default.pass.cpp58
-rw-r--r--libcxx/test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp50
-rw-r--r--libcxx/test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp48
-rw-r--r--libcxx/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp52
-rw-r--r--libcxx/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp43
-rw-r--r--libcxx/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp46
-rw-r--r--libcxx/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp77
-rw-r--r--libcxx/test/std/containers/sequences/list/list.cons/move.pass.cpp74
-rw-r--r--libcxx/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp78
-rw-r--r--libcxx/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp52
-rw-r--r--libcxx/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp50
-rw-r--r--libcxx/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp44
-rw-r--r--libcxx/test/std/containers/sequences/list/list.cons/size_type.pass.cpp103
-rw-r--r--libcxx/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp79
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/clear.pass.cpp35
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/emplace.pass.cpp88
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp66
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp66
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter.pass.cpp65
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp51
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp53
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp84
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp51
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp51
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp51
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp49
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp67
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp185
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp68
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp106
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp112
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/pop_back.pass.cpp55
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/pop_front.pass.cpp43
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/push_back.pass.cpp37
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp73
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp46
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/push_front.pass.cpp37
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp73
-rw-r--r--libcxx/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp46
-rw-r--r--libcxx/test/std/containers/sequences/list/list.ops/merge.pass.cpp41
-rw-r--r--libcxx/test/std/containers/sequences/list/list.ops/merge_comp.pass.cpp42
-rw-r--r--libcxx/test/std/containers/sequences/list/list.ops/remove.pass.cpp69
-rw-r--r--libcxx/test/std/containers/sequences/list/list.ops/remove_if.pass.cpp64
-rw-r--r--libcxx/test/std/containers/sequences/list/list.ops/reverse.pass.cpp37
-rw-r--r--libcxx/test/std/containers/sequences/list/list.ops/sort.pass.cpp37
-rw-r--r--libcxx/test/std/containers/sequences/list/list.ops/sort_comp.pass.cpp38
-rw-r--r--libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list.pass.cpp803
-rw-r--r--libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp357
-rw-r--r--libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp237
-rw-r--r--libcxx/test/std/containers/sequences/list/list.ops/unique.pass.cpp37
-rw-r--r--libcxx/test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp42
-rw-r--r--libcxx/test/std/containers/sequences/list/list.special/db_swap_1.pass.cpp59
-rw-r--r--libcxx/test/std/containers/sequences/list/list.special/swap.pass.cpp146
-rw-r--r--libcxx/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp60
-rw-r--r--libcxx/test/std/containers/sequences/list/types.pass.cpp46
-rw-r--r--libcxx/test/std/containers/sequences/list/version.pass.cpp20
-rw-r--r--libcxx/test/std/containers/sequences/nothing_to_do.pass.cpp12
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp44
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp43
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/assign_move.pass.cpp81
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/capacity.pass.cpp44
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/construct_default.pass.cpp59
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp48
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp55
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/construct_size.pass.cpp64
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp37
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp39
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/copy.pass.cpp65
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp62
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp49
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp51
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/emplace.pass.cpp68
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp57
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp65
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp85
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/find.pass.cpp40
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp41
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp44
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp65
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp126
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp81
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp77
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/iterators.pass.cpp123
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/move.pass.cpp64
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp77
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp51
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp49
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp43
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/push_back.pass.cpp48
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp54
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/resize_size.pass.cpp50
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp52
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp38
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/swap.pass.cpp98
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp59
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/types.pass.cpp72
-rw-r--r--libcxx/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp51
-rw-r--r--libcxx/test/std/containers/sequences/vector/asan.pass.cpp52
-rw-r--r--libcxx/test/std/containers/sequences/vector/asan_throw.pass.cc198
-rw-r--r--libcxx/test/std/containers/sequences/vector/const_value_type.pass.cpp22
-rw-r--r--libcxx/test/std/containers/sequences/vector/db_back.pass.cpp56
-rw-r--r--libcxx/test/std/containers/sequences/vector/db_cback.pass.cpp52
-rw-r--r--libcxx/test/std/containers/sequences/vector/db_cfront.pass.cpp52
-rw-r--r--libcxx/test/std/containers/sequences/vector/db_cindex.pass.cpp54
-rw-r--r--libcxx/test/std/containers/sequences/vector/db_front.pass.cpp56
-rw-r--r--libcxx/test/std/containers/sequences/vector/db_index.pass.cpp56
-rw-r--r--libcxx/test/std/containers/sequences/vector/db_iterators_2.pass.cpp54
-rw-r--r--libcxx/test/std/containers/sequences/vector/db_iterators_3.pass.cpp54
-rw-r--r--libcxx/test/std/containers/sequences/vector/db_iterators_4.pass.cpp56
-rw-r--r--libcxx/test/std/containers/sequences/vector/db_iterators_5.pass.cpp60
-rw-r--r--libcxx/test/std/containers/sequences/vector/db_iterators_6.pass.cpp58
-rw-r--r--libcxx/test/std/containers/sequences/vector/db_iterators_7.pass.cpp58
-rw-r--r--libcxx/test/std/containers/sequences/vector/db_iterators_8.pass.cpp54
-rw-r--r--libcxx/test/std/containers/sequences/vector/iterators.pass.cpp165
-rw-r--r--libcxx/test/std/containers/sequences/vector/types.pass.cpp84
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp48
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp69
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp83
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp76
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp62
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp50
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp44
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp46
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp101
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp78
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp56
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp71
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp73
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp40
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp39
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp78
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp64
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp23
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp50
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp52
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp43
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp47
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.cons/move.pass.cpp103
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp99
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp52
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp50
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp46
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.data/data.pass.cpp44
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp44
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp160
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp107
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp62
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp74
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp51
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp53
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp127
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp51
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp51
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp51
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp49
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp68
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp190
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp86
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp132
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp116
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp55
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp108
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp86
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp111
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.special/db_swap_1.pass.cpp56
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.special/swap.pass.cpp187
-rw-r--r--libcxx/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp60
-rw-r--r--libcxx/test/std/containers/sequences/vector/version.pass.cpp20
-rw-r--r--libcxx/test/std/containers/stack_allocator.h66
-rw-r--r--libcxx/test/std/containers/test_compare.h36
-rw-r--r--libcxx/test/std/containers/test_hash.h32
-rw-r--r--libcxx/test/std/containers/unord/next_prime.pass.cpp51
-rw-r--r--libcxx/test/std/containers/unord/unord.map/bucket.pass.cpp77
-rw-r--r--libcxx/test/std/containers/unord/unord.map/bucket_count.pass.cpp80
-rw-r--r--libcxx/test/std/containers/unord/unord.map/bucket_size.pass.cpp81
-rw-r--r--libcxx/test/std/containers/unord/unord.map/compare.pass.cpp42
-rw-r--r--libcxx/test/std/containers/unord/unord.map/count.pass.cpp65
-rw-r--r--libcxx/test/std/containers/unord/unord.map/db_iterators_7.pass.cpp60
-rw-r--r--libcxx/test/std/containers/unord/unord.map/db_iterators_8.pass.cpp56
-rw-r--r--libcxx/test/std/containers/unord/unord.map/db_local_iterators_7.pass.cpp57
-rw-r--r--libcxx/test/std/containers/unord/unord.map/db_local_iterators_8.pass.cpp54
-rw-r--r--libcxx/test/std/containers/unord/unord.map/eq.pass.cpp163
-rw-r--r--libcxx/test/std/containers/unord/unord.map/equal_range_const.pass.cpp75
-rw-r--r--libcxx/test/std/containers/unord/unord.map/equal_range_non_const.pass.cpp75
-rw-r--r--libcxx/test/std/containers/unord/unord.map/find_const.pass.cpp71
-rw-r--r--libcxx/test/std/containers/unord/unord.map/find_non_const.pass.cpp71
-rw-r--r--libcxx/test/std/containers/unord/unord.map/iterators.pass.cpp128
-rw-r--r--libcxx/test/std/containers/unord/unord.map/load_factor.pass.cpp77
-rw-r--r--libcxx/test/std/containers/unord/unord.map/local_iterators.pass.cpp421
-rw-r--r--libcxx/test/std/containers/unord/unord.map/max_bucket_count.pass.cpp43
-rw-r--r--libcxx/test/std/containers/unord/unord.map/max_load_factor.pass.cpp71
-rw-r--r--libcxx/test/std/containers/unord/unord.map/max_size.pass.cpp36
-rw-r--r--libcxx/test/std/containers/unord/unord.map/rehash.pass.cpp91
-rw-r--r--libcxx/test/std/containers/unord/unord.map/reserve.pass.cpp91
-rw-r--r--libcxx/test/std/containers/unord/unord.map/swap_member.pass.cpp572
-rw-r--r--libcxx/test/std/containers/unord/unord.map/types.pass.cpp72
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp111
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp185
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp97
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp229
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp151
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp110
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp78
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp70
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp67
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp162
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp100
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp102
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp105
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp107
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp199
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp157
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp69
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp66
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp170
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp105
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp108
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp110
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp113
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp69
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp69
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp73
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp75
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp77
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp134
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.elem/index.pass.cpp115
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp41
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp44
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp73
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp572
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp61
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp80
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp93
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp69
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp39
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp42
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp41
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp41
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp41
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp40
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp177
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp99
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp86
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp97
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp156
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp72
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp71
-rw-r--r--libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp152
-rw-r--r--libcxx/test/std/containers/unord/unord.map/version.pass.cpp20
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/bucket.pass.cpp77
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp49
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/bucket_size.pass.cpp85
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/count.pass.cpp71
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/db_iterators_7.pass.cpp60
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/db_iterators_8.pass.cpp56
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp57
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp54
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/eq.pass.cpp181
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/equal_range_const.pass.cpp97
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp97
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/find_const.pass.cpp71
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/find_non_const.pass.cpp71
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/iterators.fail.cpp69
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/iterators.pass.cpp134
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/load_factor.pass.cpp77
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/local_iterators.fail.cpp286
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/local_iterators.pass.cpp549
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp43
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp71
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/max_size.pass.cpp36
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/rehash.pass.cpp119
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/reserve.pass.cpp93
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/scary.pass.cpp24
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/swap_member.pass.cpp585
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/types.pass.cpp72
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp111
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp227
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp146
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp306
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp193
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp138
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp78
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp70
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp67
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp254
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp144
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp146
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp149
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp151
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp243
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp228
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp69
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp66
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp263
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp149
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp152
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp154
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp157
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp69
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp69
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp73
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp75
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp77
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp61
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp74
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp109
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp117
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp39
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp42
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp41
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp41
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp41
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp40
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp388
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp179
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp78
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp97
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp156
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp122
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp121
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp136
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.swap/db_swap_1.pass.cpp44
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp73
-rw-r--r--libcxx/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp584
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/bucket.pass.cpp76
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp79
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/bucket_size.pass.cpp84
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/clear.pass.cpp60
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/count.pass.cpp70
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/db_iterators_7.pass.cpp58
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/db_iterators_8.pass.cpp54
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp57
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp54
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/emplace.pass.cpp64
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/emplace_hint.pass.cpp80
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/eq.pass.cpp180
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/equal_range_const.pass.cpp90
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/equal_range_non_const.pass.cpp90
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/erase_const_iter.pass.cpp70
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/erase_iter_db1.pass.cpp38
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/erase_iter_db2.pass.cpp41
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/erase_iter_iter_db1.pass.cpp40
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/erase_iter_iter_db2.pass.cpp40
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/erase_iter_iter_db3.pass.cpp40
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/erase_iter_iter_db4.pass.cpp39
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/erase_key.pass.cpp176
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/erase_range.pass.cpp94
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/find_const.pass.cpp68
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/find_non_const.pass.cpp68
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp70
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp89
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp138
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/insert_init.pass.cpp71
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/insert_range.pass.cpp70
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/insert_rvalue.pass.cpp118
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/iterators.fail.cpp67
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/iterators.pass.cpp127
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/load_factor.pass.cpp76
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/local_iterators.fail.cpp261
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/local_iterators.pass.cpp500
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/max_bucket_count.pass.cpp38
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/max_load_factor.pass.cpp70
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/max_size.pass.cpp36
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/rehash.pass.cpp90
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/reserve.pass.cpp90
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/scary.pass.cpp24
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/swap_member.pass.cpp571
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/types.pass.cpp69
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp109
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp209
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp97
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp286
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp171
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp123
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp74
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp70
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp67
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp163
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp97
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp100
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp102
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp104
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp194
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp213
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp69
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp66
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp167
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp101
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp104
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp106
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp109
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp65
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp65
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp69
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.pass.cpp71
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp73
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.swap/db_swap_1.pass.cpp43
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp73
-rw-r--r--libcxx/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp571
-rw-r--r--libcxx/test/std/containers/unord/unord.set/bucket.pass.cpp75
-rw-r--r--libcxx/test/std/containers/unord/unord.set/bucket_count.pass.cpp77
-rw-r--r--libcxx/test/std/containers/unord/unord.set/bucket_size.pass.cpp79
-rw-r--r--libcxx/test/std/containers/unord/unord.set/clear.pass.cpp59
-rw-r--r--libcxx/test/std/containers/unord/unord.set/count.pass.cpp69
-rw-r--r--libcxx/test/std/containers/unord/unord.set/db_iterators_7.pass.cpp58
-rw-r--r--libcxx/test/std/containers/unord/unord.set/db_iterators_8.pass.cpp54
-rw-r--r--libcxx/test/std/containers/unord/unord.set/db_local_iterators_7.pass.cpp57
-rw-r--r--libcxx/test/std/containers/unord/unord.set/db_local_iterators_8.pass.cpp54
-rw-r--r--libcxx/test/std/containers/unord/unord.set/emplace.pass.cpp70
-rw-r--r--libcxx/test/std/containers/unord/unord.set/emplace_hint.pass.cpp80
-rw-r--r--libcxx/test/std/containers/unord/unord.set/eq.pass.cpp159
-rw-r--r--libcxx/test/std/containers/unord/unord.set/equal_range_const.pass.cpp81
-rw-r--r--libcxx/test/std/containers/unord/unord.set/equal_range_non_const.pass.cpp81
-rw-r--r--libcxx/test/std/containers/unord/unord.set/erase_const_iter.pass.cpp67
-rw-r--r--libcxx/test/std/containers/unord/unord.set/erase_iter_db1.pass.cpp38
-rw-r--r--libcxx/test/std/containers/unord/unord.set/erase_iter_db2.pass.cpp41
-rw-r--r--libcxx/test/std/containers/unord/unord.set/erase_iter_iter_db1.pass.cpp40
-rw-r--r--libcxx/test/std/containers/unord/unord.set/erase_iter_iter_db2.pass.cpp40
-rw-r--r--libcxx/test/std/containers/unord/unord.set/erase_iter_iter_db3.pass.cpp40
-rw-r--r--libcxx/test/std/containers/unord/unord.set/erase_iter_iter_db4.pass.cpp39
-rw-r--r--libcxx/test/std/containers/unord/unord.set/erase_key.pass.cpp175
-rw-r--r--libcxx/test/std/containers/unord/unord.set/erase_range.pass.cpp93
-rw-r--r--libcxx/test/std/containers/unord/unord.set/find_const.pass.cpp67
-rw-r--r--libcxx/test/std/containers/unord/unord.set/find_non_const.pass.cpp67
-rw-r--r--libcxx/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp78
-rw-r--r--libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp89
-rw-r--r--libcxx/test/std/containers/unord/unord.set/insert_hint_rvalue.pass.cpp138
-rw-r--r--libcxx/test/std/containers/unord/unord.set/insert_init.pass.cpp71
-rw-r--r--libcxx/test/std/containers/unord/unord.set/insert_range.pass.cpp70
-rw-r--r--libcxx/test/std/containers/unord/unord.set/insert_rvalue.pass.cpp134
-rw-r--r--libcxx/test/std/containers/unord/unord.set/iterators.fail.cpp67
-rw-r--r--libcxx/test/std/containers/unord/unord.set/iterators.pass.cpp127
-rw-r--r--libcxx/test/std/containers/unord/unord.set/load_factor.pass.cpp76
-rw-r--r--libcxx/test/std/containers/unord/unord.set/local_iterators.fail.cpp261
-rw-r--r--libcxx/test/std/containers/unord/unord.set/local_iterators.pass.cpp388
-rw-r--r--libcxx/test/std/containers/unord/unord.set/max_bucket_count.pass.cpp38
-rw-r--r--libcxx/test/std/containers/unord/unord.set/max_load_factor.pass.cpp70
-rw-r--r--libcxx/test/std/containers/unord/unord.set/max_size.pass.cpp36
-rw-r--r--libcxx/test/std/containers/unord/unord.set/rehash.pass.cpp90
-rw-r--r--libcxx/test/std/containers/unord/unord.set/reserve.pass.cpp90
-rw-r--r--libcxx/test/std/containers/unord/unord.set/swap_member.pass.cpp571
-rw-r--r--libcxx/test/std/containers/unord/unord.set/types.pass.cpp69
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp109
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp184
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp97
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp225
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp147
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp107
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp74
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp70
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp67
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp163
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp97
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp100
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp102
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp104
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp194
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp156
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp69
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp66
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp168
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp101
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp104
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp106
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp109
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/size.fail.cpp45
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp65
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp69
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.pass.cpp71
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp73
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.swap/db_swap_1.pass.cpp43
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp73
-rw-r--r--libcxx/test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp571
-rw-r--r--libcxx/test/std/containers/unord/unord.set/version.pass.cpp20
953 files changed, 87700 insertions, 0 deletions
diff --git a/libcxx/test/std/containers/Copyable.h b/libcxx/test/std/containers/Copyable.h
new file mode 100644
index 00000000000..9542c7e8516
--- /dev/null
+++ b/libcxx/test/std/containers/Copyable.h
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef COPYABLE_H
+#define COPYABLE_H
+
+class Copyable
+{
+public:
+};
+
+#endif // COPYABLE_H
diff --git a/libcxx/test/std/containers/Emplaceable.h b/libcxx/test/std/containers/Emplaceable.h
new file mode 100644
index 00000000000..34dd326203b
--- /dev/null
+++ b/libcxx/test/std/containers/Emplaceable.h
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef EMPLACEABLE_H
+#define EMPLACEABLE_H
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+class Emplaceable
+{
+ Emplaceable(const Emplaceable&);
+ Emplaceable& operator=(const Emplaceable&);
+
+ int int_;
+ double double_;
+public:
+ Emplaceable() : int_(0), double_(0) {}
+ Emplaceable(int i, double d) : int_(i), double_(d) {}
+ Emplaceable(Emplaceable&& x)
+ : int_(x.int_), double_(x.double_)
+ {x.int_ = 0; x.double_ = 0;}
+ Emplaceable& operator=(Emplaceable&& x)
+ {int_ = x.int_; x.int_ = 0;
+ double_ = x.double_; x.double_ = 0;
+ return *this;}
+
+ bool operator==(const Emplaceable& x) const
+ {return int_ == x.int_ && double_ == x.double_;}
+ bool operator<(const Emplaceable& x) const
+ {return int_ < x.int_ || (int_ == x.int_ && double_ < x.double_);}
+
+ int get() const {return int_;}
+};
+
+namespace std {
+
+template <>
+struct hash<Emplaceable>
+ : public std::unary_function<Emplaceable, std::size_t>
+{
+ std::size_t operator()(const Emplaceable& x) const {return x.get();}
+};
+
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#endif // EMPLACEABLE_H
diff --git a/libcxx/test/std/containers/MoveOnly.h b/libcxx/test/std/containers/MoveOnly.h
new file mode 100644
index 00000000000..e4d9f649560
--- /dev/null
+++ b/libcxx/test/std/containers/MoveOnly.h
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef MOVEONLY_H
+#define MOVEONLY_H
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#include <cstddef>
+#include <functional>
+
+class MoveOnly
+{
+ MoveOnly(const MoveOnly&);
+ MoveOnly& operator=(const MoveOnly&);
+
+ int data_;
+public:
+ MoveOnly(int data = 1) : data_(data) {}
+ MoveOnly(MoveOnly&& x)
+ : data_(x.data_) {x.data_ = 0;}
+ MoveOnly& operator=(MoveOnly&& x)
+ {data_ = x.data_; x.data_ = 0; return *this;}
+
+ int get() const {return data_;}
+
+ bool operator==(const MoveOnly& x) const {return data_ == x.data_;}
+ bool operator< (const MoveOnly& x) const {return data_ < x.data_;}
+};
+
+namespace std {
+
+template <>
+struct hash<MoveOnly>
+ : public std::unary_function<MoveOnly, std::size_t>
+{
+ std::size_t operator()(const MoveOnly& x) const {return x.get();}
+};
+
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+#endif // MOVEONLY_H
diff --git a/libcxx/test/std/containers/NotConstructible.h b/libcxx/test/std/containers/NotConstructible.h
new file mode 100644
index 00000000000..ac8b98ef99f
--- /dev/null
+++ b/libcxx/test/std/containers/NotConstructible.h
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef NOTCONSTRUCTIBLE_H
+#define NOTCONSTRUCTIBLE_H
+
+#include <functional>
+
+class NotConstructible
+{
+ NotConstructible(const NotConstructible&);
+ NotConstructible& operator=(const NotConstructible&);
+public:
+};
+
+inline
+bool
+operator==(const NotConstructible&, const NotConstructible&)
+{return true;}
+
+namespace std
+{
+
+template <>
+struct hash<NotConstructible>
+ : public std::unary_function<NotConstructible, std::size_t>
+{
+ std::size_t operator()(const NotConstructible&) const {return 0;}
+};
+
+}
+
+#endif // NOTCONSTRUCTIBLE_H
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();
+}
diff --git a/libcxx/test/std/containers/container.adaptors/nothing_to_do.pass.cpp b/libcxx/test/std/containers/container.adaptors/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_alloc.pass.cpp
new file mode 100644
index 00000000000..b102f117d48
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_alloc.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+// explicit priority_queue(const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct test
+ : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+ typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+ typedef typename base::container_type container_type;
+ typedef typename base::value_compare value_compare;
+
+ explicit test(const test_allocator<int>& a) : base(a) {}
+ test(const value_compare& comp, const test_allocator<int>& a)
+ : base(comp, c, a) {}
+ test(const value_compare& comp, const container_type& c,
+ const test_allocator<int>& a) : base(comp, c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test(const value_compare& comp, container_type&& c,
+ const test_allocator<int>& a) : base(comp, std::move(c), a) {}
+ test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_allocator<int> get_allocator() {return c.get_allocator();}
+
+ using base::c;
+};
+
+int main()
+{
+ test<int> q((test_allocator<int>(3)));
+ assert(q.c.get_allocator() == test_allocator<int>(3));
+ assert(q.c.size() == 0);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_alloc.pass.cpp
new file mode 100644
index 00000000000..4d99fc14728
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_alloc.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+// priority_queue(const Compare& comp, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct test
+ : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+ typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+ typedef typename base::container_type container_type;
+ typedef typename base::value_compare value_compare;
+
+ explicit test(const test_allocator<int>& a) : base(a) {}
+ test(const value_compare& comp, const test_allocator<int>& a)
+ : base(comp, a) {}
+ test(const value_compare& comp, const container_type& c,
+ const test_allocator<int>& a) : base(comp, c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test(const value_compare& comp, container_type&& c,
+ const test_allocator<int>& a) : base(comp, std::move(c), a) {}
+ test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_allocator<int> get_allocator() {return c.get_allocator();}
+
+ using base::c;
+};
+
+int main()
+{
+ test<int> q(std::less<int>(), test_allocator<int>(3));
+ assert(q.c.get_allocator() == test_allocator<int>(3));
+ assert(q.c.size() == 0);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp
new file mode 100644
index 00000000000..66ca614126f
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+// priority_queue(const Compare& comp, const container_type& c,
+// const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+template <class T>
+struct test
+ : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+ typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+ typedef typename base::container_type container_type;
+ typedef typename base::value_compare value_compare;
+
+ explicit test(const test_allocator<int>& a) : base(a) {}
+ test(const value_compare& comp, const test_allocator<int>& a)
+ : base(comp, a) {}
+ test(const value_compare& comp, const container_type& c,
+ const test_allocator<int>& a) : base(comp, c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test(const value_compare& comp, container_type&& c,
+ const test_allocator<int>& a) : base(comp, std::move(c), a) {}
+ test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_allocator<int> get_allocator() {return c.get_allocator();}
+
+ using base::c;
+};
+
+int main()
+{
+ typedef std::vector<int, test_allocator<int> > C;
+ C v = make<C>(5);
+ test<int> q(std::less<int>(), v, test_allocator<int>(3));
+ assert(q.c.get_allocator() == test_allocator<int>(3));
+ assert(q.size() == 5);
+ assert(q.top() == 4);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp
new file mode 100644
index 00000000000..643b0c625ab
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+// priority_queue(const Compare& comp, container_type&& c,
+// const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+template <class T>
+struct test
+ : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+ typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+ typedef typename base::container_type container_type;
+ typedef typename base::value_compare value_compare;
+
+ explicit test(const test_allocator<int>& a) : base(a) {}
+ test(const value_compare& comp, const test_allocator<int>& a)
+ : base(comp, a) {}
+ test(const value_compare& comp, const container_type& c,
+ const test_allocator<int>& a) : base(comp, c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test(const value_compare& comp, container_type&& c,
+ const test_allocator<int>& a) : base(comp, std::move(c), a) {}
+ test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_allocator<int> get_allocator() {return c.get_allocator();}
+
+ using base::c;
+};
+
+int main()
+{
+ typedef std::vector<int, test_allocator<int> > C;
+ test<int> q(std::less<int>(), make<C>(5), test_allocator<int>(3));
+ assert(q.c.get_allocator() == test_allocator<int>(3));
+ assert(q.size() == 5);
+ assert(q.top() == 4);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_copy_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_copy_alloc.pass.cpp
new file mode 100644
index 00000000000..a5a073c079b
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_copy_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+// priority_queue(const priority_queue& q, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+#include "test_allocator.h"
+
+template <class T>
+struct test
+ : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+ typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+ typedef typename base::container_type container_type;
+ typedef typename base::value_compare value_compare;
+
+ explicit test(const test_allocator<int>& a) : base(a) {}
+ test(const value_compare& comp, const test_allocator<int>& a)
+ : base(comp, c, a) {}
+ test(const value_compare& comp, const container_type& c,
+ const test_allocator<int>& a) : base(comp, c, a) {}
+ test(const test& q, const test_allocator<int>& a) : base(q, a) {}
+ test_allocator<int> get_allocator() {return c.get_allocator();}
+
+ using base::c;
+};
+
+int main()
+{
+ test<int> qo(std::less<int>(),
+ make<std::vector<int, test_allocator<int> > >(5),
+ test_allocator<int>(2));
+ test<int> q(qo, test_allocator<int>(6));
+ assert(q.size() == 5);
+ assert(q.c.get_allocator() == test_allocator<int>(6));
+ assert(q.top() == int(4));
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_move_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_move_alloc.pass.cpp
new file mode 100644
index 00000000000..d4df36cf2af
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_move_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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+// priority_queue(priority_queue&& q, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+#include "test_allocator.h"
+
+template <class T>
+struct test
+ : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
+{
+ typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
+ typedef typename base::container_type container_type;
+ typedef typename base::value_compare value_compare;
+
+ explicit test(const test_allocator<int>& a) : base(a) {}
+ test(const value_compare& comp, const test_allocator<int>& a)
+ : base(comp, c, a) {}
+ test(const value_compare& comp, const container_type& c,
+ const test_allocator<int>& a) : base(comp, c, a) {}
+ test(const value_compare& comp, container_type&& c,
+ const test_allocator<int>& a) : base(comp, std::move(c), a) {}
+ test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+ test_allocator<int> get_allocator() {return c.get_allocator();}
+
+ using base::c;
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test<MoveOnly> qo(std::less<MoveOnly>(),
+ make<std::vector<MoveOnly, test_allocator<MoveOnly> > >(5),
+ test_allocator<MoveOnly>(2));
+ test<MoveOnly> q(std::move(qo), test_allocator<MoveOnly>(6));
+ assert(q.size() == 5);
+ assert(q.c.get_allocator() == test_allocator<MoveOnly>(6));
+ assert(q.top() == MoveOnly(4));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_copy.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_copy.pass.cpp
new file mode 100644
index 00000000000..82e44b414f6
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_copy.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue& operator=(const priority_queue&) = default;
+
+#include <queue>
+#include <cassert>
+#include <functional>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+int main()
+{
+ std::vector<int> v = make<std::vector<int> >(5);
+ std::priority_queue<int, std::vector<int>, std::greater<int> > qo(std::greater<int>(), v);
+ std::priority_queue<int, std::vector<int>, std::greater<int> > q;
+ q = qo;
+ assert(q.size() == 5);
+ assert(q.top() == 0);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_move.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_move.pass.cpp
new file mode 100644
index 00000000000..07726f60b84
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/assign_move.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue& operator=(priority_queue&& q);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::priority_queue<MoveOnly> qo(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5));
+ std::priority_queue<MoveOnly> q;
+ q = std::move(qo);
+ assert(q.size() == 5);
+ assert(q.top() == MoveOnly(4));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp
new file mode 100644
index 00000000000..f543b6379f1
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// explicit priority_queue(const Compare& comp);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+
+int main()
+{
+ std::priority_queue<int, std::vector<int, stack_allocator<int, 10> > > q((std::less<int>()));
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ assert(q.size() == 2);
+ assert(q.top() == 2);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp
new file mode 100644
index 00000000000..2c73cbc62c6
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_container.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// explicit priority_queue(const Compare& comp, const container_type& c);
+
+#include <queue>
+#include <cassert>
+#include <functional>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+int main()
+{
+ std::vector<int> v = make<std::vector<int> >(5);
+ std::priority_queue<int, std::vector<int>, std::greater<int> > q(std::greater<int>(), v);
+ assert(q.size() == 5);
+ assert(q.top() == 0);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.pass.cpp
new file mode 100644
index 00000000000..40e36456f1f
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_comp_rcontainer.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// explicit priority_queue(const Compare& comp, container_type&& c);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::priority_queue<MoveOnly> q(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5));
+ assert(q.size() == 5);
+ assert(q.top() == MoveOnly(4));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_copy.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_copy.pass.cpp
new file mode 100644
index 00000000000..f1129bc1bbc
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_copy.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue(const priority_queue&) = default;
+
+#include <queue>
+#include <cassert>
+#include <functional>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+int main()
+{
+ std::vector<int> v = make<std::vector<int> >(5);
+ std::priority_queue<int, std::vector<int>, std::greater<int> > qo(std::greater<int>(), v);
+ std::priority_queue<int, std::vector<int>, std::greater<int> > q = qo;
+ assert(q.size() == 5);
+ assert(q.top() == 0);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp
new file mode 100644
index 00000000000..2bffe80ae11
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_default.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+#include <queue>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+
+int main()
+{
+ std::priority_queue<int, std::vector<int, stack_allocator<int, 10> > > q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ assert(q.size() == 2);
+ assert(q.top() == 2);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter.pass.cpp
new file mode 100644
index 00000000000..1aaa8a3c659
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class InputIterator>
+// priority_queue(InputIterator first, InputIterator last);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ int a[] = {3, 5, 2, 0, 6, 8, 1};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ std::priority_queue<int> q(a, an);
+ assert(q.size() == an - a);
+ assert(q.top() == 8);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp.pass.cpp
new file mode 100644
index 00000000000..17a698c15df
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class InputIterator>
+// priority_queue(InputIterator first, InputIterator last, const Compare& comp);
+
+#include <queue>
+#include <cassert>
+#include <functional>
+
+int main()
+{
+ int a[] = {3, 5, 2, 0, 6, 8, 1};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ std::priority_queue<int, std::vector<int>, std::greater<int> >
+ q(a, an, std::greater<int>());
+ assert(q.size() == an - a);
+ assert(q.top() == 0);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_cont.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_cont.pass.cpp
new file mode 100644
index 00000000000..b44d7d38c6f
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_cont.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class InputIterator>
+// priority_queue(InputIterator first, InputIterator last,
+// const Compare& comp, const container_type& c);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ int a[] = {3, 5, 2, 0, 6, 8, 1};
+ const int n = sizeof(a)/sizeof(a[0]);
+ std::vector<int> v(a, a+n/2);
+ std::priority_queue<int> q(a+n/2, a+n, std::less<int>(), v);
+ assert(q.size() == n);
+ assert(q.top() == 8);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_rcont.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_rcont.pass.cpp
new file mode 100644
index 00000000000..b81daf98d8e
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_iter_iter_comp_rcont.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class InputIterator>
+// priority_queue(InputIterator first, InputIterator last,
+// const Compare& comp, container_type&& c);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ int a[] = {3, 5, 2, 0, 6, 8, 1};
+ const int n = sizeof(a)/sizeof(a[0]);
+ std::priority_queue<MoveOnly> q(a+n/2, a+n,
+ std::less<MoveOnly>(),
+ std::vector<MoveOnly>(a, a+n/2));
+ assert(q.size() == n);
+ assert(q.top() == MoveOnly(8));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_move.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_move.pass.cpp
new file mode 100644
index 00000000000..ad23f262545
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/ctor_move.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue(priority_queue&& q);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::priority_queue<MoveOnly> qo(std::less<MoveOnly>(), make<std::vector<MoveOnly> >(5));
+ std::priority_queue<MoveOnly> q = std::move(qo);
+ assert(q.size() == 5);
+ assert(q.top() == MoveOnly(4));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp
new file mode 100644
index 00000000000..48e075698ad
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue()
+// noexcept(is_nothrow_default_constructible<container_type>::value &&
+// is_nothrow_default_constructible<Compare>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::priority_queue<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 00000000000..80ad8bdb28b
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// ~priority_queue() // implied noexcept;
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::priority_queue<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_assign_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 00000000000..7fd01d6dcb6
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_assign_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue& operator=(priority_queue&& c)
+// noexcept(is_nothrow_move_assignable<container_type>::value &&
+// is_nothrow_move_assignable<Compare>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::priority_queue<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp
new file mode 100644
index 00000000000..1e7fcd86b46
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue(priority_queue&&)
+// noexcept(is_nothrow_move_constructible<container_type>::value &&
+// is_nothrow_move_constructible<Compare>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::priority_queue<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/emplace.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/emplace.pass.cpp
new file mode 100644
index 00000000000..4f14e93f5f5
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/emplace.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// template <class... Args> void emplace(Args&&... args);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::priority_queue<Emplaceable> q;
+ q.emplace(1, 2.5);
+ assert(q.top() == Emplaceable(1, 2.5));
+ q.emplace(3, 4.5);
+ assert(q.top() == Emplaceable(3, 4.5));
+ q.emplace(2, 3.5);
+ assert(q.top() == Emplaceable(3, 4.5));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/empty.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/empty.pass.cpp
new file mode 100644
index 00000000000..f0c914a0427
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/empty.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// bool empty() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::priority_queue<int> q;
+ assert(q.empty());
+ q.push(1);
+ assert(!q.empty());
+ q.pop();
+ assert(q.empty());
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/pop.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/pop.pass.cpp
new file mode 100644
index 00000000000..f41b26f68fb
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/pop.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// void pop();
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::priority_queue<int> q;
+ q.push(1);
+ assert(q.top() == 1);
+ q.push(3);
+ assert(q.top() == 3);
+ q.push(2);
+ assert(q.top() == 3);
+ q.pop();
+ assert(q.top() == 2);
+ q.pop();
+ assert(q.top() == 1);
+ q.pop();
+ assert(q.empty());
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/push.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/push.pass.cpp
new file mode 100644
index 00000000000..288e858f93f
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/push.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// void push(const value_type& v);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::priority_queue<int> q;
+ q.push(1);
+ assert(q.top() == 1);
+ q.push(3);
+ assert(q.top() == 3);
+ q.push(2);
+ assert(q.top() == 3);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/push_rvalue.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/push_rvalue.pass.cpp
new file mode 100644
index 00000000000..2f737cecd6a
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/push_rvalue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// void push(value_type&& v);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::priority_queue<MoveOnly> q;
+ q.push(1);
+ assert(q.top() == 1);
+ q.push(3);
+ assert(q.top() == 3);
+ q.push(2);
+ assert(q.top() == 3);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/size.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/size.pass.cpp
new file mode 100644
index 00000000000..0ed579e060b
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/size.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// size_type size() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::priority_queue<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ assert(q.size() == 1);
+ q.pop();
+ assert(q.size() == 0);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/swap.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/swap.pass.cpp
new file mode 100644
index 00000000000..397d67fab52
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/swap.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// void swap(priority_queue& q);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::priority_queue<int> q1;
+ std::priority_queue<int> q2;
+ q1.push(1);
+ q1.push(3);
+ q1.push(2);
+ q1.swap(q2);
+ assert(q1.empty());
+ assert(q2.size() == 3);
+ assert(q2.top() == 3);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/top.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/top.pass.cpp
new file mode 100644
index 00000000000..eddbb926d20
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.members/top.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// const_reference top() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::priority_queue<int> q;
+ q.push(1);
+ assert(q.top() == 1);
+ q.push(3);
+ assert(q.top() == 3);
+ q.push(2);
+ assert(q.top() == 3);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap.pass.cpp
new file mode 100644
index 00000000000..1a828adde35
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// priority_queue();
+
+// template <class T, class Container, class Compare>
+// void swap(priority_queue<T, Container, Compare>& x,
+// priority_queue<T, Container, Compare>& y);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::priority_queue<int> q1;
+ std::priority_queue<int> q2;
+ q1.push(1);
+ q1.push(3);
+ q1.push(2);
+ swap(q1, q2);
+ assert(q1.empty());
+ assert(q2.size() == 3);
+ assert(q2.top() == 3);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp
new file mode 100644
index 00000000000..e40570a120b
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void swap(priority_queue& c)
+// noexcept(__is_nothrow_swappable<container_type>::value &&
+// __is_nothrow_swappable<Compare>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::priority_queue<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/container.adaptors/priority.queue/types.pass.cpp b/libcxx/test/std/containers/container.adaptors/priority.queue/types.pass.cpp
new file mode 100644
index 00000000000..ade20d47d4e
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/priority.queue/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class T, class Container = vector<T>,
+// class Compare = less<typename Container::value_type>>
+// class priority_queue
+// {
+// public:
+// typedef Container container_type;
+// typedef typename container_type::value_type value_type;
+// typedef typename container_type::reference reference;
+// typedef typename container_type::const_reference const_reference;
+// typedef typename container_type::size_type size_type;
+//
+// protected:
+// container_type c;
+// Compare comp;
+
+#include <queue>
+#include <cassert>
+#include <type_traits>
+
+struct test
+ : private std::priority_queue<int>
+{
+ test()
+ {
+ c.push_back(1);
+ assert(comp(1, 2));
+ }
+};
+
+struct C
+{
+ typedef int value_type;
+ typedef int& reference;
+ typedef const int& const_reference;
+ typedef int size_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::priority_queue<int>::container_type, std::vector<int> >::value), "");
+ static_assert((std::is_same<std::priority_queue<double, std::deque<int> >::container_type, std::deque<int> >::value), "");
+ static_assert((std::is_same<std::priority_queue<double, std::deque<int> >::value_type, int>::value), "");
+ static_assert((std::is_same<std::priority_queue<int>::reference, std::vector<int>::reference>::value), "");
+ static_assert((std::is_same<std::priority_queue<int>::const_reference, std::vector<int>::const_reference>::value), "");
+ static_assert((std::is_same<std::priority_queue<int>::size_type, std::vector<int>::size_type>::value), "");
+ static_assert((std::uses_allocator<std::priority_queue<int>, std::allocator<int> >::value), "");
+ static_assert((!std::uses_allocator<std::priority_queue<int, C>, std::allocator<int> >::value), "");
+ test t;
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_alloc.pass.cpp
new file mode 100644
index 00000000000..b3ee758182a
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+// explicit queue(const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+
+struct test
+ : private std::queue<int, std::deque<int, test_allocator<int> > >
+{
+ typedef std::queue<int, std::deque<int, test_allocator<int> > > base;
+
+ explicit test(const test_allocator<int>& a) : base(a) {}
+ test(const container_type& c, const test_allocator<int>& a) : base(c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {}
+ test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_allocator<int> get_allocator() {return c.get_allocator();}
+};
+
+int main()
+{
+ test q(test_allocator<int>(3));
+ assert(q.get_allocator() == test_allocator<int>(3));
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.pass.cpp
new file mode 100644
index 00000000000..16ba1747dd8
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_container_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+// queue(const container_type& c, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+typedef std::deque<int, test_allocator<int> > C;
+
+struct test
+ : public std::queue<int, C>
+{
+ typedef std::queue<int, C> base;
+
+ explicit test(const test_allocator<int>& a) : base(a) {}
+ test(const container_type& c, const test_allocator<int>& a) : base(c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {}
+ test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_allocator<int> get_allocator() {return c.get_allocator();}
+};
+
+int main()
+{
+ C d = make<C>(5);
+ test q(d, test_allocator<int>(4));
+ assert(q.get_allocator() == test_allocator<int>(4));
+ assert(q.size() == 5);
+ for (int i = 0; i < d.size(); ++i)
+ {
+ assert(q.front() == d[i]);
+ q.pop();
+ }
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_queue_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_queue_alloc.pass.cpp
new file mode 100644
index 00000000000..70eaa18f9e2
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_queue_alloc.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+// queue(const queue& q, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+typedef std::deque<int, test_allocator<int> > C;
+
+template <class T>
+struct test
+ : public std::queue<T, C>
+{
+ typedef std::queue<T, C> base;
+ typedef test_allocator<int> allocator_type;
+ typedef typename base::container_type container_type;
+
+ explicit test(const allocator_type& a) : base(a) {}
+ test(const container_type& c, const allocator_type& a) : base(c, a) {}
+ test(const test& q, const allocator_type& a) : base(q, a) {}
+ allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+int main()
+{
+ test<int> q(make<C>(5), test_allocator<int>(4));
+ test<int> q2(q, test_allocator<int>(5));
+ assert(q2.get_allocator() == test_allocator<int>(5));
+ assert(q2.size() == 5);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp
new file mode 100644
index 00000000000..b752238056b
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+// queue(const container_type& c, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C;
+
+template <class T>
+struct test
+ : public std::queue<T, C>
+{
+ typedef std::queue<T, C> base;
+ typedef test_allocator<MoveOnly> allocator_type;
+ typedef typename base::container_type container_type;
+
+ explicit test(const allocator_type& a) : base(a) {}
+ test(const container_type& c, const allocator_type& a) : base(c, a) {}
+ test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {}
+ test(test&& q, const allocator_type& a) : base(std::move(q), a) {}
+ allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
+ assert(q.get_allocator() == test_allocator<MoveOnly>(4));
+ assert(q.size() == 5);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.pass.cpp
new file mode 100644
index 00000000000..11b4ecd3b0a
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rqueue_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class Alloc>
+// queue(queue&& q, const Alloc& a);
+
+#include <queue>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C;
+
+template <class T>
+struct test
+ : public std::queue<T, C>
+{
+ typedef std::queue<T, C> base;
+ typedef test_allocator<MoveOnly> allocator_type;
+ typedef typename base::container_type container_type;
+
+ explicit test(const allocator_type& a) : base(a) {}
+ test(const container_type& c, const allocator_type& a) : base(c, a) {}
+ test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {}
+ test(test&& q, const allocator_type& a) : base(std::move(q), a) {}
+ allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
+ test<MoveOnly> q2(std::move(q), test_allocator<MoveOnly>(5));
+ assert(q2.get_allocator() == test_allocator<MoveOnly>(5));
+ assert(q2.size() == 5);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_container.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_container.pass.cpp
new file mode 100644
index 00000000000..c4ab955c311
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_container.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// explicit queue(const container_type& c);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+int main()
+{
+ std::deque<int> d = make<std::deque<int> >(5);
+ std::queue<int> q(d);
+ assert(q.size() == 5);
+ for (int i = 0; i < d.size(); ++i)
+ {
+ assert(q.front() == d[i]);
+ q.pop();
+ }
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_copy.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_copy.pass.cpp
new file mode 100644
index 00000000000..998f849797c
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_copy.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue(const queue&) = default;
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+int main()
+{
+ std::queue<int> q(make<std::deque<int> >(5));
+ std::queue<int> q2 = q;
+ assert(q2 == q);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_default.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_default.pass.cpp
new file mode 100644
index 00000000000..e6aadd39dd9
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue();
+
+#include <queue>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+
+int main()
+{
+ std::queue<int, std::vector<int, stack_allocator<int, 10> > > q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ assert(q.size() == 2);
+ assert(q.front() == 1);
+ assert(q.back() == 2);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_move.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_move.pass.cpp
new file mode 100644
index 00000000000..f168209f83d
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_move.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue(queue&& q);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+ std::queue<MoveOnly> q2 = std::move(q);
+ assert(q2.size() == 5);
+ assert(q.empty());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp
new file mode 100644
index 00000000000..2f6c3dab1c6
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/ctor_rcontainer.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// explicit queue(container_type&& c);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+ assert(q.size() == 5);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp
new file mode 100644
index 00000000000..874577c7632
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue()
+// noexcept(is_nothrow_default_constructible<container_type>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::queue<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 00000000000..1af20ecb04b
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// ~queue() // implied noexcept;
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::queue<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.cons/move_assign_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 00000000000..1b45bfa93ee
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue& operator=(queue&& c)
+// noexcept(is_nothrow_move_assignable<container_type>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::queue<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp
new file mode 100644
index 00000000000..8fba28fc534
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue(queue&&)
+// noexcept(is_nothrow_move_constructible<container_type>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::queue<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/assign_copy.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/assign_copy.pass.cpp
new file mode 100644
index 00000000000..e9afa0b8c61
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/assign_copy.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue& operator=(const queue& q);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+int main()
+{
+ std::queue<int> q(make<std::deque<int> >(5));
+ std::queue<int> q2;
+ q2 = q;
+ assert(q2 == q);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/assign_move.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/assign_move.pass.cpp
new file mode 100644
index 00000000000..828c0b78dc6
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/assign_move.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// queue& operator=(queue&& q);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::queue<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+ std::queue<MoveOnly> q2;
+ q2 = std::move(q);
+ assert(q2.size() == 5);
+ assert(q.empty());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/back.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/back.pass.cpp
new file mode 100644
index 00000000000..e91edc28308
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/back.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// reference back();
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ q.push(3);
+ int& ir = q.back();
+ assert(ir == 3);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/back_const.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/back_const.pass.cpp
new file mode 100644
index 00000000000..f2696e903fe
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/back_const.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// const_reference back() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ q.push(3);
+ const std::queue<int>& cqr = q;
+ const int& cir = cqr.back();
+ assert(cir == 3);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp
new file mode 100644
index 00000000000..1d9c08b156b
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/emplace.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class... Args> void emplace(Args&&... args);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::queue<Emplaceable> q;
+ q.emplace(1, 2.5);
+ q.emplace(2, 3.5);
+ q.emplace(3, 4.5);
+ assert(q.size() == 3);
+ assert(q.front() == Emplaceable(1, 2.5));
+ assert(q.back() == Emplaceable(3, 4.5));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/empty.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/empty.pass.cpp
new file mode 100644
index 00000000000..deac5fa4d0e
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/empty.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// bool empty() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ assert(q.empty());
+ q.push(1);
+ assert(!q.empty());
+ q.pop();
+ assert(q.empty());
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/front.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/front.pass.cpp
new file mode 100644
index 00000000000..4fbbb005386
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/front.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// reference front();
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ q.push(3);
+ int& ir = q.front();
+ assert(ir == 1);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/front_const.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/front_const.pass.cpp
new file mode 100644
index 00000000000..253a27817eb
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/front_const.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// const_reference front() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ q.push(3);
+ const std::queue<int>& cqr = q;
+ const int& cir = cqr.front();
+ assert(cir == 1);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/pop.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/pop.pass.cpp
new file mode 100644
index 00000000000..3da2d122f34
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/pop.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void pop();
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ q.push(3);
+ assert(q.size() == 3);
+ assert(q.front() == 1);
+ assert(q.back() == 3);
+ q.pop();
+ assert(q.size() == 2);
+ assert(q.front() == 2);
+ assert(q.back() == 3);
+ q.pop();
+ assert(q.size() == 1);
+ assert(q.front() == 3);
+ assert(q.back() == 3);
+ q.pop();
+ assert(q.size() == 0);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/push.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/push.pass.cpp
new file mode 100644
index 00000000000..9d462954c29
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/push.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void push(const value_type& v);
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ q.push(1);
+ assert(q.size() == 1);
+ assert(q.front() == 1);
+ assert(q.back() == 1);
+ q.push(2);
+ assert(q.size() == 2);
+ assert(q.front() == 1);
+ assert(q.back() == 2);
+ q.push(3);
+ assert(q.size() == 3);
+ assert(q.front() == 1);
+ assert(q.back() == 3);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp
new file mode 100644
index 00000000000..11883d8cf70
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/push_rv.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void push(value_type&& v);
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::queue<MoveOnly> q;
+ q.push(MoveOnly(1));
+ assert(q.size() == 1);
+ assert(q.front() == MoveOnly(1));
+ assert(q.back() == MoveOnly(1));
+ q.push(MoveOnly(2));
+ assert(q.size() == 2);
+ assert(q.front() == MoveOnly(1));
+ assert(q.back() == MoveOnly(2));
+ q.push(MoveOnly(3));
+ assert(q.size() == 3);
+ assert(q.front() == MoveOnly(1));
+ assert(q.back() == MoveOnly(3));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/size.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/size.pass.cpp
new file mode 100644
index 00000000000..1c72408f469
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/size.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// size_type size() const;
+
+#include <queue>
+#include <cassert>
+
+int main()
+{
+ std::queue<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ assert(q.size() == 1);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/swap.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/swap.pass.cpp
new file mode 100644
index 00000000000..e0744939748
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/swap.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void swap(queue& q);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push(i);
+ return c;
+}
+
+int main()
+{
+ std::queue<int> q1 = make<std::queue<int> >(5);
+ std::queue<int> q2 = make<std::queue<int> >(10);
+ std::queue<int> q1_save = q1;
+ std::queue<int> q2_save = q2;
+ q1.swap(q2);
+ assert(q1 == q2_save);
+ assert(q2 == q1_save);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp
new file mode 100644
index 00000000000..cc918a36170
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.defn/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class T, class Container = deque<T>>
+// class queue
+// {
+// public:
+// typedef Container container_type;
+// typedef typename container_type::value_type value_type;
+// typedef typename container_type::reference reference;
+// typedef typename container_type::const_reference const_reference;
+// typedef typename container_type::size_type size_type;
+//
+// protected:
+// container_type c;
+// ...
+// };
+
+#include <queue>
+#include <type_traits>
+
+struct test
+ : private std::queue<int>
+{
+ test()
+ {
+ c.push_back(1);
+ }
+};
+
+struct C
+{
+ typedef int value_type;
+ typedef int& reference;
+ typedef const int& const_reference;
+ typedef int size_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::queue<int>::container_type, std::deque<int> >::value), "");
+ static_assert((std::is_same<std::queue<double, std::vector<int> >::container_type, std::vector<int> >::value), "");
+ static_assert((std::is_same<std::queue<double, std::vector<int> >::value_type, int>::value), "");
+ static_assert((std::is_same<std::queue<int>::reference, std::deque<int>::reference>::value), "");
+ static_assert((std::is_same<std::queue<int>::const_reference, std::deque<int>::const_reference>::value), "");
+ static_assert((std::is_same<std::queue<int>::size_type, std::deque<int>::size_type>::value), "");
+ static_assert((std::uses_allocator<std::queue<int>, std::allocator<int> >::value), "");
+ static_assert((!std::uses_allocator<std::queue<int, C>, std::allocator<int> >::value), "");
+ test t;
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.ops/eq.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.ops/eq.pass.cpp
new file mode 100644
index 00000000000..a2ad32fec14
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.ops/eq.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class T, class Container>
+// bool operator==(const queue<T, Container>& x,const queue<T, Container>& y);
+//
+// template <class T, class Container>
+// bool operator!=(const queue<T, Container>& x,const queue<T, Container>& y);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push(i);
+ return c;
+}
+
+int main()
+{
+ std::queue<int> q1 = make<std::queue<int> >(5);
+ std::queue<int> q2 = make<std::queue<int> >(10);
+ std::queue<int> q1_save = q1;
+ std::queue<int> q2_save = q2;
+ assert(q1 == q1_save);
+ assert(q1 != q2);
+ assert(q2 == q2_save);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.ops/lt.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.ops/lt.pass.cpp
new file mode 100644
index 00000000000..af08cbaca48
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.ops/lt.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class T, class Container>
+// bool operator< (const queue<T, Container>& x,const queue<T, Container>& y);
+//
+// template <class T, class Container>
+// bool operator> (const queue<T, Container>& x,const queue<T, Container>& y);
+//
+// template <class T, class Container>
+// bool operator>=(const queue<T, Container>& x,const queue<T, Container>& y);
+//
+// template <class T, class Container>
+// bool operator<=(const queue<T, Container>& x,const queue<T, Container>& y);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push(i);
+ return c;
+}
+
+int main()
+{
+ std::queue<int> q1 = make<std::queue<int> >(5);
+ std::queue<int> q2 = make<std::queue<int> >(10);
+ assert(q1 < q2);
+ assert(q2 > q1);
+ assert(q1 <= q2);
+ assert(q2 >= q1);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.special/swap.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.special/swap.pass.cpp
new file mode 100644
index 00000000000..a3f7c43b792
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.special/swap.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// template <class T, class Container>
+// void swap(queue<T, Container>& x, queue<T, Container>& y);
+
+#include <queue>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push(i);
+ return c;
+}
+
+int main()
+{
+ std::queue<int> q1 = make<std::queue<int> >(5);
+ std::queue<int> q2 = make<std::queue<int> >(10);
+ std::queue<int> q1_save = q1;
+ std::queue<int> q2_save = q2;
+ swap(q1, q2);
+ assert(q1 == q2_save);
+ assert(q2 == q1_save);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp
new file mode 100644
index 00000000000..5c9b7756b8a
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+// void swap(queue& c)
+// noexcept(__is_nothrow_swappable<container_type>::value);
+
+// This tests a conforming extension
+
+#include <queue>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::queue<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/container.adaptors/queue/version.pass.cpp b/libcxx/test/std/containers/container.adaptors/queue/version.pass.cpp
new file mode 100644
index 00000000000..35b94b33c51
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/queue/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <queue>
+
+#include <queue>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.pass.cpp
new file mode 100644
index 00000000000..94899d4f1b5
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class Alloc>
+// explicit stack(const Alloc& a);
+
+#include <stack>
+#include <cassert>
+
+#include "test_allocator.h"
+
+struct test
+ : private std::stack<int, std::deque<int, test_allocator<int> > >
+{
+ typedef std::stack<int, std::deque<int, test_allocator<int> > > base;
+
+ explicit test(const test_allocator<int>& a) : base(a) {}
+ test(const container_type& c, const test_allocator<int>& a) : base(c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {}
+ test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_allocator<int> get_allocator() {return c.get_allocator();}
+};
+
+int main()
+{
+ test q(test_allocator<int>(3));
+ assert(q.get_allocator() == test_allocator<int>(3));
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.pass.cpp
new file mode 100644
index 00000000000..fe8622751c9
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_container_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class Alloc>
+// stack(const container_type& c, const Alloc& a);
+
+#include <stack>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+typedef std::deque<int, test_allocator<int> > C;
+
+struct test
+ : public std::stack<int, C>
+{
+ typedef std::stack<int, C> base;
+
+ explicit test(const test_allocator<int>& a) : base(a) {}
+ test(const container_type& c, const test_allocator<int>& a) : base(c, a) {}
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test(container_type&& c, const test_allocator<int>& a) : base(std::move(c), a) {}
+ test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_allocator<int> get_allocator() {return c.get_allocator();}
+};
+
+int main()
+{
+ C d = make<C>(5);
+ test q(d, test_allocator<int>(4));
+ assert(q.get_allocator() == test_allocator<int>(4));
+ assert(q.size() == 5);
+ for (int i = 0; i < d.size(); ++i)
+ {
+ assert(q.top() == d[d.size() - i - 1]);
+ q.pop();
+ }
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_copy_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_copy_alloc.pass.cpp
new file mode 100644
index 00000000000..33cb4dd52b3
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_copy_alloc.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class Alloc>
+// stack(const stack& q, const Alloc& a);
+
+#include <stack>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(int(i));
+ return c;
+}
+
+typedef std::deque<int, test_allocator<int> > C;
+
+template <class T>
+struct test
+ : public std::stack<T, C>
+{
+ typedef std::stack<T, C> base;
+ typedef test_allocator<int> allocator_type;
+ typedef typename base::container_type container_type;
+
+ explicit test(const allocator_type& a) : base(a) {}
+ test(const container_type& c, const allocator_type& a) : base(c, a) {}
+ test(const test& q, const allocator_type& a) : base(q, a) {}
+ allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+int main()
+{
+ test<int> q(make<C>(5), test_allocator<int>(4));
+ test<int> q2(q, test_allocator<int>(5));
+ assert(q2.get_allocator() == test_allocator<int>(5));
+ assert(q2.size() == 5);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.pass.cpp
new file mode 100644
index 00000000000..16ba9d76cd0
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rcontainer_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class Alloc>
+// stack(const container_type& c, const Alloc& a);
+
+#include <stack>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C;
+
+template <class T>
+struct test
+ : public std::stack<T, C>
+{
+ typedef std::stack<T, C> base;
+ typedef test_allocator<MoveOnly> allocator_type;
+ typedef typename base::container_type container_type;
+
+ explicit test(const allocator_type& a) : base(a) {}
+ test(const container_type& c, const allocator_type& a) : base(c, a) {}
+ test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {}
+ test(test&& q, const allocator_type& a) : base(std::move(q), a) {}
+ allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
+ assert(q.get_allocator() == test_allocator<MoveOnly>(4));
+ assert(q.size() == 5);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.pass.cpp
new file mode 100644
index 00000000000..19d968a0854
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons.alloc/ctor_rqueue_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class Alloc>
+// stack(stack&& q, const Alloc& a);
+
+#include <stack>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C;
+
+template <class T>
+struct test
+ : public std::stack<T, C>
+{
+ typedef std::stack<T, C> base;
+ typedef test_allocator<MoveOnly> allocator_type;
+ typedef typename base::container_type container_type;
+
+ explicit test(const allocator_type& a) : base(a) {}
+ test(const container_type& c, const allocator_type& a) : base(c, a) {}
+ test(container_type&& c, const allocator_type& a) : base(std::move(c), a) {}
+ test(test&& q, const allocator_type& a) : base(std::move(q), a) {}
+ allocator_type get_allocator() {return this->c.get_allocator();}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
+ test<MoveOnly> q2(std::move(q), test_allocator<MoveOnly>(5));
+ assert(q2.get_allocator() == test_allocator<MoveOnly>(5));
+ assert(q2.size() == 5);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp
new file mode 100644
index 00000000000..9dc05013e3d
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_container.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// explicit stack(const container_type& c);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+int main()
+{
+ std::deque<int> d = make<std::deque<int> >(5);
+ std::stack<int> q(d);
+ assert(q.size() == 5);
+ for (int i = 0; i < d.size(); ++i)
+ {
+ assert(q.top() == d[d.size() - i - 1]);
+ q.pop();
+ }
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_copy.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_copy.pass.cpp
new file mode 100644
index 00000000000..8673e06ce93
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_copy.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack(const stack&) = default;
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+int main()
+{
+ std::stack<int> q(make<std::deque<int> >(5));
+ std::stack<int> q2 = q;
+ assert(q2 == q);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_default.pass.cpp
new file mode 100644
index 00000000000..523cd681189
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack();
+
+#include <stack>
+#include <vector>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+
+int main()
+{
+ std::stack<int, std::vector<int, stack_allocator<int, 10> > > q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ assert(q.size() == 2);
+ assert(q.top() == 2);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_move.pass.cpp
new file mode 100644
index 00000000000..173bfc2fe09
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_move.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack(stack&& q);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+ std::stack<MoveOnly> q2 = std::move(q);
+ assert(q2.size() == 5);
+ assert(q.empty());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp
new file mode 100644
index 00000000000..a6c424d9abb
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/ctor_rcontainer.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// explicit stack(container_type&& c);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+ assert(q.size() == 5);
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp
new file mode 100644
index 00000000000..521d9567758
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack()
+// noexcept(is_nothrow_default_constructible<container_type>::value);
+
+// This tests a conforming extension
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::stack<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 00000000000..c502012c8eb
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// ~stack() // implied noexcept;
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::stack<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 00000000000..4952803d042
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack& operator=(stack&& c)
+// noexcept(is_nothrow_move_assignable<container_type>::value);
+
+// This tests a conforming extension
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::stack<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp
new file mode 100644
index 00000000000..c9826834311
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack(stack&&)
+// noexcept(is_nothrow_move_constructible<container_type>::value);
+
+// This tests a conforming extension
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::stack<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.defn/assign_copy.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/assign_copy.pass.cpp
new file mode 100644
index 00000000000..38769e3fb02
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/assign_copy.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack& operator=(const stack& q);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(i);
+ return c;
+}
+
+int main()
+{
+ std::stack<int> q(make<std::deque<int> >(5));
+ std::stack<int> q2;
+ q2 = q;
+ assert(q2 == q);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.defn/assign_move.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/assign_move.pass.cpp
new file mode 100644
index 00000000000..5455299058a
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/assign_move.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// stack& operator=(stack&& q);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push_back(MoveOnly(i));
+ return c;
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::stack<MoveOnly> q(make<std::deque<MoveOnly> >(5));
+ std::stack<MoveOnly> q2;
+ q2 = std::move(q);
+ assert(q2.size() == 5);
+ assert(q.empty());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.defn/emplace.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/emplace.pass.cpp
new file mode 100644
index 00000000000..3573c220ece
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/emplace.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class... Args> void emplace(Args&&... args);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::stack<Emplaceable> q;
+ q.emplace(1, 2.5);
+ q.emplace(2, 3.5);
+ q.emplace(3, 4.5);
+ assert(q.size() == 3);
+ assert(q.top() == Emplaceable(3, 4.5));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.defn/empty.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/empty.pass.cpp
new file mode 100644
index 00000000000..a4f72817413
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/empty.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// bool empty() const;
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+ std::stack<int> q;
+ assert(q.empty());
+ q.push(1);
+ assert(!q.empty());
+ q.pop();
+ assert(q.empty());
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.defn/pop.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/pop.pass.cpp
new file mode 100644
index 00000000000..7ec1bf187ce
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/pop.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// void pop();
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+ std::stack<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ q.push(3);
+ assert(q.size() == 3);
+ assert(q.top() == 3);
+ q.pop();
+ assert(q.size() == 2);
+ assert(q.top() == 2);
+ q.pop();
+ assert(q.size() == 1);
+ assert(q.top() == 1);
+ q.pop();
+ assert(q.size() == 0);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.defn/push.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/push.pass.cpp
new file mode 100644
index 00000000000..6d5c90890d2
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/push.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// void push(const value_type& v);
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+ std::stack<int> q;
+ q.push(1);
+ assert(q.size() == 1);
+ assert(q.top() == 1);
+ q.push(2);
+ assert(q.size() == 2);
+ assert(q.top() == 2);
+ q.push(3);
+ assert(q.size() == 3);
+ assert(q.top() == 3);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.defn/push_rv.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/push_rv.pass.cpp
new file mode 100644
index 00000000000..c769c5d4749
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/push_rv.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// void push(value_type&& v);
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ std::stack<MoveOnly> q;
+ q.push(MoveOnly(1));
+ assert(q.size() == 1);
+ assert(q.top() == MoveOnly(1));
+ q.push(MoveOnly(2));
+ assert(q.size() == 2);
+ assert(q.top() == MoveOnly(2));
+ q.push(MoveOnly(3));
+ assert(q.size() == 3);
+ assert(q.top() == MoveOnly(3));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.defn/size.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/size.pass.cpp
new file mode 100644
index 00000000000..2d802472933
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/size.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// size_type size() const;
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+ std::stack<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ assert(q.size() == 1);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.defn/swap.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/swap.pass.cpp
new file mode 100644
index 00000000000..50a29c48aa2
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/swap.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// void swap(stack& q);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push(i);
+ return c;
+}
+
+int main()
+{
+ std::stack<int> q1 = make<std::stack<int> >(5);
+ std::stack<int> q2 = make<std::stack<int> >(10);
+ std::stack<int> q1_save = q1;
+ std::stack<int> q2_save = q2;
+ q1.swap(q2);
+ assert(q1 == q2_save);
+ assert(q2 == q1_save);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.defn/top.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/top.pass.cpp
new file mode 100644
index 00000000000..6bde162e3eb
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/top.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// reference top();
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+ std::stack<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ q.push(3);
+ int& ir = q.top();
+ assert(ir == 3);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.defn/top_const.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/top_const.pass.cpp
new file mode 100644
index 00000000000..8e43d05fc68
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/top_const.pass.cpp
@@ -0,0 +1,27 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// const_reference top() const;
+
+#include <stack>
+#include <cassert>
+
+int main()
+{
+ std::stack<int> q;
+ assert(q.size() == 0);
+ q.push(1);
+ q.push(2);
+ q.push(3);
+ const std::stack<int>& cqr = q;
+ const int& cir = cqr.top();
+ assert(cir == 3);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.defn/types.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/types.pass.cpp
new file mode 100644
index 00000000000..afc5ebd5375
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.defn/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class T, class Container = deque<T>>
+// class stack
+// {
+// public:
+// typedef Container container_type;
+// typedef typename container_type::value_type value_type;
+// typedef typename container_type::reference reference;
+// typedef typename container_type::const_reference const_reference;
+// typedef typename container_type::size_type size_type;
+//
+// protected:
+// container_type c;
+// ...
+// };
+
+#include <stack>
+#include <vector>
+#include <type_traits>
+
+struct test
+ : private std::stack<int>
+{
+ test()
+ {
+ c.push_back(1);
+ }
+};
+
+struct C
+{
+ typedef int value_type;
+ typedef int& reference;
+ typedef const int& const_reference;
+ typedef int size_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::stack<int>::container_type, std::deque<int> >::value), "");
+ static_assert((std::is_same<std::stack<double, std::vector<int> >::container_type, std::vector<int> >::value), "");
+ static_assert((std::is_same<std::stack<double, std::vector<int> >::value_type, int>::value), "");
+ static_assert((std::is_same<std::stack<int>::reference, std::deque<int>::reference>::value), "");
+ static_assert((std::is_same<std::stack<int>::const_reference, std::deque<int>::const_reference>::value), "");
+ static_assert((std::is_same<std::stack<int>::size_type, std::deque<int>::size_type>::value), "");
+ static_assert((std::uses_allocator<std::stack<int>, std::allocator<int> >::value), "");
+ static_assert((!std::uses_allocator<std::stack<int, C>, std::allocator<int> >::value), "");
+ test t;
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.ops/eq.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.ops/eq.pass.cpp
new file mode 100644
index 00000000000..9b041f7f8d1
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.ops/eq.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class T, class Container>
+// bool operator==(const stack<T, Container>& x,const stack<T, Container>& y);
+//
+// template <class T, class Container>
+// bool operator!=(const stack<T, Container>& x,const stack<T, Container>& y);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push(i);
+ return c;
+}
+
+int main()
+{
+ std::stack<int> q1 = make<std::stack<int> >(5);
+ std::stack<int> q2 = make<std::stack<int> >(10);
+ std::stack<int> q1_save = q1;
+ std::stack<int> q2_save = q2;
+ assert(q1 == q1_save);
+ assert(q1 != q2);
+ assert(q2 == q2_save);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.ops/lt.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.ops/lt.pass.cpp
new file mode 100644
index 00000000000..beb937d4c12
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.ops/lt.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class T, class Container>
+// bool operator< (const stack<T, Container>& x,const stack<T, Container>& y);
+//
+// template <class T, class Container>
+// bool operator> (const stack<T, Container>& x,const stack<T, Container>& y);
+//
+// template <class T, class Container>
+// bool operator>=(const stack<T, Container>& x,const stack<T, Container>& y);
+//
+// template <class T, class Container>
+// bool operator<=(const stack<T, Container>& x,const stack<T, Container>& y);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push(i);
+ return c;
+}
+
+int main()
+{
+ std::stack<int> q1 = make<std::stack<int> >(5);
+ std::stack<int> q2 = make<std::stack<int> >(10);
+ assert(q1 < q2);
+ assert(q2 > q1);
+ assert(q1 <= q2);
+ assert(q2 >= q1);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.special/swap.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.special/swap.pass.cpp
new file mode 100644
index 00000000000..90371146dc0
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.special/swap.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// template <class T, class Container>
+// void swap(stack<T, Container>& x, stack<T, Container>& y);
+
+#include <stack>
+#include <cassert>
+
+template <class C>
+C
+make(int n)
+{
+ C c;
+ for (int i = 0; i < n; ++i)
+ c.push(i);
+ return c;
+}
+
+int main()
+{
+ std::stack<int> q1 = make<std::stack<int> >(5);
+ std::stack<int> q2 = make<std::stack<int> >(10);
+ std::stack<int> q1_save = q1;
+ std::stack<int> q2_save = q2;
+ swap(q1, q2);
+ assert(q1 == q2_save);
+ assert(q2 == q1_save);
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp
new file mode 100644
index 00000000000..d0977f4e3e5
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+// void swap(stack& c)
+// noexcept(__is_nothrow_swappable<container_type>::value);
+
+// This tests a conforming extension
+
+#include <stack>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::stack<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/container.adaptors/stack/version.pass.cpp b/libcxx/test/std/containers/container.adaptors/stack/version.pass.cpp
new file mode 100644
index 00000000000..339d0f4dda8
--- /dev/null
+++ b/libcxx/test/std/containers/container.adaptors/stack/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <stack>
+
+#include <stack>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/container.requirements/associative.reqmts/associative.reqmts.except/nothing_to_do.pass.cpp b/libcxx/test/std/containers/container.requirements/associative.reqmts/associative.reqmts.except/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/containers/container.requirements/associative.reqmts/associative.reqmts.except/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/container.requirements/associative.reqmts/nothing_to_do.pass.cpp b/libcxx/test/std/containers/container.requirements/associative.reqmts/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/containers/container.requirements/associative.reqmts/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/container.requirements/container.requirements.dataraces/nothing_to_do.pass.cpp b/libcxx/test/std/containers/container.requirements/container.requirements.dataraces/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/containers/container.requirements/container.requirements.dataraces/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/container.requirements/container.requirements.general/nothing_to_do.pass.cpp b/libcxx/test/std/containers/container.requirements/container.requirements.general/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/containers/container.requirements/container.requirements.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/container.requirements/nothing_to_do.pass.cpp b/libcxx/test/std/containers/container.requirements/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/containers/container.requirements/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/container.requirements/sequence.reqmts/nothing_to_do.pass.cpp b/libcxx/test/std/containers/container.requirements/sequence.reqmts/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/containers/container.requirements/sequence.reqmts/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/container.requirements/unord.req/nothing_to_do.pass.cpp b/libcxx/test/std/containers/container.requirements/unord.req/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/containers/container.requirements/unord.req/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/container.requirements/unord.req/unord.req.except/nothing_to_do.pass.cpp b/libcxx/test/std/containers/container.requirements/unord.req/unord.req.except/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/containers/container.requirements/unord.req/unord.req.except/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/containers.general/nothing_to_do.pass.cpp b/libcxx/test/std/containers/containers.general/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/containers/containers.general/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/nothing_to_do.pass.cpp b/libcxx/test/std/containers/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/containers/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.cons/default.pass.cpp b/libcxx/test/std/containers/sequences/array/array.cons/default.pass.cpp
new file mode 100644
index 00000000000..7bc62b759c3
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.cons/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// array();
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c;
+ assert(c.size() == 3);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ C c;
+ assert(c.size() == 0);
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp
new file mode 100644
index 00000000000..b9775eef067
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp
@@ -0,0 +1,34 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// Construct with initizializer list
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ assert(c.size() == 3);
+ assert(c[0] == 1);
+ assert(c[1] == 2);
+ assert(c[2] == 3.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ C c = {};
+ assert(c.size() == 0);
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.data/data.pass.cpp b/libcxx/test/std/containers/sequences/array/array.data/data.pass.cpp
new file mode 100644
index 00000000000..08e4fd39d37
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.data/data.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// T *data();
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ T* p = c.data();
+ assert(p[0] == 1);
+ assert(p[1] == 2);
+ assert(p[2] == 3.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ C c = {};
+ T* p = c.data();
+ (void)p; // to placate scan-build
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp b/libcxx/test/std/containers/sequences/array/array.data/data_const.pass.cpp
new file mode 100644
index 00000000000..8eb9762dcb8
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.data/data_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// const T* data() const;
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ const C c = {1, 2, 3.5};
+ const T* p = c.data();
+ assert(p[0] == 1);
+ assert(p[1] == 2);
+ assert(p[2] == 3.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ const C c = {};
+ const T* p = c.data();
+ (void)p; // to placate scan-build
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.fill/fill.pass.cpp b/libcxx/test/std/containers/sequences/array/array.fill/fill.pass.cpp
new file mode 100644
index 00000000000..675f4950062
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.fill/fill.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// void fill(const T& u);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ c.fill(5.5);
+ assert(c.size() == 3);
+ assert(c[0] == 5.5);
+ assert(c[1] == 5.5);
+ assert(c[2] == 5.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ C c = {};
+ c.fill(5.5);
+ assert(c.size() == 0);
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.size/size.pass.cpp b/libcxx/test/std/containers/sequences/array/array.size/size.pass.cpp
new file mode 100644
index 00000000000..fe5a0d5c8db
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.size/size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <class T, size_t N> constexpr size_type array<T,N>::size();
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ assert(c.size() == 3);
+ assert(c.max_size() == 3);
+ assert(!c.empty());
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ C c = {};
+ assert(c.size() == 0);
+ assert(c.max_size() == 0);
+ assert(c.empty());
+ }
+#ifndef _LIBCPP_HAS_NO_CONSTEXPR
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr C c = {1, 2, 3.5};
+ static_assert(c.size() == 3, "");
+ static_assert(c.max_size() == 3, "");
+ static_assert(!c.empty(), "");
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ constexpr C c = {};
+ static_assert(c.size() == 0, "");
+ static_assert(c.max_size() == 0, "");
+ static_assert(c.empty(), "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.special/swap.pass.cpp b/libcxx/test/std/containers/sequences/array/array.special/swap.pass.cpp
new file mode 100644
index 00000000000..08e437739ee
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.special/swap.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <class T, size_t N> void swap(array<T,N>& x, array<T,N>& y);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c1 = {1, 2, 3.5};
+ C c2 = {4, 5, 6.5};
+ swap(c1, c2);
+ assert(c1.size() == 3);
+ assert(c1[0] == 4);
+ assert(c1[1] == 5);
+ assert(c1[2] == 6.5);
+ assert(c2.size() == 3);
+ assert(c2[0] == 1);
+ assert(c2[1] == 2);
+ assert(c2[2] == 3.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ C c1 = {};
+ C c2 = {};
+ swap(c1, c2);
+ assert(c1.size() == 0);
+ assert(c2.size() == 0);
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.swap/swap.pass.cpp b/libcxx/test/std/containers/sequences/array/array.swap/swap.pass.cpp
new file mode 100644
index 00000000000..c7a4cb8df38
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.swap/swap.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// void swap(array& a);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c1 = {1, 2, 3.5};
+ C c2 = {4, 5, 6.5};
+ c1.swap(c2);
+ assert(c1.size() == 3);
+ assert(c1[0] == 4);
+ assert(c1[1] == 5);
+ assert(c1[2] == 6.5);
+ assert(c2.size() == 3);
+ assert(c2[0] == 1);
+ assert(c2[1] == 2);
+ assert(c2[2] == 3.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ C c1 = {};
+ C c2 = {};
+ c1.swap(c2);
+ assert(c1.size() == 0);
+ assert(c2.size() == 0);
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.tuple/get.fail.cpp b/libcxx/test/std/containers/sequences/array/array.tuple/get.fail.cpp
new file mode 100644
index 00000000000..4f4fbcf93af
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.tuple/get.fail.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <size_t I, class T, size_t N> T& get(array<T, N>& a);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ std::get<3>(c) = 5.5; // Can't get element 3!
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.tuple/get.pass.cpp b/libcxx/test/std/containers/sequences/array/array.tuple/get.pass.cpp
new file mode 100644
index 00000000000..d9e242cd420
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.tuple/get.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <size_t I, class T, size_t N> T& get(array<T, N>& a);
+
+#include <array>
+#include <cassert>
+
+#if __cplusplus > 201103L
+struct S {
+ std::array<int, 3> a;
+ int k;
+ constexpr S() : a{1,2,3}, k(std::get<2>(a)) {}
+ };
+
+constexpr std::array<int, 2> getArr () { return { 3, 4 }; }
+#endif
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ std::get<1>(c) = 5.5;
+ assert(c[0] == 1);
+ assert(c[1] == 5.5);
+ assert(c[2] == 3.5);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr C c = {1, 2, 3.5};
+ static_assert(std::get<0>(c) == 1, "");
+ static_assert(std::get<1>(c) == 2, "");
+ static_assert(std::get<2>(c) == 3.5, "");
+ }
+ {
+ static_assert(S().k == 3, "");
+ static_assert(std::get<1>(getArr()) == 4, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp b/libcxx/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp
new file mode 100644
index 00000000000..1cbdfa4ff39
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.tuple/get_const.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <size_t I, class T, size_t N> const T& get(const array<T, N>& a);
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ const C c = {1, 2, 3.5};
+ assert(std::get<0>(c) == 1);
+ assert(std::get<1>(c) == 2);
+ assert(std::get<2>(c) == 3.5);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr const C c = {1, 2, 3.5};
+ static_assert(std::get<0>(c) == 1, "");
+ static_assert(std::get<1>(c) == 2, "");
+ static_assert(std::get<2>(c) == 3.5, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp b/libcxx/test/std/containers/sequences/array/array.tuple/get_rv.pass.cpp
new file mode 100644
index 00000000000..869c1ec9c2d
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.tuple/get_rv.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <size_t I, class T, size_t N> T&& get(array<T, N>&& a);
+
+#include <array>
+#include <memory>
+#include <cassert>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unique_ptr<double> T;
+ typedef std::array<T, 1> C;
+ C c = {std::unique_ptr<double>(new double(3.5))};
+ T t = std::get<0>(std::move(c));
+ assert(*t == 3.5);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.tuple/tuple_element.pass.cpp b/libcxx/test/std/containers/sequences/array/array.tuple/tuple_element.pass.cpp
new file mode 100644
index 00000000000..cd1dad60ade
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.tuple/tuple_element.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// tuple_element<I, array<T, N> >::type
+
+#include <array>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ static_assert((std::is_same<std::tuple_element<0, C>::type, T>::value), "");
+ static_assert((std::is_same<std::tuple_element<1, C>::type, T>::value), "");
+ static_assert((std::is_same<std::tuple_element<2, C>::type, T>::value), "");
+ }
+ {
+ typedef int T;
+ typedef std::array<T, 3> C;
+ static_assert((std::is_same<std::tuple_element<0, C>::type, T>::value), "");
+ static_assert((std::is_same<std::tuple_element<1, C>::type, T>::value), "");
+ static_assert((std::is_same<std::tuple_element<2, C>::type, T>::value), "");
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.tuple/tuple_size.pass.cpp b/libcxx/test/std/containers/sequences/array/array.tuple/tuple_size.pass.cpp
new file mode 100644
index 00000000000..83394b1e0c9
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.tuple/tuple_size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// tuple_size<array<T, N> >::value
+
+#include <array>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ static_assert((std::tuple_size<C>::value == 3), "");
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 0> C;
+ static_assert((std::tuple_size<C>::value == 0), "");
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp b/libcxx/test/std/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp
new file mode 100644
index 00000000000..0aa2f50d8b4
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/array.zero/tested_elsewhere.pass.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// support for zero-sized array
+
+#include <array>
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/sequences/array/at.pass.cpp b/libcxx/test/std/containers/sequences/array/at.pass.cpp
new file mode 100644
index 00000000000..b5cf8a5aaa8
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/at.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// reference operator[] (size_type)
+// const_reference operator[] (size_type); // constexpr in C++14
+// reference at (size_type)
+// const_reference at (size_type); // constexpr in C++14
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ C::reference r1 = c.at(0);
+ assert(r1 == 1);
+ r1 = 5.5;
+ assert(c.front() == 5.5);
+
+ C::reference r2 = c.at(2);
+ assert(r2 == 3.5);
+ r2 = 7.5;
+ assert(c.back() == 7.5);
+
+ try { (void) c.at(3); }
+ catch (const std::out_of_range &) {}
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ const C c = {1, 2, 3.5};
+ C::const_reference r1 = c.at(0);
+ assert(r1 == 1);
+
+ C::const_reference r2 = c.at(2);
+ assert(r2 == 3.5);
+
+ try { (void) c.at(3); }
+ catch (const std::out_of_range &) {}
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr C c = {1, 2, 3.5};
+
+ constexpr T t1 = c.at(0);
+ static_assert (t1 == 1, "");
+
+ constexpr T t2 = c.at(2);
+ static_assert (t2 == 3.5, "");
+ }
+#endif
+
+}
diff --git a/libcxx/test/std/containers/sequences/array/begin.pass.cpp b/libcxx/test/std/containers/sequences/array/begin.pass.cpp
new file mode 100644
index 00000000000..9cba0d6fceb
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/begin.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// iterator begin();
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ C::iterator i;
+ i = c.begin();
+ assert(*i == 1);
+ assert(&*i == c.data());
+ *i = 5.5;
+ assert(c[0] == 5.5);
+ }
+ {
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/front_back.pass.cpp b/libcxx/test/std/containers/sequences/array/front_back.pass.cpp
new file mode 100644
index 00000000000..45a963b9947
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/front_back.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// reference front();
+// reference back();
+// const_reference front(); // constexpr in C++14
+// const_reference back(); // constexpr in C++14
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+
+ C::reference r1 = c.front();
+ assert(r1 == 1);
+ r1 = 5.5;
+ assert(c[0] == 5.5);
+
+ C::reference r2 = c.back();
+ assert(r2 == 3.5);
+ r2 = 7.5;
+ assert(c[2] == 7.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ const C c = {1, 2, 3.5};
+ C::const_reference r1 = c.front();
+ assert(r1 == 1);
+
+ C::const_reference r2 = c.back();
+ assert(r2 == 3.5);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr C c = {1, 2, 3.5};
+
+ constexpr T t1 = c.front();
+ static_assert (t1 == 1, "");
+
+ constexpr T t2 = c.back();
+ static_assert (t2 == 3.5, "");
+ }
+#endif
+
+}
diff --git a/libcxx/test/std/containers/sequences/array/indexing.pass.cpp b/libcxx/test/std/containers/sequences/array/indexing.pass.cpp
new file mode 100644
index 00000000000..e4dda0dc5cf
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/indexing.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// reference operator[] (size_type)
+// const_reference operator[] (size_type); // constexpr in C++14
+// reference at (size_type)
+// const_reference at (size_type); // constexpr in C++14
+
+#include <array>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ C c = {1, 2, 3.5};
+ C::reference r1 = c[0];
+ assert(r1 == 1);
+ r1 = 5.5;
+ assert(c.front() == 5.5);
+
+ C::reference r2 = c[2];
+ assert(r2 == 3.5);
+ r2 = 7.5;
+ assert(c.back() == 7.5);
+ }
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ const C c = {1, 2, 3.5};
+ C::const_reference r1 = c[0];
+ assert(r1 == 1);
+ C::const_reference r2 = c[2];
+ assert(r2 == 3.5);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef double T;
+ typedef std::array<T, 3> C;
+ constexpr C c = {1, 2, 3.5};
+
+ constexpr T t1 = c[0];
+ static_assert (t1 == 1, "");
+
+ constexpr T t2 = c[2];
+ static_assert (t2 == 3.5, "");
+ }
+#endif
+
+}
diff --git a/libcxx/test/std/containers/sequences/array/iterators.pass.cpp b/libcxx/test/std/containers/sequences/array/iterators.pass.cpp
new file mode 100644
index 00000000000..98997d8c26d
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/iterators.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// iterator, const_iterator
+
+#include <array>
+#include <iterator>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::array<int, 5> C;
+ C c;
+ C::iterator i;
+ i = c.begin();
+ C::const_iterator j;
+ j = c.cbegin();
+ assert(i == j);
+ }
+ {
+ typedef std::array<int, 0> C;
+ C c;
+ C::iterator i;
+ i = c.begin();
+ C::const_iterator j;
+ j = c.cbegin();
+ assert(i == j);
+ }
+
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ {
+ typedef std::array<int, 5> C;
+ C::iterator ii1{}, ii2{};
+ C::iterator ii4 = ii1;
+ C::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+ assert ( ii1 == cii );
+
+ assert ( !(ii1 != ii2 ));
+ assert ( !(ii1 != cii ));
+
+ C c;
+ assert ( c.begin() == std::begin(c));
+ assert ( c.cbegin() == std::cbegin(c));
+ assert ( c.rbegin() == std::rbegin(c));
+ assert ( c.crbegin() == std::crbegin(c));
+ assert ( c.end() == std::end(c));
+ assert ( c.cend() == std::cend(c));
+ assert ( c.rend() == std::rend(c));
+ assert ( c.crend() == std::crend(c));
+
+ assert ( std::begin(c) != std::end(c));
+ assert ( std::rbegin(c) != std::rend(c));
+ assert ( std::cbegin(c) != std::cend(c));
+ assert ( std::crbegin(c) != std::crend(c));
+ }
+ {
+ typedef std::array<int, 0> 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 ));
+ assert (!(ii1 < cii ));
+ assert (!(cii < ii1 ));
+ assert ( (ii1 <= cii ));
+ assert ( (cii <= ii1 ));
+ assert (!(ii1 > cii ));
+ assert (!(cii > ii1 ));
+ assert ( (ii1 >= cii ));
+ assert ( (cii >= ii1 ));
+ assert (cii - ii1 == 0);
+ assert (ii1 - cii == 0);
+
+ C c;
+ assert ( c.begin() == std::begin(c));
+ assert ( c.cbegin() == std::cbegin(c));
+ assert ( c.rbegin() == std::rbegin(c));
+ assert ( c.crbegin() == std::crbegin(c));
+ assert ( c.end() == std::end(c));
+ assert ( c.cend() == std::cend(c));
+ assert ( c.rend() == std::rend(c));
+ assert ( c.crend() == std::crend(c));
+
+ assert ( std::begin(c) == std::end(c));
+ assert ( std::rbegin(c) == std::rend(c));
+ assert ( std::cbegin(c) == std::cend(c));
+ assert ( std::crbegin(c) == std::crend(c));
+ }
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/array/types.pass.cpp b/libcxx/test/std/containers/sequences/array/types.pass.cpp
new file mode 100644
index 00000000000..065ade959d0
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/types.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+// template <class T, size_t N >
+// struct array
+// {
+// // types:
+// typedef T& reference;
+// typedef const T& const_reference;
+// typedef implementation defined iterator;
+// typedef implementation defined const_iterator;
+// typedef T value_type;
+// typedef T* pointer;
+// typedef size_t size_type;
+// typedef ptrdiff_t difference_type;
+// typedef T value_type;
+// typedef std::reverse_iterator<iterator> reverse_iterator;
+// typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
+#include <array>
+#include <iterator>
+#include <type_traits>
+
+int main()
+{
+ {
+ typedef double T;
+ typedef std::array<T, 10> C;
+ static_assert((std::is_same<C::reference, T&>::value), "");
+ static_assert((std::is_same<C::const_reference, const T&>::value), "");
+ static_assert((std::is_same<C::iterator, T*>::value), "");
+ static_assert((std::is_same<C::const_iterator, const T*>::value), "");
+ static_assert((std::is_same<C::pointer, T*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const T*>::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), "");
+ static_assert((std::is_same<C::reverse_iterator, std::reverse_iterator<C::iterator> >::value), "");
+ static_assert((std::is_same<C::const_reverse_iterator, std::reverse_iterator<C::const_iterator> >::value), "");
+ }
+ {
+ typedef int* T;
+ typedef std::array<T, 0> C;
+ static_assert((std::is_same<C::reference, T&>::value), "");
+ static_assert((std::is_same<C::const_reference, const T&>::value), "");
+ static_assert((std::is_same<C::iterator, T*>::value), "");
+ static_assert((std::is_same<C::const_iterator, const T*>::value), "");
+ static_assert((std::is_same<C::pointer, T*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const T*>::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), "");
+ static_assert((std::is_same<C::reverse_iterator, std::reverse_iterator<C::iterator> >::value), "");
+ static_assert((std::is_same<C::const_reverse_iterator, std::reverse_iterator<C::const_iterator> >::value), "");
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/array/version.pass.cpp b/libcxx/test/std/containers/sequences/array/version.pass.cpp
new file mode 100644
index 00000000000..b89a8dd8cca
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/array/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <array>
+
+#include <array>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.capacity/access.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.capacity/access.pass.cpp
new file mode 100644
index 00000000000..77aaf3c131e
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.capacity/access.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// reference operator[](size_type __i);
+// const_reference operator[](size_type __i) const;
+//
+// reference at(size_type __i);
+// const_reference at(size_type __i) const;
+//
+// reference front();
+// const_reference front() const;
+//
+// reference back();
+// const_reference back() const;
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+int main()
+{
+ {
+ std::deque<int> c = make<std::deque<int> >(10);
+ for (unsigned i = 0; i < 10; ++i)
+ assert(c[i] == i);
+ for (unsigned i = 0; i < 10; ++i)
+ assert(c.at(i) == i);
+ assert(c.front() == 0);
+ assert(c.back() == 9);
+ }
+ {
+ const std::deque<int> c = make<std::deque<int> >(10);
+ for (unsigned i = 0; i < 10; ++i)
+ assert(c[i] == i);
+ for (unsigned i = 0; i < 10; ++i)
+ assert(c.at(i) == i);
+ assert(c.front() == 0);
+ assert(c.back() == 9);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10);
+ for (unsigned i = 0; i < 10; ++i)
+ assert(c[i] == i);
+ for (unsigned i = 0; i < 10; ++i)
+ assert(c.at(i) == i);
+ assert(c.front() == 0);
+ assert(c.back() == 9);
+ }
+ {
+ const std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10);
+ for (unsigned i = 0; i < 10; ++i)
+ assert(c[i] == i);
+ for (unsigned i = 0; i < 10; ++i)
+ assert(c.at(i) == i);
+ assert(c.front() == 0);
+ assert(c.back() == 9);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.capacity/resize_size.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.capacity/resize_size.pass.cpp
new file mode 100644
index 00000000000..8f732a06c7c
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.capacity/resize_size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void resize(size_type n);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void
+test(C& c1, int size)
+{
+ typedef typename C::const_iterator CI;
+ typename C::size_type c1_osize = c1.size();
+ c1.resize(size);
+ assert(c1.size() == size);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ CI i = c1.begin();
+ for (int j = 0; j < std::min(c1_osize, c1.size()); ++j, ++i)
+ assert(*i == j);
+ for (int j = c1_osize; j < c1.size(); ++j, ++i)
+ assert(*i == 0);
+}
+
+template <class C>
+void
+testN(int start, int N, int M)
+{
+ typedef typename C::const_iterator CI;
+ C c1 = make<C>(N, start);
+ test(c1, M);
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int, min_allocator<int>>>(rng[i], rng[j], rng[k]);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp
new file mode 100644
index 00000000000..1d1522cbcb3
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.capacity/resize_size_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void resize(size_type n, const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void
+test(C& c1, int size, int x)
+{
+ typedef typename C::const_iterator CI;
+ typename C::size_type c1_osize = c1.size();
+ c1.resize(size, x);
+ assert(c1.size() == size);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ CI i = c1.begin();
+ for (int j = 0; j < std::min(c1_osize, c1.size()); ++j, ++i)
+ assert(*i == j);
+ for (int j = c1_osize; j < c1.size(); ++j, ++i)
+ assert(*i == x);
+}
+
+template <class C>
+void
+testN(int start, int N, int M)
+{
+ typedef typename C::const_iterator CI;
+ C c1 = make<C>(N, start);
+ test(c1, M, -10);
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int, min_allocator<int>>>(rng[i], rng[j], rng[k]);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.capacity/shrink_to_fit.pass.cpp
new file mode 100644
index 00000000000..0ac1d5a680c
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.capacity/shrink_to_fit.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void shrink_to_fit();
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void
+test(C& c1)
+{
+ C s = c1;
+ c1.shrink_to_fit();
+ assert(c1 == s);
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ typedef typename C::const_iterator CI;
+ C c1 = make<C>(N, start);
+ test(c1);
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/alloc.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/alloc.pass.cpp
new file mode 100644
index 00000000000..841bfd9f8a7
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// explicit deque(const allocator_type& a);
+
+#include <deque>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "../../../NotConstructible.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test(const Allocator& a)
+{
+ std::deque<T, Allocator> d(a);
+ assert(d.size() == 0);
+ assert(d.get_allocator() == a);
+}
+
+int main()
+{
+ test<int>(std::allocator<int>());
+ test<NotConstructible>(test_allocator<NotConstructible>(3));
+#if __cplusplus >= 201103L
+ test<int>(min_allocator<int>());
+ test<NotConstructible>(min_allocator<NotConstructible>{});
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 00000000000..c760b437244
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/assign_initializer_list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void assign(initializer_list<value_type> il);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::deque<int> d;
+ d.assign({3, 4, 5, 6});
+ assert(d.size() == 4);
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::deque<int, min_allocator<int>> d;
+ d.assign({3, 4, 5, 6});
+ assert(d.size() == 4);
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp
new file mode 100644
index 00000000000..6594984fc0d
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class InputIterator>
+// void assign(InputIterator f, InputIterator l);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void
+test(C& c1, const C& c2)
+{
+ std::size_t c1_osize = c1.size();
+ c1.assign(c2.begin(), c2.end());
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ assert(c1 == c2);
+}
+
+template <class C>
+void
+testN(int start, int N, int M)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ test(c1, c2);
+}
+
+template <class C>
+void
+testI(C& c1, const C& c2)
+{
+ typedef typename C::const_iterator CI;
+ typedef input_iterator<CI> ICI;
+ std::size_t c1_osize = c1.size();
+ c1.assign(ICI(c2.begin()), ICI(c2.end()));
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ assert(c1 == c2);
+}
+
+template <class C>
+void
+testNI(int start, int N, int M)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ testI(c1, c2);
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+ testNI<std::deque<int> >(1500, 2000, 1000);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
+ testNI<std::deque<int, min_allocator<int>> >(1500, 2000, 1000);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/assign_size_value.pass.cpp
new file mode 100644
index 00000000000..fd6dd6e4ab6
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/assign_size_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void assign(size_type n, const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void
+test(C& c1, int size, int v)
+{
+ typedef typename C::const_iterator CI;
+ std::size_t c1_osize = c1.size();
+ c1.assign(size, v);
+ assert(c1.size() == size);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ for (CI i = c1.begin(); i != c1.end(); ++i)
+ assert(*i == v);
+}
+
+template <class C>
+void
+testN(int start, int N, int M)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ C c1 = make<C>(N, start);
+ test(c1, M, -10);
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/copy.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/copy.pass.cpp
new file mode 100644
index 00000000000..fa0c1203ede
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/copy.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(const deque&);
+
+#include <deque>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void
+test(const C& x)
+{
+ C c(x);
+ assert(c == x);
+}
+
+int main()
+{
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ test(std::deque<int>(ab, an));
+ }
+ {
+ std::deque<int, test_allocator<int> > v(3, 2, test_allocator<int>(5));
+ std::deque<int, test_allocator<int> > v2 = v;
+ assert(v2 == v);
+ assert(v2.get_allocator() == v.get_allocator());
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ std::deque<int, other_allocator<int> > v(3, 2, other_allocator<int>(5));
+ std::deque<int, other_allocator<int> > v2 = v;
+ assert(v2 == v);
+ assert(v2.get_allocator() == other_allocator<int>(-2));
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ test(std::deque<int, min_allocator<int>>(ab, an));
+ }
+ {
+ std::deque<int, min_allocator<int> > v(3, 2, min_allocator<int>());
+ std::deque<int, min_allocator<int> > v2 = v;
+ assert(v2 == v);
+ assert(v2.get_allocator() == v.get_allocator());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp
new file mode 100644
index 00000000000..efea4948eba
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/copy_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(const deque& c, const allocator_type& a);
+
+#include <deque>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void
+test(const C& x, const typename C::allocator_type& a)
+{
+ C c(x, a);
+ assert(c == x);
+ assert(c.get_allocator() == a);
+}
+
+int main()
+{
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ test(std::deque<int, test_allocator<int> >(ab, an, test_allocator<int>(3)),
+ test_allocator<int>(4));
+ }
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ test(std::deque<int, other_allocator<int> >(ab, an, other_allocator<int>(3)),
+ other_allocator<int>(4));
+ }
+#if __cplusplus >= 201103L
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ test(std::deque<int, min_allocator<int> >(ab, an, min_allocator<int>()),
+ min_allocator<int>());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/default.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/default.pass.cpp
new file mode 100644
index 00000000000..b725dade70b
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque()
+
+#include <deque>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+#include "../../../NotConstructible.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test()
+{
+ std::deque<T, Allocator> d;
+ assert(d.size() == 0);
+#if __cplusplus >= 201103L
+ std::deque<T, Allocator> d1 = {};
+ assert(d1.size() == 0);
+#endif
+}
+
+int main()
+{
+ test<int, std::allocator<int> >();
+ test<NotConstructible, stack_allocator<NotConstructible, 1> >();
+#if __cplusplus >= 201103L
+ test<int, min_allocator<int> >();
+ test<NotConstructible, min_allocator<NotConstructible> >();
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp
new file mode 100644
index 00000000000..3605a1b636f
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque()
+// noexcept(is_nothrow_default_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::deque<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 00000000000..0f459b2c919
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// ~deque() // implied noexcept;
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+ ~some_alloc() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::deque<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/initializer_list.pass.cpp
new file mode 100644
index 00000000000..a9e0218e2e0
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/initializer_list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(initializer_list<value_type> il);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::deque<int> d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::deque<int, min_allocator<int>> d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp
new file mode 100644
index 00000000000..36c5af60ee3
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(initializer_list<value_type> il, const Allocator& a = allocator_type());
+
+#include <deque>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::deque<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3));
+ assert(d.get_allocator() == test_allocator<int>(3));
+ assert(d.size() == 4);
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::deque<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>());
+ assert(d.get_allocator() == min_allocator<int>());
+ assert(d.size() == 4);
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp
new file mode 100644
index 00000000000..faadf2b1a1d
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class InputIterator> deque(InputIterator f, InputIterator l);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class InputIterator>
+void
+test(InputIterator f, InputIterator l)
+{
+ typedef typename std::iterator_traits<InputIterator>::value_type T;
+ typedef std::allocator<T> Allocator;
+ typedef std::deque<T, Allocator> C;
+ typedef typename C::const_iterator const_iterator;
+ C d(f, l);
+ assert(d.size() == std::distance(f, l));
+ assert(distance(d.begin(), d.end()) == d.size());
+ for (const_iterator i = d.begin(), e = d.end(); i != e; ++i, ++f)
+ assert(*i == *f);
+}
+
+template <class Allocator, class InputIterator>
+void
+test(InputIterator f, InputIterator l)
+{
+ typedef typename std::iterator_traits<InputIterator>::value_type T;
+ typedef std::deque<T, Allocator> C;
+ typedef typename C::const_iterator const_iterator;
+ C d(f, l);
+ assert(d.size() == std::distance(f, l));
+ assert(distance(d.begin(), d.end()) == d.size());
+ for (const_iterator i = d.begin(), e = d.end(); i != e; ++i, ++f)
+ assert(*i == *f);
+}
+
+int main()
+{
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ test(input_iterator<const int*>(ab), input_iterator<const int*>(an));
+ test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an));
+ test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an));
+ test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an));
+ test<stack_allocator<int, 4096> >(ab, an);
+#if __cplusplus >= 201103L
+ test<min_allocator<int> >(ab, an);
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp
new file mode 100644
index 00000000000..b8c3e889929
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class InputIterator>
+// deque(InputIterator f, InputIterator l, const allocator_type& a);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class InputIterator, class Allocator>
+void
+test(InputIterator f, InputIterator l, const Allocator& a)
+{
+ typedef typename std::iterator_traits<InputIterator>::value_type T;
+ typedef std::deque<T, Allocator> C;
+ typedef typename C::const_iterator const_iterator;
+ C d(f, l, a);
+ assert(d.get_allocator() == a);
+ assert(d.size() == std::distance(f, l));
+ assert(distance(d.begin(), d.end()) == d.size());
+ for (const_iterator i = d.begin(), e = d.end(); i != e; ++i, ++f)
+ assert(*i == *f);
+}
+
+int main()
+{
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ test(input_iterator<const int*>(ab), input_iterator<const int*>(an), test_allocator<int>(3));
+ test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an), test_allocator<int>(4));
+ test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an), test_allocator<int>(5));
+ test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an), test_allocator<int>(6));
+#if __cplusplus >= 201103L
+ test(input_iterator<const int*>(ab), input_iterator<const int*>(an), min_allocator<int>());
+ test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an), min_allocator<int>());
+ test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an), min_allocator<int>());
+ test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an), min_allocator<int>());
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/move.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/move.pass.cpp
new file mode 100644
index 00000000000..a20ad4cecbd
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/move.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(deque&&);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef test_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A(1));
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A(2));
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3 = std::move(c1);
+ assert(c2 == c3);
+ assert(c1.size() == 0);
+ assert(c3.get_allocator() == c1.get_allocator());
+ }
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef other_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A(1));
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A(2));
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3 = std::move(c1);
+ assert(c2 == c3);
+ assert(c1.size() == 0);
+ assert(c3.get_allocator() == c1.get_allocator());
+ }
+#if __cplusplus >= 201103L
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef min_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A{});
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A{});
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3 = std::move(c1);
+ assert(c2 == c3);
+ assert(c1.size() == 0);
+ assert(c3.get_allocator() == c1.get_allocator());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/move_alloc.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/move_alloc.pass.cpp
new file mode 100644
index 00000000000..0ba4a2da330
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/move_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(deque&& c, const allocator_type& a);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef test_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A(1));
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A(1));
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3(std::move(c1), A(3));
+ assert(c2 == c3);
+ assert(c3.get_allocator() == A(3));
+ assert(c1.size() != 0);
+ }
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef test_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A(1));
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A(1));
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3(std::move(c1), A(1));
+ assert(c2 == c3);
+ assert(c3.get_allocator() == A(1));
+ assert(c1.size() == 0);
+ }
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef other_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A(1));
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A(1));
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3(std::move(c1), A(3));
+ assert(c2 == c3);
+ assert(c3.get_allocator() == A(3));
+ assert(c1.size() != 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef min_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A{});
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A{});
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3(std::move(c1), A());
+ assert(c2 == c3);
+ assert(c3.get_allocator() == A());
+ assert(c1.size() == 0);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/move_assign.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/move_assign.pass.cpp
new file mode 100644
index 00000000000..bb01dc5c54b
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/move_assign.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque& operator=(deque&& c);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef test_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A(5));
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A(5));
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3(A(5));
+ c3 = std::move(c1);
+ assert(c2 == c3);
+ assert(c1.size() == 0);
+ assert(c3.get_allocator() == A(5));
+ }
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef test_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A(5));
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A(5));
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3(A(6));
+ c3 = std::move(c1);
+ assert(c2 == c3);
+ assert(c1.size() != 0);
+ assert(c3.get_allocator() == A(6));
+ }
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef other_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A(5));
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A(5));
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3(A(6));
+ c3 = std::move(c1);
+ assert(c2 == c3);
+ assert(c1.size() == 0);
+ assert(c3.get_allocator() == A(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ typedef min_allocator<MoveOnly> A;
+ std::deque<MoveOnly, A> c1(A{});
+ for (int* p = ab; p < an; ++p)
+ c1.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c2(A{});
+ for (int* p = ab; p < an; ++p)
+ c2.push_back(MoveOnly(*p));
+ std::deque<MoveOnly, A> c3(A{});
+ c3 = std::move(c1);
+ assert(c2 == c3);
+ assert(c1.size() == 0);
+ assert(c3.get_allocator() == A());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 00000000000..c2bb40a8b6f
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque& operator=(deque&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::deque<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp
new file mode 100644
index 00000000000..36f780703c0
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(deque&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::deque<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/op_equal.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/op_equal.pass.cpp
new file mode 100644
index 00000000000..3a6ec8370b8
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/op_equal.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque& operator=(const deque& c);
+
+#include <deque>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void
+test(const C& x)
+{
+ C c;
+ c = x;
+ assert(c == x);
+}
+
+int main()
+{
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ test(std::deque<int>(ab, an));
+ }
+ {
+ std::deque<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+ std::deque<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == test_allocator<int>(3));
+ }
+ {
+ std::deque<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+ std::deque<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == other_allocator<int>(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45};
+ int* an = ab + sizeof(ab)/sizeof(ab[0]);
+ test(std::deque<int, min_allocator<int>>(ab, an));
+ }
+ {
+ std::deque<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+ std::deque<int, min_allocator<int> > l2(l, min_allocator<int>());
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == min_allocator<int>());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp
new file mode 100644
index 00000000000..6468e4329bd
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/op_equal_initializer_list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque& operator=(initializer_list<value_type> il);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::deque<int> d;
+ d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::deque<int, min_allocator<int>> d;
+ d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/size.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/size.pass.cpp
new file mode 100644
index 00000000000..d2e324b0e3f
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/size.pass.cpp
@@ -0,0 +1,113 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// explicit deque(size_type n);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test2(unsigned n)
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::deque<T, Allocator> C;
+ typedef typename C::const_iterator const_iterator;
+ assert(DefaultOnly::count == 0);
+ {
+ C d(n, Allocator());
+ assert(DefaultOnly::count == n);
+ assert(d.size() == n);
+ assert(distance(d.begin(), d.end()) == d.size());
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
+ assert(*i == T());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ }
+ assert(DefaultOnly::count == 0);
+#endif
+}
+
+template <class T, class Allocator>
+void
+test1(unsigned n)
+{
+ typedef std::deque<T, Allocator> C;
+ typedef typename C::const_iterator const_iterator;
+ assert(DefaultOnly::count == 0);
+ {
+ C d(n);
+ assert(DefaultOnly::count == n);
+ assert(d.size() == n);
+ assert(distance(d.begin(), d.end()) == d.size());
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
+ assert(*i == T());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ }
+ assert(DefaultOnly::count == 0);
+}
+
+template <class T, class Allocator>
+void
+test3(unsigned n, Allocator const &alloc = Allocator())
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::deque<T, Allocator> C;
+ typedef typename C::const_iterator const_iterator;
+ {
+ C d(n, alloc);
+ assert(d.size() == n);
+ assert(d.get_allocator() == alloc);
+ }
+#endif
+}
+
+template <class T, class Allocator>
+void
+test(unsigned n)
+{
+ test1<T, Allocator> ( n );
+ test2<T, Allocator> ( n );
+}
+
+int main()
+{
+ test<DefaultOnly, std::allocator<DefaultOnly> >(0);
+ test<DefaultOnly, std::allocator<DefaultOnly> >(1);
+ test<DefaultOnly, std::allocator<DefaultOnly> >(10);
+ test<DefaultOnly, std::allocator<DefaultOnly> >(1023);
+ test<DefaultOnly, std::allocator<DefaultOnly> >(1024);
+ test<DefaultOnly, std::allocator<DefaultOnly> >(1025);
+ test<DefaultOnly, std::allocator<DefaultOnly> >(2047);
+ test<DefaultOnly, std::allocator<DefaultOnly> >(2048);
+ test<DefaultOnly, std::allocator<DefaultOnly> >(2049);
+ test<DefaultOnly, std::allocator<DefaultOnly> >(4095);
+ test<DefaultOnly, std::allocator<DefaultOnly> >(4096);
+ test<DefaultOnly, std::allocator<DefaultOnly> >(4097);
+
+ test1<DefaultOnly, stack_allocator<DefaultOnly, 4096> >(4095);
+
+#if __cplusplus >= 201103L
+ test<DefaultOnly, min_allocator<DefaultOnly> >(4095);
+#endif
+
+#if _LIBCPP_STD_VER > 11
+ test3<DefaultOnly, std::allocator<DefaultOnly>> (1023);
+ test3<int, std::allocator<int>>(1);
+ test3<int, min_allocator<int>> (3);
+#endif
+
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp
new file mode 100644
index 00000000000..859deba1e1a
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/size_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(size_type n, const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test(unsigned n, const T& x)
+{
+ typedef std::deque<T, Allocator> C;
+ typedef typename C::const_iterator const_iterator;
+ C d(n, x);
+ assert(d.size() == n);
+ assert(distance(d.begin(), d.end()) == d.size());
+ for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
+ assert(*i == x);
+}
+
+int main()
+{
+ test<int, std::allocator<int> >(0, 5);
+ test<int, std::allocator<int> >(1, 10);
+ test<int, std::allocator<int> >(10, 11);
+ test<int, std::allocator<int> >(1023, -11);
+ test<int, std::allocator<int> >(1024, 25);
+ test<int, std::allocator<int> >(1025, 0);
+ test<int, std::allocator<int> >(2047, 110);
+ test<int, std::allocator<int> >(2048, -500);
+ test<int, std::allocator<int> >(2049, 654);
+ test<int, std::allocator<int> >(4095, 78);
+ test<int, std::allocator<int> >(4096, 1165);
+ test<int, std::allocator<int> >(4097, 157);
+ test<int, stack_allocator<int, 4096> >(4095, 90);
+#if __cplusplus >= 201103L
+ test<int, min_allocator<int> >(4095, 90);
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp
new file mode 100644
index 00000000000..5693be702de
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.cons/size_value_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// deque(size_type n, const value_type& v, const allocator_type& a);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test(unsigned n, const T& x, const Allocator& a)
+{
+ typedef std::deque<T, Allocator> C;
+ typedef typename C::const_iterator const_iterator;
+ C d(n, x, a);
+ assert(d.get_allocator() == a);
+ assert(d.size() == n);
+ assert(distance(d.begin(), d.end()) == d.size());
+ for (const_iterator i = d.begin(), e = d.end(); i != e; ++i)
+ assert(*i == x);
+}
+
+int main()
+{
+ {
+ std::allocator<int> a;
+ test(0, 5, a);
+ test(1, 10, a);
+ test(10, 11, a);
+ test(1023, -11, a);
+ test(1024, 25, a);
+ test(1025, 0, a);
+ test(2047, 110, a);
+ test(2048, -500, a);
+ test(2049, 654, a);
+ test(4095, 78, a);
+ test(4096, 1165, a);
+ test(4097, 157, a);
+ }
+#if __cplusplus >= 201103L
+ {
+ min_allocator<int> a;
+ test(0, 5, a);
+ test(1, 10, a);
+ test(10, 11, a);
+ test(1023, -11, a);
+ test(1024, 25, a);
+ test(1025, 0, a);
+ test(2047, 110, a);
+ test(2048, -500, a);
+ test(2049, 654, a);
+ test(4095, 78, a);
+ test(4096, 1165, a);
+ test(4097, 157, a);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/emplace.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/emplace.pass.cpp
new file mode 100644
index 00000000000..806f7280332
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/emplace.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class... Args> iterator emplace(const_iterator p, Args&&... args);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(Emplaceable());
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void
+test(int P, C& c1)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ std::size_t c1_osize = c1.size();
+ CI i = c1.emplace(c1.begin() + P, Emplaceable(1, 2.5));
+ assert(i == c1.begin() + P);
+ assert(c1.size() == c1_osize + 1);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ assert(*i == Emplaceable(1, 2.5));
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ for (int i = 0; i <= 3; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1);
+ }
+ }
+ for (int i = N/2-1; i <= N/2+1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1);
+ }
+ }
+ for (int i = N - 3; i <= N; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1);
+ }
+ }
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<Emplaceable> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<Emplaceable, min_allocator<Emplaceable>> >(rng[i], rng[j]);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp
new file mode 100644
index 00000000000..aa977eb84bf
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/emplace_back.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class... Args> void emplace_back(Args&&... args);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(Emplaceable());
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void
+test(C& c1)
+{
+ typedef typename C::iterator I;
+ std::size_t c1_osize = c1.size();
+ c1.emplace_back(Emplaceable(1, 2.5));
+ assert(c1.size() == c1_osize + 1);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ I i = c1.end();
+ assert(*--i == Emplaceable(1, 2.5));
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ C c1 = make<C>(N, start);
+ test(c1);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<Emplaceable> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<Emplaceable, min_allocator<Emplaceable>> >(rng[i], rng[j]);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp
new file mode 100644
index 00000000000..cf09d6e19b6
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/emplace_front.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class... Args> void emplace_front(Args&&... args);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(Emplaceable());
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void
+test(C& c1)
+{
+ typedef typename C::iterator I;
+ std::size_t c1_osize = c1.size();
+ c1.emplace_front(Emplaceable(1, 2.5));
+ assert(c1.size() == c1_osize + 1);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ I i = c1.begin();
+ assert(*i == Emplaceable(1, 2.5));
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ C c1 = make<C>(N, start);
+ test(c1);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<Emplaceable> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<Emplaceable, min_allocator<Emplaceable>> >(rng[i], rng[j]);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp
new file mode 100644
index 00000000000..bfab2a3a4fc
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/erase_iter.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// iterator erase(const_iterator p)
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void
+test(int P, C& c1)
+{
+ typedef typename C::iterator I;
+ assert(P < c1.size());
+ std::size_t c1_osize = c1.size();
+ I i = c1.erase(c1.cbegin() + P);
+ assert(i == c1.begin() + P);
+ assert(c1.size() == c1_osize - 1);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ i = c1.begin();
+ int j = 0;
+ for (; j < P; ++j, ++i)
+ assert(*i == j);
+ for (++j; j < c1_osize; ++j, ++i)
+ assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ int pstep = std::max(N / std::max(std::min(N, 10), 1), 1);
+ for (int p = 0; p < N; p += pstep)
+ {
+ C c1 = make<C>(N, start);
+ test(p, c1);
+ }
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp
new file mode 100644
index 00000000000..6e937ac0c4e
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp
@@ -0,0 +1,96 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <deque>
+
+// iterator erase(const_iterator f, const_iterator l)
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void
+test(int P, C& c1, int size)
+{
+ typedef typename C::iterator I;
+ assert(P + size <= c1.size());
+ std::size_t c1_osize = c1.size();
+ I i = c1.erase(c1.cbegin() + P, c1.cbegin() + (P + size));
+ assert(i == c1.begin() + P);
+ assert(c1.size() == c1_osize - size);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ i = c1.begin();
+ int j = 0;
+ for (; j < P; ++j, ++i)
+ assert(*i == j);
+ for (j += size; j < c1_osize; ++j, ++i)
+ assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ int pstep = std::max(N / std::max(std::min(N, 10), 1), 1);
+ for (int p = 0; p <= N; p += pstep)
+ {
+ int sstep = std::max((N - p) / std::max(std::min(N - p, 10), 1), 1);
+ for (int s = 0; s <= N - p; s += sstep)
+ {
+ C c1 = make<C>(N, start);
+ test(p, c1, s);
+ }
+ }
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.pass.cpp
new file mode 100644
index 00000000000..5f7804023c7
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_iter_initializer_list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// iterator insert(const_iterator p, initializer_list<value_type> il);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::deque<int> d(10, 1);
+ std::deque<int>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
+ assert(d.size() == 14);
+ assert(i == d.begin() + 2);
+ assert(d[0] == 1);
+ assert(d[1] == 1);
+ assert(d[2] == 3);
+ assert(d[3] == 4);
+ assert(d[4] == 5);
+ assert(d[5] == 6);
+ assert(d[6] == 1);
+ assert(d[7] == 1);
+ assert(d[8] == 1);
+ assert(d[9] == 1);
+ assert(d[10] == 1);
+ assert(d[11] == 1);
+ assert(d[12] == 1);
+ assert(d[13] == 1);
+ }
+ {
+ std::deque<int, min_allocator<int>> d(10, 1);
+ std::deque<int, min_allocator<int>>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
+ assert(d.size() == 14);
+ assert(i == d.begin() + 2);
+ assert(d[0] == 1);
+ assert(d[1] == 1);
+ assert(d[2] == 3);
+ assert(d[3] == 4);
+ assert(d[4] == 5);
+ assert(d[5] == 6);
+ assert(d[6] == 1);
+ assert(d[7] == 1);
+ assert(d[8] == 1);
+ assert(d[9] == 1);
+ assert(d[10] == 1);
+ assert(d[11] == 1);
+ assert(d[12] == 1);
+ assert(d[13] == 1);
+ }
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp
new file mode 100644
index 00000000000..2bc37c34ce4
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_iter_iter.pass.cpp
@@ -0,0 +1,256 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <deque>
+
+// template <class InputIterator>
+// iterator insert (const_iterator p, InputIterator f, InputIterator l);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "../../../MoveOnly.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void
+test(int P, C& c1, const C& c2)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ typedef bidirectional_iterator<CI> BCI;
+ std::size_t c1_osize = c1.size();
+ CI i = c1.insert(c1.begin() + P, BCI(c2.begin()), BCI(c2.end()));
+ assert(i == c1.begin() + P);
+ assert(c1.size() == c1_osize + c2.size());
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ i = c1.begin();
+ for (int j = 0; j < P; ++j, ++i)
+ assert(*i == j);
+ for (int j = 0; j < c2.size(); ++j, ++i)
+ assert(*i == j);
+ for (int j = P; j < c1_osize; ++j, ++i)
+ assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N, int M)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ for (int i = 0; i <= 3; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ test(i, c1, c2);
+ }
+ }
+ for (int i = M-1; i <= M+1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ test(i, c1, c2);
+ }
+ }
+ for (int i = N/2-1; i <= N/2+1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ test(i, c1, c2);
+ }
+ }
+ for (int i = N - M - 1; i <= N - M + 1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ test(i, c1, c2);
+ }
+ }
+ for (int i = N - M - 1; i <= N - M + 1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ test(i, c1, c2);
+ }
+ }
+ for (int i = N - 3; i <= N; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ test(i, c1, c2);
+ }
+ }
+}
+
+template <class C>
+void
+testI(int P, C& c1, const C& c2)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ typedef input_iterator<CI> ICI;
+ std::size_t c1_osize = c1.size();
+ CI i = c1.insert(c1.begin() + P, ICI(c2.begin()), ICI(c2.end()));
+ assert(i == c1.begin() + P);
+ assert(c1.size() == c1_osize + c2.size());
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ i = c1.begin();
+ for (int j = 0; j < P; ++j, ++i)
+ assert(*i == j);
+ for (int j = 0; j < c2.size(); ++j, ++i)
+ assert(*i == j);
+ for (int j = P; j < c1_osize; ++j, ++i)
+ assert(*i == j);
+}
+
+template <class C>
+void
+testNI(int start, int N, int M)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ for (int i = 0; i <= 3; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ testI(i, c1, c2);
+ }
+ }
+ for (int i = M-1; i <= M+1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ testI(i, c1, c2);
+ }
+ }
+ for (int i = N/2-1; i <= N/2+1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ testI(i, c1, c2);
+ }
+ }
+ for (int i = N - M - 1; i <= N - M + 1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ testI(i, c1, c2);
+ }
+ }
+ for (int i = N - 3; i <= N; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ testI(i, c1, c2);
+ }
+ }
+}
+
+template <class C>
+void
+test_move()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ C c;
+ typedef typename C::const_iterator CI;
+ {
+ MoveOnly mo(0);
+ typedef MoveOnly* I;
+ c.insert(c.end(), std::move_iterator<I>(&mo), std::move_iterator<I>(&mo+1));
+ }
+ int j = 0;
+ for (CI i = c.begin(); i != c.end(); ++i, ++j)
+ assert(*i == MoveOnly(j));
+ {
+ MoveOnly mo(1);
+ typedef input_iterator<MoveOnly*> I;
+ c.insert(c.end(), std::move_iterator<I>(I(&mo)), std::move_iterator<I>(I(&mo+1)));
+ }
+ j = 0;
+ for (CI i = c.begin(); i != c.end(); ++i, ++j)
+ assert(*i == MoveOnly(j));
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+ testNI<std::deque<int> >(1500, 2000, 1000);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ test_move<std::deque<MoveOnly, stack_allocator<MoveOnly, 2000> > >();
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
+ testNI<std::deque<int> >(1500, 2000, 1000);
+ test_move<std::deque<MoveOnly, min_allocator<MoveOnly> > >();
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_rvalue.pass.cpp
new file mode 100644
index 00000000000..0bde7d9b7e3
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_rvalue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// iterator insert (const_iterator p, value_type&& v);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(MoveOnly(i));
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void
+test(int P, C& c1, int x)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ std::size_t c1_osize = c1.size();
+ CI i = c1.insert(c1.begin() + P, MoveOnly(x));
+ assert(i == c1.begin() + P);
+ assert(c1.size() == c1_osize + 1);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ i = c1.begin();
+ for (int j = 0; j < P; ++j, ++i)
+ assert(*i == MoveOnly(j));
+ assert(*i == MoveOnly(x));
+ ++i;
+ for (int j = P; j < c1_osize; ++j, ++i)
+ assert(*i == MoveOnly(j));
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ for (int i = 0; i <= 3; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1, -10);
+ }
+ }
+ for (int i = N/2-1; i <= N/2+1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1, -10);
+ }
+ }
+ for (int i = N - 3; i <= N; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1, -10);
+ }
+ }
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<MoveOnly> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[i], rng[j]);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_size_value.pass.cpp
new file mode 100644
index 00000000000..3e7767209e5
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_size_value.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.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// <deque>
+
+// iterator insert (const_iterator p, size_type n, const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void
+test(int P, C& c1, int size, int x)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ std::size_t c1_osize = c1.size();
+ CI i = c1.insert(c1.begin() + P, size, x);
+ assert(i == c1.begin() + P);
+ assert(c1.size() == c1_osize + size);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ i = c1.begin();
+ for (int j = 0; j < P; ++j, ++i)
+ assert(*i == j);
+ for (int j = 0; j < size; ++j, ++i)
+ assert(*i == x);
+ for (int j = P; j < c1_osize; ++j, ++i)
+ assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N, int M)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ for (int i = 0; i <= 3; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1, M, -10);
+ }
+ }
+ for (int i = M-1; i <= M+1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1, M, -10);
+ }
+ }
+ for (int i = N/2-1; i <= N/2+1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1, M, -10);
+ }
+ }
+ for (int i = N - M - 1; i <= N - M + 1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1, M, -10);
+ }
+ }
+ for (int i = N - 3; i <= N; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1, M, -10);
+ }
+ }
+}
+
+template <class C>
+void
+self_reference_test()
+{
+ typedef typename C::const_iterator CI;
+ for (int i = 0; i < 20; ++i)
+ {
+ for (int j = 0; j < 20; ++j)
+ {
+ C c = make<C>(20);
+ CI it = c.cbegin() + i;
+ CI jt = c.cbegin() + j;
+ c.insert(it, 5, *jt);
+ assert(c.size() == 25);
+ assert(distance(c.begin(), c.end()) == c.size());
+ it = c.cbegin();
+ for (int k = 0; k < i; ++k, ++it)
+ assert(*it == k);
+ for (int k = 0; k < 5; ++k, ++it)
+ assert(*it == j);
+ for (int k = i; k < 20; ++k, ++it)
+ assert(*it == k);
+ }
+ }
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+ self_reference_test<std::deque<int> >();
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
+ self_reference_test<std::deque<int, min_allocator<int>> >();
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp
new file mode 100644
index 00000000000..97827c1183a
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/insert_value.pass.cpp
@@ -0,0 +1,139 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// iterator insert (const_iterator p, const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void
+test(int P, C& c1, int x)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ std::size_t c1_osize = c1.size();
+ CI i = c1.insert(c1.begin() + P, x);
+ assert(i == c1.begin() + P);
+ assert(c1.size() == c1_osize + 1);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ i = c1.begin();
+ for (int j = 0; j < P; ++j, ++i)
+ assert(*i == j);
+ assert(*i == x);
+ ++i;
+ for (int j = P; j < c1_osize; ++j, ++i)
+ assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ for (int i = 0; i <= 3; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1, -10);
+ }
+ }
+ for (int i = N/2-1; i <= N/2+1; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1, -10);
+ }
+ }
+ for (int i = N - 3; i <= N; ++i)
+ {
+ if (0 <= i && i <= N)
+ {
+ C c1 = make<C>(N, start);
+ test(i, c1, -10);
+ }
+ }
+}
+
+template <class C>
+void
+self_reference_test()
+{
+ typedef typename C::const_iterator CI;
+ for (int i = 0; i < 20; ++i)
+ {
+ for (int j = 0; j < 20; ++j)
+ {
+ C c = make<C>(20);
+ CI it = c.cbegin() + i;
+ CI jt = c.cbegin() + j;
+ c.insert(it, *jt);
+ assert(c.size() == 21);
+ assert(distance(c.begin(), c.end()) == c.size());
+ it = c.cbegin();
+ for (int k = 0; k < i; ++k, ++it)
+ assert(*it == k);
+ assert(*it == j);
+ ++it;
+ for (int k = i; k < 20; ++k, ++it)
+ assert(*it == k);
+ }
+ }
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ self_reference_test<std::deque<int> >();
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ self_reference_test<std::deque<int, min_allocator<int>> >();
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp
new file mode 100644
index 00000000000..e642f7132f5
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/pop_back.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void pop_back()
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void
+test(C& c1)
+{
+ typedef typename C::iterator I;
+ std::size_t c1_osize = c1.size();
+ c1.pop_back();
+ assert(c1.size() == c1_osize - 1);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ I i = c1.begin();
+ for (int j = 0; j < c1.size(); ++j, ++i)
+ assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ if (N != 0)
+ {
+ C c1 = make<C>(N, start);
+ test(c1);
+ }
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp
new file mode 100644
index 00000000000..e27edf51f79
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/pop_front.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void pop_front()
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void
+test(C& c1)
+{
+ typedef typename C::iterator I;
+ std::size_t c1_osize = c1.size();
+ c1.pop_front();
+ assert(c1.size() == c1_osize - 1);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ I i = c1.begin();
+ for (int j = 1; j < c1.size(); ++j, ++i)
+ assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ if (N != 0)
+ {
+ C c1 = make<C>(N, start);
+ test(c1);
+ }
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_back.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_back.pass.cpp
new file mode 100644
index 00000000000..444ab9ba955
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_back.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void push_back(const value_type& v);
+// void pop_back();
+// void pop_front();
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void test(int size)
+{
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int j = 0; j < N; ++j)
+ {
+ C c = make<C>(size, rng[j]);
+ typename C::const_iterator it = c.begin();
+ for (int i = 0; i < size; ++i, ++it)
+ assert(*it == i);
+ }
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int j = 0; j < N; ++j)
+ test<std::deque<int> >(rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int j = 0; j < N; ++j)
+ test<std::deque<int, min_allocator<int>> >(rng[j]);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp
new file mode 100644
index 00000000000..3e628791a9f
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void push_back(const value_type& x);
+
+#include <deque>
+#include <cassert>
+
+// Flag that makes the copy constructor for CMyClass throw an exception
+static bool gCopyConstructorShouldThow = false;
+
+
+class CMyClass {
+ public: CMyClass(int tag);
+ public: CMyClass(const CMyClass& iOther);
+ public: ~CMyClass();
+
+ bool equal(const CMyClass &rhs) const
+ { return fTag == rhs.fTag && fMagicValue == rhs.fMagicValue; }
+ private:
+ int fMagicValue;
+ int fTag;
+
+ private: static int kStartedConstructionMagicValue;
+ private: static int kFinishedConstructionMagicValue;
+};
+
+// Value for fMagicValue when the constructor has started running, but not yet finished
+int CMyClass::kStartedConstructionMagicValue = 0;
+// Value for fMagicValue when the constructor has finished running
+int CMyClass::kFinishedConstructionMagicValue = 12345;
+
+CMyClass::CMyClass(int tag) :
+ fMagicValue(kStartedConstructionMagicValue), fTag(tag)
+{
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::CMyClass(const CMyClass& iOther) :
+ fMagicValue(kStartedConstructionMagicValue), fTag(iOther.fTag)
+{
+ // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
+ if (gCopyConstructorShouldThow) {
+ throw std::exception();
+ }
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::~CMyClass() {
+ // Only instances for which the constructor has finished running should be destructed
+ assert(fMagicValue == kFinishedConstructionMagicValue);
+}
+
+bool operator==(const CMyClass &lhs, const CMyClass &rhs) { return lhs.equal(rhs); }
+
+int main()
+{
+ CMyClass instance(42);
+ std::deque<CMyClass> vec;
+
+ vec.push_back(instance);
+ std::deque<CMyClass> vec2(vec);
+
+ gCopyConstructorShouldThow = true;
+ try {
+ vec.push_back(instance);
+ }
+ catch (...) {
+ assert(vec==vec2);
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp
new file mode 100644
index 00000000000..d6c44391477
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void push_back(value_type&& v);
+// void pop_back();
+// void pop_front();
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(MoveOnly(i));
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void test(int size)
+{
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int j = 0; j < N; ++j)
+ {
+ C c = make<C>(size, rng[j]);
+ typename C::const_iterator it = c.begin();
+ for (int i = 0; i < size; ++i, ++it)
+ assert(*it == MoveOnly(i));
+ }
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int j = 0; j < N; ++j)
+ test<std::deque<MoveOnly> >(rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int j = 0; j < N; ++j)
+ test<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[j]);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_front.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_front.pass.cpp
new file mode 100644
index 00000000000..700edd3abdb
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_front.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void push_front(const value_type& v);
+
+#include <deque>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void
+test(C& c1, int x)
+{
+ typedef typename C::iterator I;
+ std::size_t c1_osize = c1.size();
+ c1.push_front(x);
+ assert(c1.size() == c1_osize + 1);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ I i = c1.begin();
+ assert(*i == x);
+ ++i;
+ for (int j = 0; j < c1_osize; ++j, ++i)
+ assert(*i == j);
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ C c1 = make<C>(N, start);
+ test(c1, -10);
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp
new file mode 100644
index 00000000000..6ae06db0bca
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void push_front(const value_type& x);
+
+#include <deque>
+#include <cassert>
+
+// Flag that makes the copy constructor for CMyClass throw an exception
+static bool gCopyConstructorShouldThow = false;
+
+
+class CMyClass {
+ public: CMyClass(int tag);
+ public: CMyClass(const CMyClass& iOther);
+ public: ~CMyClass();
+
+ bool equal(const CMyClass &rhs) const
+ { return fTag == rhs.fTag && fMagicValue == rhs.fMagicValue; }
+ private:
+ int fMagicValue;
+ int fTag;
+
+ private: static int kStartedConstructionMagicValue;
+ private: static int kFinishedConstructionMagicValue;
+};
+
+// Value for fMagicValue when the constructor has started running, but not yet finished
+int CMyClass::kStartedConstructionMagicValue = 0;
+// Value for fMagicValue when the constructor has finished running
+int CMyClass::kFinishedConstructionMagicValue = 12345;
+
+CMyClass::CMyClass(int tag) :
+ fMagicValue(kStartedConstructionMagicValue), fTag(tag)
+{
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::CMyClass(const CMyClass& iOther) :
+ fMagicValue(kStartedConstructionMagicValue), fTag(iOther.fTag)
+{
+ // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
+ if (gCopyConstructorShouldThow) {
+ throw std::exception();
+ }
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::~CMyClass() {
+ // Only instances for which the constructor has finished running should be destructed
+ assert(fMagicValue == kFinishedConstructionMagicValue);
+}
+
+bool operator==(const CMyClass &lhs, const CMyClass &rhs) { return lhs.equal(rhs); }
+
+int main()
+{
+ CMyClass instance(42);
+ std::deque<CMyClass> vec;
+
+ vec.push_front(instance);
+ std::deque<CMyClass> vec2(vec);
+
+ gCopyConstructorShouldThow = true;
+ try {
+ vec.push_front(instance);
+ }
+ catch (...) {
+ assert(vec==vec2);
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp
new file mode 100644
index 00000000000..1670a44aa07
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void push_front(value_type&& v);
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(MoveOnly(i));
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void
+test(C& c1, int x)
+{
+ typedef typename C::iterator I;
+ std::size_t c1_osize = c1.size();
+ c1.push_front(MoveOnly(x));
+ assert(c1.size() == c1_osize + 1);
+ assert(distance(c1.begin(), c1.end()) == c1.size());
+ I i = c1.begin();
+ assert(*i == MoveOnly(x));
+ ++i;
+ for (int j = 0; j < c1_osize; ++j, ++i)
+ assert(*i == MoveOnly(j));
+}
+
+template <class C>
+void
+testN(int start, int N)
+{
+ C c1 = make<C>(N, start);
+ test(c1, -10);
+}
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<MoveOnly> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<MoveOnly, min_allocator<MoveOnly>> >(rng[i], rng[j]);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.special/copy.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.special/copy.pass.cpp
new file mode 100644
index 00000000000..7dfb4bc5c2d
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.special/copy.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Optimization for deque::iterators
+
+// template <class InputIterator, class OutputIterator>
+// OutputIterator
+// copy(InputIterator first, InputIterator last, OutputIterator result);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void testN(int start, int N)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ typedef random_access_iterator<I> RAI;
+ typedef random_access_iterator<CI> RACI;
+ typedef input_iterator<CI> ICI;
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(N);
+ assert(std::copy(c1.cbegin(), c1.cend(), c2.begin()) == c2.end());
+ assert(c1 == c2);
+ assert(std::copy(c2.cbegin(), c2.cend(), c1.begin()) == c1.end());
+ assert(c1 == c2);
+ assert(std::copy(c1.cbegin(), c1.cend(), RAI(c2.begin())) == RAI(c2.end()));
+ assert(c1 == c2);
+ assert(std::copy(c2.cbegin(), c2.cend(), RAI(c1.begin())) == RAI(c1.end()));
+ assert(c1 == c2);
+ assert(std::copy(RACI(c1.cbegin()), RACI(c1.cend()), c2.begin()) == c2.end());
+ assert(c1 == c2);
+ assert(std::copy(ICI(c2.cbegin()), ICI(c2.cend()), c1.begin()) == c1.end());
+ assert(c1 == c2);
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.special/copy_backward.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.special/copy_backward.pass.cpp
new file mode 100644
index 00000000000..b484a865c57
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.special/copy_backward.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Optimization for deque::iterators
+
+// template <class InputIterator, class OutputIterator>
+// OutputIterator
+// copy_backward(InputIterator first, InputIterator last, OutputIterator result);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void testN(int start, int N)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ typedef random_access_iterator<I> RAI;
+ typedef random_access_iterator<CI> RACI;
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(N);
+ assert(std::copy_backward(c1.cbegin(), c1.cend(), c2.end()) == c2.begin());
+ assert(c1 == c2);
+ assert(std::copy_backward(c2.cbegin(), c2.cend(), c1.end()) == c1.begin());
+ assert(c1 == c2);
+ assert(std::copy_backward(c1.cbegin(), c1.cend(), RAI(c2.end())) == RAI(c2.begin()));
+ assert(c1 == c2);
+ assert(std::copy_backward(c2.cbegin(), c2.cend(), RAI(c1.end())) == RAI(c1.begin()));
+ assert(c1 == c2);
+ assert(std::copy_backward(RACI(c1.cbegin()), RACI(c1.cend()), c2.end()) == c2.begin());
+ assert(c1 == c2);
+ assert(std::copy_backward(RACI(c2.cbegin()), RACI(c2.cend()), c1.end()) == c1.begin());
+ assert(c1 == c2);
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.special/move.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.special/move.pass.cpp
new file mode 100644
index 00000000000..b100ba487ea
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.special/move.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Optimization for deque::iterators
+
+// template <class InputIterator, class OutputIterator>
+// OutputIterator
+// move(InputIterator first, InputIterator last, OutputIterator result);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void testN(int start, int N)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ typedef random_access_iterator<I> RAI;
+ typedef random_access_iterator<CI> RACI;
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(N);
+ assert(std::move(c1.cbegin(), c1.cend(), c2.begin()) == c2.end());
+ assert(c1 == c2);
+ assert(std::move(c2.cbegin(), c2.cend(), c1.begin()) == c1.end());
+ assert(c1 == c2);
+ assert(std::move(c1.cbegin(), c1.cend(), RAI(c2.begin())) == RAI(c2.end()));
+ assert(c1 == c2);
+ assert(std::move(c2.cbegin(), c2.cend(), RAI(c1.begin())) == RAI(c1.end()));
+ assert(c1 == c2);
+ assert(std::move(RACI(c1.cbegin()), RACI(c1.cend()), c2.begin()) == c2.end());
+ assert(c1 == c2);
+ assert(std::move(RACI(c2.cbegin()), RACI(c2.cend()), c1.begin()) == c1.end());
+ assert(c1 == c2);
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j]);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.special/move_backward.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.special/move_backward.pass.cpp
new file mode 100644
index 00000000000..072d7a78a30
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.special/move_backward.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Optimization for deque::iterators
+
+// template <class InputIterator, class OutputIterator>
+// OutputIterator
+// move_backward(InputIterator first, InputIterator last, OutputIterator result);
+
+#include <deque>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void testN(int start, int N)
+{
+ typedef typename C::iterator I;
+ typedef typename C::const_iterator CI;
+ typedef random_access_iterator<I> RAI;
+ typedef random_access_iterator<CI> RACI;
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(N);
+ assert(std::move_backward(c1.cbegin(), c1.cend(), c2.end()) == c2.begin());
+ assert(c1 == c2);
+ assert(std::move_backward(c2.cbegin(), c2.cend(), c1.end()) == c1.begin());
+ assert(c1 == c2);
+ assert(std::move_backward(c1.cbegin(), c1.cend(), RAI(c2.end())) == RAI(c2.begin()));
+ assert(c1 == c2);
+ assert(std::move_backward(c2.cbegin(), c2.cend(), RAI(c1.end())) == RAI(c1.begin()));
+ assert(c1 == c2);
+ assert(std::move_backward(RACI(c1.cbegin()), RACI(c1.cend()), c2.end()) == c2.begin());
+ assert(c1 == c2);
+ assert(std::move_backward(RACI(c2.cbegin()), RACI(c2.cend()), c1.end()) == c1.begin());
+ assert(c1 == c2);
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int> >(rng[i], rng[j]);
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ testN<std::deque<int, min_allocator<int> > >(rng[i], rng[j]);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.special/swap.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.special/swap.pass.cpp
new file mode 100644
index 00000000000..808144c9ebe
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.special/swap.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// template <class T, class A>
+// void swap(deque<T, A>& x, deque<T, A>& y);
+
+#include <deque>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+C
+make(int size, int start = 0 )
+{
+ const int b = 4096 / sizeof(int);
+ int init = 0;
+ if (start > 0)
+ {
+ init = (start+1) / b + ((start+1) % b != 0);
+ init *= b;
+ --init;
+ }
+ C c(init, 0);
+ for (int i = 0; i < init-start; ++i)
+ c.pop_back();
+ for (int i = 0; i < size; ++i)
+ c.push_back(i);
+ for (int i = 0; i < start; ++i)
+ c.pop_front();
+ return c;
+};
+
+template <class C>
+void testN(int start, int N, int M)
+{
+ C c1 = make<C>(N, start);
+ C c2 = make<C>(M);
+ C c1_save = c1;
+ C c2_save = c2;
+ swap(c1, c2);
+ assert(c1 == c2_save);
+ assert(c2 == c1_save);
+}
+
+int main()
+{
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int> >(rng[i], rng[j], rng[k]);
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef test_allocator<int> A;
+ std::deque<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+ std::deque<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+ swap(c1, c2);
+ assert((c1 == std::deque<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A(1));
+ assert((c2 == std::deque<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A(2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef other_allocator<int> A;
+ std::deque<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+ std::deque<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+ swap(c1, c2);
+ assert((c1 == std::deque<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A(2));
+ assert((c2 == std::deque<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A(1));
+ }
+#if __cplusplus >= 201103L
+ {
+ int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049};
+ const int N = sizeof(rng)/sizeof(rng[0]);
+ for (int i = 0; i < N; ++i)
+ for (int j = 0; j < N; ++j)
+ for (int k = 0; k < N; ++k)
+ testN<std::deque<int, min_allocator<int>> >(rng[i], rng[j], rng[k]);
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef min_allocator<int> A;
+ std::deque<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A());
+ std::deque<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A());
+ swap(c1, c2);
+ assert((c1 == std::deque<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A());
+ assert((c2 == std::deque<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp
new file mode 100644
index 00000000000..d55d719c762
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/deque.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// void swap(deque& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <deque>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+
+ some_alloc() {}
+ some_alloc(const some_alloc&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::deque<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::deque<MoveOnly, test_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::deque<MoveOnly, other_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/iterators.pass.cpp b/libcxx/test/std/containers/sequences/deque/iterators.pass.cpp
new file mode 100644
index 00000000000..8ec491fae4d
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/iterators.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Test nested types and default template args:
+
+// template <class T, class Allocator = allocator<T> >
+// class deque;
+
+// iterator, const_iterator
+
+#include <deque>
+#include <iterator>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::deque<int> C;
+ C c;
+ C::iterator i;
+ i = c.begin();
+ C::const_iterator j;
+ j = c.cbegin();
+ assert(i == j);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::deque<int, min_allocator<int>> C;
+ C c;
+ C::iterator i;
+ i = c.begin();
+ C::const_iterator j;
+ j = c.cbegin();
+ assert(i == j);
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ std::deque<int>::iterator ii1{}, ii2{};
+ std::deque<int>::iterator ii4 = ii1;
+ std::deque<int>::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ assert (!(ii1 < cii ));
+ assert (!(cii < ii1 ));
+ assert ( (ii1 <= cii ));
+ assert ( (cii <= ii1 ));
+ assert (!(ii1 > cii ));
+ assert (!(cii > ii1 ));
+ assert ( (ii1 >= cii ));
+ assert ( (cii >= ii1 ));
+ assert (cii - ii1 == 0);
+ assert (ii1 - cii == 0);
+
+// std::deque<int> c;
+// assert ( ii1 != c.cbegin());
+// assert ( cii != c.begin());
+// assert ( cii != c.cend());
+// assert ( ii1 != c.end());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/deque/types.pass.cpp b/libcxx/test/std/containers/sequences/deque/types.pass.cpp
new file mode 100644
index 00000000000..da9470d8a6c
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+// Test nested types and default template args:
+
+// template <class T, class Allocator = allocator<T> >
+// class deque
+// {
+// public:
+// typedef T value_type;
+// typedef Allocator allocator_type;
+// typedef typename allocator_type::reference reference;
+// typedef typename allocator_type::const_reference const_reference;
+// typedef implementation-defined iterator;
+// typedef implementation-defined const_iterator;
+// typedef typename allocator_type::size_type size_type;
+// typedef typename allocator_type::difference_type difference_type;
+// typedef typename allocator_type::pointer pointer;
+// typedef typename allocator_type::const_pointer const_pointer;
+// typedef std::reverse_iterator<iterator> reverse_iterator;
+// typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+// };
+
+#include <deque>
+#include <iterator>
+#include <type_traits>
+
+#include "test_allocator.h"
+#include "../../Copyable.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test()
+{
+ typedef std::deque<T, Allocator> C;
+
+ static_assert((std::is_same<typename C::value_type, T>::value), "");
+ static_assert((std::is_same<typename C::value_type, typename Allocator::value_type>::value), "");
+ static_assert((std::is_same<typename C::allocator_type, Allocator>::value), "");
+ static_assert((std::is_same<typename C::size_type, typename Allocator::size_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type, typename Allocator::difference_type>::value), "");
+ static_assert((std::is_same<typename C::reference, typename Allocator::reference>::value), "");
+ static_assert((std::is_same<typename C::const_reference, typename Allocator::const_reference>::value), "");
+ static_assert((std::is_same<typename C::pointer, typename Allocator::pointer>::value), "");
+ static_assert((std::is_same<typename C::const_pointer, typename Allocator::const_pointer>::value), "");
+ static_assert((std::is_same<
+ typename std::iterator_traits<typename C::iterator>::iterator_category,
+ std::random_access_iterator_tag>::value), "");
+ static_assert((std::is_same<
+ typename std::iterator_traits<typename C::const_iterator>::iterator_category,
+ std::random_access_iterator_tag>::value), "");
+ static_assert((std::is_same<
+ typename C::reverse_iterator,
+ std::reverse_iterator<typename C::iterator> >::value), "");
+ static_assert((std::is_same<
+ typename C::const_reverse_iterator,
+ std::reverse_iterator<typename C::const_iterator> >::value), "");
+}
+
+int main()
+{
+ test<int, test_allocator<int> >();
+ test<int*, std::allocator<int*> >();
+ test<Copyable, test_allocator<Copyable> >();
+ static_assert((std::is_same<std::deque<char>::allocator_type,
+ std::allocator<char> >::value), "");
+#if __cplusplus >= 201103L
+ {
+ typedef std::deque<short, min_allocator<short>> C;
+ static_assert((std::is_same<C::value_type, short>::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<C::value_type>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const C::value_type>>::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/sequences/deque/version.pass.cpp b/libcxx/test/std/containers/sequences/deque/version.pass.cpp
new file mode 100644
index 00000000000..22e663d9bc2
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/deque/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <deque>
+
+#include <deque>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/sequences/dynarray/dynarray.cons/alloc.pass.cpp b/libcxx/test/std/containers/sequences/dynarray/dynarray.cons/alloc.pass.cpp
new file mode 100644
index 00000000000..d274bc03088
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/dynarray/dynarray.cons/alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.cons
+
+// template <class Alloc>
+// dynarray(size_type c, const Alloc& alloc);
+// template <class Alloc>
+// dynarray(size_type c, const T& v, const Alloc& alloc);
+// template <class Alloc>
+// dynarray(const dynarray& d, const Alloc& alloc);
+// template <class Alloc>
+// dynarray(initializer_list<T>, const Alloc& alloc);
+
+// ~dynarray();
+
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+#include "test_allocator.h"
+
+using std::experimental::dynarray;
+
+template <class T, class Allocator>
+void check_allocator ( const dynarray<T> &dyn, const Allocator &alloc ) {
+ for ( int i = 0; i < dyn.size (); ++i )
+ assert ( dyn[i].get_allocator() == alloc );
+}
+
+template <class T, class Allocator>
+void test ( const std::initializer_list<T> &vals, const Allocator &alloc ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( vals, alloc );
+ assert ( d1.size () == vals.size() );
+ assert ( std::equal ( vals.begin (), vals.end (), d1.begin (), d1.end ()));
+ check_allocator ( d1, alloc );
+ }
+
+
+template <class T, class Allocator>
+void test ( const T &val, const Allocator &alloc1, const Allocator &alloc2 ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( 4, alloc1 );
+ assert ( d1.size () == 4 );
+ assert ( std::all_of ( d1.begin (), d1.end (), []( const T &item ){ return item == T(); } ));
+ check_allocator ( d1, alloc1 );
+
+ dynA d2 ( 7, val, alloc1 );
+ assert ( d2.size () == 7 );
+ assert ( std::all_of ( d2.begin (), d2.end (), [&val]( const T &item ){ return item == val; } ));
+ check_allocator ( d2, alloc1 );
+
+ dynA d3 ( d2, alloc2 );
+ assert ( d3.size () == 7 );
+ assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ return item == val; } ));
+ check_allocator ( d3, alloc2 );
+ }
+
+int main()
+{
+// This test is waiting on the resolution of LWG issue #2235
+// typedef test_allocator<char> Alloc;
+// typedef std::basic_string<char, std::char_traits<char>, Alloc> nstr;
+//
+// test ( nstr("fourteen"), Alloc(3), Alloc(4) );
+// test ( { nstr("1"), nstr("1"), nstr("2"), nstr("3"), nstr("5"), nstr("8")}, Alloc(6));
+}
+#else
+int main() {}
+#endif
diff --git a/libcxx/test/std/containers/sequences/dynarray/dynarray.cons/default.pass.cpp b/libcxx/test/std/containers/sequences/dynarray/dynarray.cons/default.pass.cpp
new file mode 100644
index 00000000000..0effac2fc14
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/dynarray/dynarray.cons/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.cons
+
+// explicit dynarray(size_type c);
+// dynarray(size_type c, const T& v);
+// dynarray(initializer_list<T>);
+// dynarray(const dynarray& d);
+
+// ~dynarray();
+
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void test ( const std::initializer_list<T> &vals ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( vals );
+ assert ( d1.size () == vals.size() );
+ assert ( std::equal ( vals.begin (), vals.end (), d1.begin (), d1.end ()));
+ }
+
+
+template <class T>
+void test ( const T &val ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( 4 );
+ assert ( d1.size () == 4 );
+ assert ( std::all_of ( d1.begin (), d1.end (), []( const T &item ){ return item == T(); } ));
+
+ dynA d2 ( 7, val );
+ assert ( d2.size () == 7 );
+ assert ( std::all_of ( d2.begin (), d2.end (), [&val]( const T &item ){ return item == val; } ));
+
+ dynA d3 ( d2 );
+ assert ( d3.size () == 7 );
+ assert ( std::all_of ( d3.begin (), d3.end (), [&val]( const T &item ){ return item == val; } ));
+ }
+
+void test_bad_length () {
+ try { dynarray<int> ( std::numeric_limits<size_t>::max() / sizeof ( int ) + 1 ); }
+ catch ( std::bad_array_length & ) { return ; }
+ assert ( false );
+ }
+
+void test_bad_alloc () {
+ try { dynarray<int> ( std::numeric_limits<size_t>::max() / sizeof ( int ) - 1 ); }
+ catch ( std::bad_alloc & ) { return ; }
+ assert ( false );
+ }
+
+int main()
+{
+// test<int> ( 14 ); // ints don't get default initialized
+ test<long> ( 0 );
+ test<double> ( 14.0 );
+ test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
+ test<std::string> ( "fourteen" );
+
+ test ( { 1, 1, 2, 3, 5, 8 } );
+ test ( { 1., 1., 2., 3., 5., 8. } );
+ test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
+ std::string("5"), std::string("8")} );
+
+// Make sure we don't pick up the Allocator version here
+ dynarray<long> d1 ( 20, 3 );
+ assert ( d1.size() == 20 );
+ assert ( std::all_of ( d1.begin (), d1.end (), []( long item ){ return item == 3L; } ));
+
+ test_bad_length ();
+ test_bad_alloc ();
+}
+#else
+int main() {}
+#endif
diff --git a/libcxx/test/std/containers/sequences/dynarray/dynarray.data/default.pass.cpp b/libcxx/test/std/containers/sequences/dynarray/dynarray.data/default.pass.cpp
new file mode 100644
index 00000000000..b669f25948e
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/dynarray/dynarray.data/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.data
+
+// T* data() noexcept;
+// const T* data() const noexcept;
+
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void dyn_test_const ( const dynarray<T> &dyn ) {
+ const T *data = dyn.data ();
+ assert ( data != NULL );
+ assert ( std::equal ( dyn.begin(), dyn.end(), data ));
+ }
+
+template <class T>
+void dyn_test ( dynarray<T> &dyn ) {
+ T *data = dyn.data ();
+ assert ( data != NULL );
+ assert ( std::equal ( dyn.begin(), dyn.end(), data ));
+ }
+
+
+
+template <class T>
+void test ( const T &val ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( 4 );
+ dyn_test ( d1 );
+ dyn_test_const ( d1 );
+
+ dynA d2 ( 7, val );
+ dyn_test ( d2 );
+ dyn_test_const ( d2 );
+ }
+
+int main()
+{
+ test<int> ( 14 );
+ test<double> ( 14.0 );
+ test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
+ test<std::string> ( "fourteen" );
+}
+#else
+int main() {}
+#endif
diff --git a/libcxx/test/std/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp b/libcxx/test/std/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp
new file mode 100644
index 00000000000..c57887ddaf9
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/dynarray/dynarray.mutate/default.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.data
+
+// void fill(const T& v);
+// const T* data() const noexcept;
+
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void test ( const T &val ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( 4 );
+ d1.fill ( val );
+ assert ( std::all_of ( d1.begin (), d1.end (),
+ [&val]( const T &item ){ return item == val; } ));
+ }
+
+int main()
+{
+ test<int> ( 14 );
+ test<double> ( 14.0 );
+ test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
+ test<std::string> ( "fourteen" );
+}
+#else
+int main() {}
+#endif
diff --git a/libcxx/test/std/containers/sequences/dynarray/dynarray.overview/at.pass.cpp b/libcxx/test/std/containers/sequences/dynarray/dynarray.overview/at.pass.cpp
new file mode 100644
index 00000000000..4d77cf73275
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/dynarray/dynarray.overview/at.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.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.overview
+
+// const_reference at(size_type n) const;
+// reference at(size_type n);
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void dyn_at_fail ( dynarray<T> &dyn, size_t sz ) {
+ try { dyn.at (sz); }
+ catch (const std::out_of_range &) { return; }
+ assert ( false );
+ }
+
+template <class T>
+void dyn_at_fail_const ( const dynarray<T> &dyn, size_t sz ) {
+ try { dyn.at (sz); }
+ catch (const std::out_of_range &) { return; }
+ assert ( false );
+ }
+
+
+template <class T>
+void dyn_test_const ( const dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
+ const T *data = dyn.data ();
+ auto it = vals.begin ();
+ for ( size_t i = 0; i < dyn.size(); ++i, ++it ) {
+ assert ( data + i == &dyn.at(i));
+ assert ( *it == dyn.at(i));
+ }
+
+ dyn_at_fail_const ( dyn, dyn.size ());
+ dyn_at_fail_const ( dyn, 2*dyn.size ());
+ dyn_at_fail_const ( dyn, size_t (-1));
+ }
+
+template <class T>
+void dyn_test ( dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
+ T *data = dyn.data ();
+ auto it = vals.begin ();
+ for ( size_t i = 0; i < dyn.size(); ++i, ++it ) {
+ assert ( data + i == &dyn.at(i));
+ assert ( *it == dyn.at(i));
+ }
+
+ dyn_at_fail ( dyn, dyn.size ());
+ dyn_at_fail ( dyn, 2*dyn.size ());
+ dyn_at_fail ( dyn, size_t (-1));
+ }
+
+
+template <class T>
+void test ( std::initializer_list<T> vals ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( vals );
+ dyn_test ( d1, vals );
+ dyn_test_const ( d1, vals );
+ }
+
+int main()
+{
+ test ( { 1, 1, 2, 3, 5, 8 } );
+ test ( { 1., 1., 2., 3., 5., 8. } );
+ test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
+ std::string("5"), std::string("8")} );
+
+ test<int> ( {} );
+ test<std::complex<double>> ( {} );
+ test<std::string> ( {} );
+}
+#else
+int main() {}
+#endif
diff --git a/libcxx/test/std/containers/sequences/dynarray/dynarray.overview/begin_end.pass.cpp b/libcxx/test/std/containers/sequences/dynarray/dynarray.overview/begin_end.pass.cpp
new file mode 100644
index 00000000000..695e1aa9f14
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/dynarray/dynarray.overview/begin_end.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.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.overview
+
+
+// iterator begin() noexcept;
+// const_iterator begin() const noexcept;
+// const_iterator cbegin() const noexcept;
+// iterator end() noexcept;
+// const_iterator end() const noexcept;
+// const_iterator cend() const noexcept;
+//
+// reverse_iterator rbegin() noexcept;
+// const_reverse_iterator rbegin() const noexcept;
+// const_reverse_iterator crbegin() const noexcept;
+// reverse_iterator rend() noexcept;
+// const_reverse_iterator rend() const noexcept;
+// const_reverse_iterator crend() const noexcept;
+
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void dyn_test_const ( const dynarray<T> &dyn ) {
+ const T *data = dyn.data ();
+ assert ( data == &*dyn.begin ());
+ assert ( data == &*dyn.cbegin ());
+
+ assert ( data + dyn.size() - 1 == &*dyn.rbegin ());
+ assert ( data + dyn.size() - 1 == &*dyn.crbegin ());
+
+ assert ( dyn.size () == std::distance ( dyn.begin(), dyn.end()));
+ assert ( dyn.size () == std::distance ( dyn.cbegin(), dyn.cend()));
+ assert ( dyn.size () == std::distance ( dyn.rbegin(), dyn.rend()));
+ assert ( dyn.size () == std::distance ( dyn.crbegin(), dyn.crend()));
+
+ assert ( dyn.begin () == dyn.cbegin ());
+ assert ( &*dyn.begin () == &*dyn.cbegin ());
+ assert ( dyn.rbegin () == dyn.crbegin ());
+ assert ( &*dyn.rbegin () == &*dyn.crbegin ());
+ assert ( dyn.end () == dyn.cend ());
+ assert ( dyn.rend () == dyn.crend ());
+ }
+
+template <class T>
+void dyn_test ( dynarray<T> &dyn ) {
+ T *data = dyn.data ();
+ assert ( data == &*dyn.begin ());
+ assert ( data == &*dyn.cbegin ());
+
+ assert ( data + dyn.size() - 1 == &*dyn.rbegin ());
+ assert ( data + dyn.size() - 1 == &*dyn.crbegin ());
+
+ assert ( dyn.size () == std::distance ( dyn.begin(), dyn.end()));
+ assert ( dyn.size () == std::distance ( dyn.cbegin(), dyn.cend()));
+ assert ( dyn.size () == std::distance ( dyn.rbegin(), dyn.rend()));
+ assert ( dyn.size () == std::distance ( dyn.crbegin(), dyn.crend()));
+
+ assert ( dyn.begin () == dyn.cbegin ());
+ assert ( &*dyn.begin () == &*dyn.cbegin ());
+ assert ( dyn.rbegin () == dyn.crbegin ());
+ assert ( &*dyn.rbegin () == &*dyn.crbegin ());
+ assert ( dyn.end () == dyn.cend ());
+ assert ( dyn.rend () == dyn.crend ());
+ }
+
+
+template <class T>
+void test ( const T &val ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( 4 );
+ dyn_test ( d1 );
+ dyn_test_const ( d1 );
+
+ dynA d2 ( 7, val );
+ dyn_test ( d2 );
+ dyn_test_const ( d2 );
+ }
+
+int main()
+{
+ test<int> ( 14 );
+ test<double> ( 14.0 );
+ test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
+ test<std::string> ( "fourteen" );
+}
+#else
+int main() {}
+#endif
diff --git a/libcxx/test/std/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp b/libcxx/test/std/containers/sequences/dynarray/dynarray.overview/capacity.pass.cpp
new file mode 100644
index 00000000000..6d28eef1b05
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/dynarray/dynarray.overview/capacity.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.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.overview
+
+// size_type size() const noexcept;
+// size_type max_size() const noexcept;
+// bool empty() const noexcept;
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void dyn_test ( const dynarray<T> &dyn, size_t sz ) {
+ assert ( dyn.size () == sz );
+ assert ( dyn.max_size () == sz );
+ assert ( dyn.empty () == ( sz == 0 ));
+ }
+
+template <class T>
+void test ( std::initializer_list<T> vals ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( vals );
+ dyn_test ( d1, vals.size ());
+ }
+
+int main()
+{
+ test ( { 1, 1, 2, 3, 5, 8 } );
+ test ( { 1., 1., 2., 3., 5., 8. } );
+ test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
+ std::string("5"), std::string("8")} );
+
+ test<int> ( {} );
+ test<std::complex<double>> ( {} );
+ test<std::string> ( {} );
+}
+#else
+int main() {}
+#endif
diff --git a/libcxx/test/std/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp b/libcxx/test/std/containers/sequences/dynarray/dynarray.overview/front_back.pass.cpp
new file mode 100644
index 00000000000..e82aa64b98b
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/dynarray/dynarray.overview/front_back.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.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.overview
+
+// reference front();
+// const_reference front() const;
+// reference back();
+// const_reference back() const;
+
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void dyn_test_const ( const dynarray<T> &dyn ) {
+ const T *data = dyn.data ();
+ assert ( *data == dyn.front ());
+ assert ( *(data + dyn.size() - 1 ) == dyn.back ());
+ }
+
+template <class T>
+void dyn_test ( dynarray<T> &dyn ) {
+ T *data = dyn.data ();
+ assert ( *data == dyn.front ());
+ assert ( *(data + dyn.size() - 1 ) == dyn.back ());
+ }
+
+
+template <class T>
+void test ( const T &val ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( 4 );
+ dyn_test ( d1 );
+ dyn_test_const ( d1 );
+
+ dynA d2 ( 7, val );
+ dyn_test ( d2 );
+ dyn_test_const ( d2 );
+ }
+
+int main()
+{
+ test<int> ( 14 );
+ test<double> ( 14.0 );
+ test<std::complex<double>> ( std::complex<double> ( 14, 0 ));
+ test<std::string> ( "fourteen" );
+}
+#else
+int main() {}
+#endif
diff --git a/libcxx/test/std/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp b/libcxx/test/std/containers/sequences/dynarray/dynarray.overview/indexing.pass.cpp
new file mode 100644
index 00000000000..7317a2023cb
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/dynarray/dynarray.overview/indexing.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.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.overview
+
+// const_reference at(size_type n) const;
+// reference at(size_type n);
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void dyn_test_const ( const dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
+ const T *data = dyn.data ();
+ auto it = vals.begin ();
+ for ( size_t i = 0; i < dyn.size(); ++i, ++it ) {
+ assert ( data + i == &dyn[i]);
+ assert ( *it == dyn[i]);
+ }
+ }
+
+template <class T>
+void dyn_test ( dynarray<T> &dyn, const std::initializer_list<T> &vals ) {
+ T *data = dyn.data ();
+ auto it = vals.begin ();
+ for ( size_t i = 0; i < dyn.size(); ++i, ++it ) {
+ assert ( data + i == &dyn[i]);
+ assert ( *it == dyn[i]);
+ }
+ }
+
+
+template <class T>
+void test ( std::initializer_list<T> vals ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( vals );
+ dyn_test ( d1, vals );
+ dyn_test_const ( d1, vals );
+ }
+
+int main()
+{
+ test ( { 1, 1, 2, 3, 5, 8 } );
+ test ( { 1., 1., 2., 3., 5., 8. } );
+ test ( { std::string("1"), std::string("1"), std::string("2"), std::string("3"),
+ std::string("5"), std::string("8")} );
+
+ test<int> ( {} );
+ test<std::complex<double>> ( {} );
+ test<std::string> ( {} );
+}
+#else
+int main() {}
+#endif
diff --git a/libcxx/test/std/containers/sequences/dynarray/dynarray.traits/default.pass.cpp b/libcxx/test/std/containers/sequences/dynarray/dynarray.traits/default.pass.cpp
new file mode 100644
index 00000000000..9b8240d4cd8
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/dynarray/dynarray.traits/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.data
+
+// template <class Type, class Alloc>
+// struct uses_allocator<dynarray<Type>, Alloc> : true_type { };
+
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include "test_allocator.h"
+
+using std::experimental::dynarray;
+
+int main()
+{
+ static_assert ( std::uses_allocator<dynarray<int>, test_allocator<int>>::value, "" );
+}
+#else
+int main() {}
+#endif
diff --git a/libcxx/test/std/containers/sequences/dynarray/dynarray.zero/default.pass.cpp b/libcxx/test/std/containers/sequences/dynarray/dynarray.zero/default.pass.cpp
new file mode 100644
index 00000000000..93f3b18f192
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/dynarray/dynarray.zero/default.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// dynarray.zero
+
+// dynarray shall provide support for the special case of construction with a size of zero.
+// In the case that the size is zero, begin() == end() == unique value.
+// The return value of data() is unspecified.
+// The effect of calling front() or back() for a zero-sized dynarray is undefined.
+
+
+
+#include <__config>
+
+#if _LIBCPP_STD_VER > 11
+
+#include <experimental/dynarray>
+#include <cassert>
+
+#include <algorithm>
+#include <complex>
+#include <string>
+
+using std::experimental::dynarray;
+
+template <class T>
+void test ( ) {
+ typedef dynarray<T> dynA;
+
+ dynA d1 ( 0 );
+ assert ( d1.size() == 0 );
+ assert ( d1.begin() == d1.end ());
+ }
+
+int main()
+{
+ test<int> ();
+ test<double> ();
+ test<std::complex<double>> ();
+ test<std::string> ();
+}
+#else
+int main() {}
+#endif
diff --git a/libcxx/test/std/containers/sequences/dynarray/nothing_to_do.pass.cpp b/libcxx/test/std/containers/sequences/dynarray/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/dynarray/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp
new file mode 100644
index 00000000000..2ec9b871332
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.access/front.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// reference front();
+// const_reference front() const;
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ assert(c.front() == 0);
+ c.front() = 10;
+ assert(c.front() == 10);
+ assert(*c.begin() == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const C c(std::begin(t), std::end(t));
+ assert(c.front() == 0);
+ assert(*c.begin() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ assert(c.front() == 0);
+ c.front() = 10;
+ assert(c.front() == 10);
+ assert(*c.begin() == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const C c(std::begin(t), std::end(t));
+ assert(c.front() == 0);
+ assert(*c.begin() == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.fail.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.fail.cpp
new file mode 100644
index 00000000000..cd4d1ede120
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.fail.cpp
@@ -0,0 +1,30 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// explicit forward_list(const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "../../../NotConstructible.h"
+
+int main()
+{
+ {
+ typedef test_allocator<NotConstructible> A;
+ typedef A::value_type T;
+ typedef std::forward_list<T, A> C;
+ C c = A(12);
+ assert(c.get_allocator() == A(12));
+ assert(c.empty());
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp
new file mode 100644
index 00000000000..7aba906ec20
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// explicit forward_list(const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "../../../NotConstructible.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_allocator<NotConstructible> A;
+ typedef A::value_type T;
+ typedef std::forward_list<T, A> C;
+ C c(A(12));
+ assert(c.get_allocator() == A(12));
+ assert(c.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<NotConstructible> A;
+ typedef A::value_type T;
+ typedef std::forward_list<T, A> C;
+ C c(A{});
+ assert(c.get_allocator() == A());
+ assert(c.empty());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp
new file mode 100644
index 00000000000..0b9263db989
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list& operator=(const forward_list& x);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef test_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const T t1[] = {10, 11, 12, 13};
+ C c0(std::begin(t0), std::end(t0), A(10));
+ C c1(std::begin(t1), std::end(t1), A(10));
+ c1 = c0;
+ assert(c1 == c0);
+ assert(c1.get_allocator() == A(10));
+ }
+ {
+ typedef int T;
+ typedef test_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const T t1[] = {10, 11, 12, 13};
+ C c0(std::begin(t0), std::end(t0), A(10));
+ C c1(std::begin(t1), std::end(t1), A(11));
+ c1 = c0;
+ assert(c1 == c0);
+ assert(c1.get_allocator() == A(11));
+ }
+ {
+ typedef int T;
+ typedef test_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t0[] = {10, 11, 12, 13};
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c0(std::begin(t0), std::end(t0), A(10));
+ C c1(std::begin(t1), std::end(t1), A(10));
+ c1 = c0;
+ assert(c1 == c0);
+ assert(c1.get_allocator() == A(10));
+ }
+ {
+ typedef int T;
+ typedef test_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t0[] = {10, 11, 12, 13};
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c0(std::begin(t0), std::end(t0), A(10));
+ C c1(std::begin(t1), std::end(t1), A(11));
+ c1 = c0;
+ assert(c1 == c0);
+ assert(c1.get_allocator() == A(11));
+ }
+
+ {
+ typedef int T;
+ typedef other_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const T t1[] = {10, 11, 12, 13};
+ C c0(std::begin(t0), std::end(t0), A(10));
+ C c1(std::begin(t1), std::end(t1), A(10));
+ c1 = c0;
+ assert(c1 == c0);
+ assert(c1.get_allocator() == A(10));
+ }
+ {
+ typedef int T;
+ typedef other_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const T t1[] = {10, 11, 12, 13};
+ C c0(std::begin(t0), std::end(t0), A(10));
+ C c1(std::begin(t1), std::end(t1), A(11));
+ c1 = c0;
+ assert(c1 == c0);
+ assert(c1.get_allocator() == A(10));
+ }
+ {
+ typedef int T;
+ typedef other_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t0[] = {10, 11, 12, 13};
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c0(std::begin(t0), std::end(t0), A(10));
+ C c1(std::begin(t1), std::end(t1), A(10));
+ c1 = c0;
+ assert(c1 == c0);
+ assert(c1.get_allocator() == A(10));
+ }
+ {
+ typedef int T;
+ typedef other_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t0[] = {10, 11, 12, 13};
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c0(std::begin(t0), std::end(t0), A(10));
+ C c1(std::begin(t1), std::end(t1), A(11));
+ c1 = c0;
+ assert(c1 == c0);
+ assert(c1.get_allocator() == A(10));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef min_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const T t1[] = {10, 11, 12, 13};
+ C c0(std::begin(t0), std::end(t0), A());
+ C c1(std::begin(t1), std::end(t1), A());
+ c1 = c0;
+ assert(c1 == c0);
+ assert(c1.get_allocator() == A());
+ }
+ {
+ typedef int T;
+ typedef min_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t0[] = {10, 11, 12, 13};
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c0(std::begin(t0), std::end(t0), A());
+ C c1(std::begin(t1), std::end(t1), A());
+ c1 = c0;
+ assert(c1 == c0);
+ assert(c1.get_allocator() == A());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp
new file mode 100644
index 00000000000..e0382a10db4
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_init.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void assign(initializer_list<value_type> il);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {10, 11, 12, 13};
+ C c(std::begin(t1), std::end(t1));
+ c.assign({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t1), std::end(t1));
+ c.assign({10, 11, 12, 13});
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == 10+n);
+ assert(n == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {10, 11, 12, 13};
+ C c(std::begin(t1), std::end(t1));
+ c.assign({0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t1), std::end(t1));
+ c.assign({10, 11, 12, 13});
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == 10+n);
+ assert(n == 4);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp
new file mode 100644
index 00000000000..a3d270f01d9
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp
@@ -0,0 +1,199 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list& operator=(forward_list&& x);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_allocator.h"
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef MoveOnly T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ T t1[] = {10, 11, 12, 13};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+ C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
+ c1 = std::move(c0);
+ int n = 0;
+ for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ assert(c1.get_allocator() == A(10));
+ assert(c0.empty());
+ }
+ {
+ typedef MoveOnly T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ T t1[] = {10, 11, 12, 13};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+ C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
+ c1 = std::move(c0);
+ int n = 0;
+ for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ assert(c1.get_allocator() == A(11));
+ assert(!c0.empty());
+ }
+ {
+ typedef MoveOnly T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ T t0[] = {10, 11, 12, 13};
+ T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+ C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
+ c1 = std::move(c0);
+ int n = 0;
+ for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+ assert(*i == 10+n);
+ assert(n == 4);
+ assert(c1.get_allocator() == A(10));
+ assert(c0.empty());
+ }
+ {
+ typedef MoveOnly T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ T t0[] = {10, 11, 12, 13};
+ T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+ C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
+ c1 = std::move(c0);
+ int n = 0;
+ for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+ assert(*i == 10+n);
+ assert(n == 4);
+ assert(c1.get_allocator() == A(11));
+ assert(!c0.empty());
+ }
+
+ {
+ typedef MoveOnly T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ T t1[] = {10, 11, 12, 13};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+ C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
+ c1 = std::move(c0);
+ int n = 0;
+ for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ assert(c1.get_allocator() == A(10));
+ assert(c0.empty());
+ }
+ {
+ typedef MoveOnly T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ T t1[] = {10, 11, 12, 13};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+ C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
+ c1 = std::move(c0);
+ int n = 0;
+ for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ assert(c1.get_allocator() == A(10));
+ assert(c0.empty());
+ }
+ {
+ typedef MoveOnly T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ T t0[] = {10, 11, 12, 13};
+ T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+ C c1(I(std::begin(t1)), I(std::end(t1)), A(10));
+ c1 = std::move(c0);
+ int n = 0;
+ for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+ assert(*i == 10+n);
+ assert(n == 4);
+ assert(c1.get_allocator() == A(10));
+ assert(c0.empty());
+ }
+ {
+ typedef MoveOnly T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ T t0[] = {10, 11, 12, 13};
+ T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t0)), I(std::end(t0)), A(10));
+ C c1(I(std::begin(t1)), I(std::end(t1)), A(11));
+ c1 = std::move(c0);
+ int n = 0;
+ for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+ assert(*i == 10+n);
+ assert(n == 4);
+ assert(c1.get_allocator() == A(10));
+ assert(c0.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef MoveOnly T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ T t1[] = {10, 11, 12, 13};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t0)), I(std::end(t0)), A());
+ C c1(I(std::begin(t1)), I(std::end(t1)), A());
+ c1 = std::move(c0);
+ int n = 0;
+ for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ assert(c1.get_allocator() == A());
+ assert(c0.empty());
+ }
+ {
+ typedef MoveOnly T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ T t0[] = {10, 11, 12, 13};
+ T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t0)), I(std::end(t0)), A());
+ C c1(I(std::begin(t1)), I(std::end(t1)), A());
+ c1 = std::move(c0);
+ int n = 0;
+ for (C::const_iterator i = c1.cbegin(); i != c1.cend(); ++i, ++n)
+ assert(*i == 10+n);
+ assert(n == 4);
+ assert(c1.get_allocator() == A());
+ assert(c0.empty());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp
new file mode 100644
index 00000000000..551908fea16
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list& operator=(initializer_list<value_type> il);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {10, 11, 12, 13};
+ C c(std::begin(t1), std::end(t1));
+ c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t1), std::end(t1));
+ c = {10, 11, 12, 13};
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == 10+n);
+ assert(n == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {10, 11, 12, 13};
+ C c(std::begin(t1), std::end(t1));
+ c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t1), std::end(t1));
+ c = {10, 11, 12, 13};
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == 10+n);
+ assert(n == 4);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp
new file mode 100644
index 00000000000..0b348e6920c
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class InputIterator>
+// void assign(InputIterator first, InputIterator last);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const T t1[] = {10, 11, 12, 13};
+ C c(std::begin(t1), std::end(t1));
+ typedef input_iterator<const T*> I;
+ c.assign(I(std::begin(t0)), I(std::end(t0)));
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t0[] = {10, 11, 12, 13};
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t1), std::end(t1));
+ typedef input_iterator<const T*> I;
+ c.assign(I(std::begin(t0)), I(std::end(t0)));
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == 10+n);
+ assert(n == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t0[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const T t1[] = {10, 11, 12, 13};
+ C c(std::begin(t1), std::end(t1));
+ typedef input_iterator<const T*> I;
+ c.assign(I(std::begin(t0)), I(std::end(t0)));
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t0[] = {10, 11, 12, 13};
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t1), std::end(t1));
+ typedef input_iterator<const T*> I;
+ c.assign(I(std::begin(t0)), I(std::end(t0)));
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, (void) ++n)
+ assert(*i == 10+n);
+ assert(n == 4);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp
new file mode 100644
index 00000000000..ea53e1c3732
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void assign(size_type n, const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {10, 11, 12, 13};
+ C c(std::begin(t1), std::end(t1));
+ c.assign(10, 1);
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == 1);
+ assert(n == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t1), std::end(t1));
+ c.assign(4, 10);
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == 10);
+ assert(n == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {10, 11, 12, 13};
+ C c(std::begin(t1), std::end(t1));
+ c.assign(10, 1);
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == 1);
+ assert(n == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t1), std::end(t1));
+ c.assign(4, 10);
+ int n = 0;
+ for (C::const_iterator i = c.cbegin(); i != c.cend(); ++i, ++n)
+ assert(*i == 10);
+ assert(n == 4);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp
new file mode 100644
index 00000000000..2fc53bc3a51
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/copy.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(const forward_list& x);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef test_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c0(std::begin(t), std::end(t), A(10));
+ C c = c0;
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c == c0);
+ assert(c.get_allocator() == A(10));
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ typedef int T;
+ typedef other_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c0(std::begin(t), std::end(t), A(10));
+ C c = c0;
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c == c0);
+ assert(c.get_allocator() == A(-2));
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef min_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c0(std::begin(t), std::end(t), A());
+ C c = c0;
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c == c0);
+ assert(c.get_allocator() == A());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp
new file mode 100644
index 00000000000..bcc24e1cc68
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(const forward_list& x, const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef test_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c0(std::begin(t), std::end(t), A(10));
+ C c(c0, A(9));
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c == c0);
+ assert(c.get_allocator() == A(9));
+ }
+ {
+ typedef int T;
+ typedef other_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c0(std::begin(t), std::end(t), A(10));
+ C c(c0, A(9));
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c == c0);
+ assert(c.get_allocator() == A(9));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef min_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c0(std::begin(t), std::end(t), A());
+ C c(c0, A());
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c == c0);
+ assert(c.get_allocator() == A());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp
new file mode 100644
index 00000000000..38e95fad839
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list();
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C c;
+ assert(c.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ assert(c.empty());
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C c = {};
+ assert(c.empty());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp
new file mode 100644
index 00000000000..6b0233d65b6
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list()
+// noexcept(is_nothrow_default_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::forward_list<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/default_recursive.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/default_recursive.pass.cpp
new file mode 100644
index 00000000000..5ff00e6fe52
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/default_recursive.pass.cpp
@@ -0,0 +1,25 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// class forward_list
+
+// forward_list();
+
+#include <forward_list>
+
+struct X
+{
+ std::forward_list<X> q;
+};
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 00000000000..1f7b05efd66
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// ~forward_list() // implied noexcept;
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+ ~some_alloc() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::forward_list<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp
new file mode 100644
index 00000000000..5b31c4dad0a
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/init.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(initializer_list<value_type> il);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp
new file mode 100644
index 00000000000..750486b829f
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(initializer_list<value_type> il, const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef int T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, A(14));
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ assert(c.get_allocator() == A(14));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c({0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, A());
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == 10);
+ assert(c.get_allocator() == A());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp
new file mode 100644
index 00000000000..164801a0b40
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/move.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(forward_list&& x);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_allocator.h"
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef MoveOnly T;
+ typedef test_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t)), I(std::end(t)), A(10));
+ C c = std::move(c0);
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c0.empty());
+ assert(c.get_allocator() == A(10));
+ }
+ {
+ typedef MoveOnly T;
+ typedef other_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t)), I(std::end(t)), A(10));
+ C c = std::move(c0);
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c0.empty());
+ assert(c.get_allocator() == A(10));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef MoveOnly T;
+ typedef min_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t)), I(std::end(t)), A());
+ C c = std::move(c0);
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c0.empty());
+ assert(c.get_allocator() == A());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp
new file mode 100644
index 00000000000..ba0cb5d3beb
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(forward_list&& x, const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_allocator.h"
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef MoveOnly T;
+ typedef test_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t)), I(std::end(t)), A(10));
+ C c(std::move(c0), A(10));
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c0.empty());
+ assert(c.get_allocator() == A(10));
+ }
+ {
+ typedef MoveOnly T;
+ typedef test_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t)), I(std::end(t)), A(10));
+ C c(std::move(c0), A(9));
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(!c0.empty());
+ assert(c.get_allocator() == A(9));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef MoveOnly T;
+ typedef min_allocator<int> A;
+ typedef std::forward_list<T, A> C;
+ T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ typedef std::move_iterator<T*> I;
+ C c0(I(std::begin(t)), I(std::end(t)), A());
+ C c(std::move(c0), A());
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c0.empty());
+ assert(c.get_allocator() == A());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 00000000000..cc5b9d54ed3
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list& operator=(forward_list&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::forward_list<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp
new file mode 100644
index 00000000000..3666c7d169d
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(forward_list&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::forward_list<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp
new file mode 100644
index 00000000000..763952439f0
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class InputIterator>
+// forward_list(InputIterator first, InputIterator last);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ typedef input_iterator<const T*> I;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(I(std::begin(t)), I(std::end(t)));
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ typedef input_iterator<const T*> I;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(I(std::begin(t)), I(std::end(t)));
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp
new file mode 100644
index 00000000000..d72c3581022
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class InputIterator>
+// forward_list(InputIterator first, InputIterator last,
+// const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "test_allocator.h"
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ typedef input_iterator<const T*> I;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(I(std::begin(t)), I(std::end(t)), A(13));
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c.get_allocator() == A(13));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ typedef input_iterator<const T*> I;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(I(std::begin(t)), I(std::end(t)), A());
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == n);
+ assert(n == std::end(t) - std::begin(t));
+ assert(c.get_allocator() == A());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/size.fail.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/size.fail.cpp
new file mode 100644
index 00000000000..2d963a1be47
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/size.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// explicit forward_list(size_type n);
+
+#include <forward_list>
+#include <cassert>
+
+#include "DefaultOnly.h"
+
+int main()
+{
+ {
+ typedef DefaultOnly T;
+ typedef std::forward_list<T> C;
+ unsigned N = 10;
+ C c = N;
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(*i == T());
+#else
+ ;
+#endif
+ assert(n == N);
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp
new file mode 100644
index 00000000000..e02dcb4bf69
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// explicit forward_list(size_type n);
+// explicit forward_list(size_type n, const Alloc& a);
+
+#include <forward_list>
+#include <cassert>
+
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void check_allocator(unsigned n, Allocator const &alloc = Allocator())
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::forward_list<T, Allocator> C;
+ C d(n, alloc);
+ assert(d.get_allocator() == alloc);
+ assert(std::distance(d.begin(), d.end()) == n);
+#endif
+}
+
+int main()
+{
+ {
+ typedef DefaultOnly T;
+ typedef std::forward_list<T> C;
+ unsigned N = 10;
+ C c(N);
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(*i == T());
+#else
+ ;
+#endif
+ assert(n == N);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef DefaultOnly T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ unsigned N = 10;
+ C c(N);
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ assert(*i == T());
+#else
+ ;
+#endif
+ assert(n == N);
+ check_allocator<T, min_allocator<T>> ( 0 );
+ check_allocator<T, min_allocator<T>> ( 3 );
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp
new file mode 100644
index 00000000000..05ab98bb205
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/size_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(size_type n, const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ T v(6);
+ unsigned N = 10;
+ C c(N, v);
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == v);
+ assert(n == N);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ T v(6);
+ unsigned N = 10;
+ C c(N, v);
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == v);
+ assert(n == N);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp
new file mode 100644
index 00000000000..1d631ab12ba
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// forward_list(size_type n, const value_type& v, const allocator_type& a);
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_allocator<int> A;
+ typedef A::value_type T;
+ typedef std::forward_list<T, A> C;
+ T v(6);
+ unsigned N = 10;
+ C c(N, v, A(12));
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == v);
+ assert(n == N);
+ assert(c.get_allocator() == A(12));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<int> A;
+ typedef A::value_type T;
+ typedef std::forward_list<T, A> C;
+ T v(6);
+ unsigned N = 10;
+ C c(N, v, A());
+ unsigned n = 0;
+ for (C::const_iterator i = c.begin(), e = c.end(); i != e; ++i, ++n)
+ assert(*i == v);
+ assert(n == N);
+ assert(c.get_allocator() == A());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp
new file mode 100644
index 00000000000..083cec2886d
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.iter/before_begin.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator before_begin();
+// const_iterator before_begin() const;
+// const_iterator cbefore_begin() const;
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C c;
+ C::iterator i = c.before_begin();
+ assert(std::distance(i, c.end()) == 1);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const C c;
+ C::const_iterator i = c.before_begin();
+ assert(std::distance(i, c.end()) == 1);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const C c;
+ C::const_iterator i = c.cbefore_begin();
+ assert(std::distance(i, c.end()) == 1);
+ assert(c.cbefore_begin() == c.before_begin());
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ C::iterator i = c.before_begin();
+ assert(std::distance(i, c.end()) == 11);
+ assert(std::next(c.before_begin()) == c.begin());
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const C c(std::begin(t), std::end(t));
+ C::const_iterator i = c.before_begin();
+ assert(std::distance(i, c.end()) == 11);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ C::iterator i = c.before_begin();
+ assert(std::distance(i, c.end()) == 1);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const C c;
+ C::const_iterator i = c.before_begin();
+ assert(std::distance(i, c.end()) == 1);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const C c;
+ C::const_iterator i = c.cbefore_begin();
+ assert(std::distance(i, c.end()) == 1);
+ assert(c.cbefore_begin() == c.before_begin());
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ C::iterator i = c.before_begin();
+ assert(std::distance(i, c.end()) == 11);
+ assert(std::next(c.before_begin()) == c.begin());
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ const C c(std::begin(t), std::end(t));
+ C::const_iterator i = c.before_begin();
+ assert(std::distance(i, c.end()) == 11);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp
new file mode 100644
index 00000000000..6f3ac548db8
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp
@@ -0,0 +1,145 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator begin();
+// iterator end();
+// const_iterator begin() const;
+// const_iterator end() const;
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C c;
+ C::iterator i = c.begin();
+ C::iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const C c;
+ C::const_iterator i = c.begin();
+ C::const_iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C c;
+ C::const_iterator i = c.cbegin();
+ C::const_iterator j = c.cend();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ assert(i == c.end());
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ C::iterator i = c.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 1);
+ *i = 10;
+ assert(*i == 10);
+ assert(std::distance(c.begin(), c.end()) == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C::iterator i;
+ C::const_iterator j;
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ C::iterator i = c.begin();
+ C::iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const C c;
+ C::const_iterator i = c.begin();
+ C::const_iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ C::const_iterator i = c.cbegin();
+ C::const_iterator j = c.cend();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ assert(i == c.end());
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ C::iterator i = c.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 1);
+ *i = 10;
+ assert(*i == 10);
+ assert(std::distance(c.begin(), c.end()) == 10);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C::iterator i;
+ C::const_iterator j;
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ std::forward_list<int>::iterator ii1{}, ii2{};
+ std::forward_list<int>::iterator ii4 = ii1;
+ std::forward_list<int>::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+
+// std::forward_list<int> c;
+// assert ( ii1 != c.cbegin());
+// assert ( cii != c.begin());
+// assert ( cii != c.cend());
+// assert ( ii1 != c.end());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp
new file mode 100644
index 00000000000..2739b49d8eb
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void clear();
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef NotConstructible T;
+ typedef std::forward_list<T> C;
+ C c;
+ c.clear();
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t[] = {0, 1, 2, 3, 4};
+ C c(std::begin(t), std::end(t));
+
+ c.clear();
+ assert(distance(c.begin(), c.end()) == 0);
+
+ c.clear();
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef NotConstructible T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ c.clear();
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4};
+ C c(std::begin(t), std::end(t));
+
+ c.clear();
+ assert(distance(c.begin(), c.end()) == 0);
+
+ c.clear();
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp
new file mode 100644
index 00000000000..e305c5b6ab5
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class... Args>
+// iterator emplace_after(const_iterator p, Args&&... args);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef Emplaceable T;
+ typedef std::forward_list<T> C;
+ typedef C::iterator I;
+ C c;
+ I i = c.emplace_after(c.cbefore_begin());
+ assert(i == c.begin());
+ assert(c.front() == Emplaceable());
+ assert(distance(c.begin(), c.end()) == 1);
+
+ i = c.emplace_after(c.cbegin(), 1, 2.5);
+ assert(i == next(c.begin()));
+ assert(c.front() == Emplaceable());
+ assert(*next(c.begin()) == Emplaceable(1, 2.5));
+ assert(distance(c.begin(), c.end()) == 2);
+
+ i = c.emplace_after(next(c.cbegin()), 2, 3.5);
+ assert(i == next(c.begin(), 2));
+ assert(c.front() == Emplaceable());
+ assert(*next(c.begin()) == Emplaceable(1, 2.5));
+ assert(*next(c.begin(), 2) == Emplaceable(2, 3.5));
+ assert(distance(c.begin(), c.end()) == 3);
+
+ i = c.emplace_after(c.cbegin(), 3, 4.5);
+ assert(i == next(c.begin()));
+ assert(c.front() == Emplaceable());
+ assert(*next(c.begin(), 1) == Emplaceable(3, 4.5));
+ assert(*next(c.begin(), 2) == Emplaceable(1, 2.5));
+ assert(*next(c.begin(), 3) == Emplaceable(2, 3.5));
+ assert(distance(c.begin(), c.end()) == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef Emplaceable T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ typedef C::iterator I;
+ C c;
+ I i = c.emplace_after(c.cbefore_begin());
+ assert(i == c.begin());
+ assert(c.front() == Emplaceable());
+ assert(distance(c.begin(), c.end()) == 1);
+
+ i = c.emplace_after(c.cbegin(), 1, 2.5);
+ assert(i == next(c.begin()));
+ assert(c.front() == Emplaceable());
+ assert(*next(c.begin()) == Emplaceable(1, 2.5));
+ assert(distance(c.begin(), c.end()) == 2);
+
+ i = c.emplace_after(next(c.cbegin()), 2, 3.5);
+ assert(i == next(c.begin(), 2));
+ assert(c.front() == Emplaceable());
+ assert(*next(c.begin()) == Emplaceable(1, 2.5));
+ assert(*next(c.begin(), 2) == Emplaceable(2, 3.5));
+ assert(distance(c.begin(), c.end()) == 3);
+
+ i = c.emplace_after(c.cbegin(), 3, 4.5);
+ assert(i == next(c.begin()));
+ assert(c.front() == Emplaceable());
+ assert(*next(c.begin(), 1) == Emplaceable(3, 4.5));
+ assert(*next(c.begin(), 2) == Emplaceable(1, 2.5));
+ assert(*next(c.begin(), 3) == Emplaceable(2, 3.5));
+ assert(distance(c.begin(), c.end()) == 4);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp
new file mode 100644
index 00000000000..c02337e0562
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class... Args> void emplace_front(Args&&... args);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef Emplaceable T;
+ typedef std::forward_list<T> C;
+ C c;
+ c.emplace_front();
+ assert(c.front() == Emplaceable());
+ assert(distance(c.begin(), c.end()) == 1);
+ c.emplace_front(1, 2.5);
+ assert(c.front() == Emplaceable(1, 2.5));
+ assert(*next(c.begin()) == Emplaceable());
+ assert(distance(c.begin(), c.end()) == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef Emplaceable T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ c.emplace_front();
+ assert(c.front() == Emplaceable());
+ assert(distance(c.begin(), c.end()) == 1);
+ c.emplace_front(1, 2.5);
+ assert(c.front() == Emplaceable(1, 2.5));
+ assert(*next(c.begin()) == Emplaceable());
+ assert(distance(c.begin(), c.end()) == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp
new file mode 100644
index 00000000000..bd9b15300ef
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp
@@ -0,0 +1,155 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator erase_after(const_iterator first, const_iterator last);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+
+ C::iterator i = c.erase_after(next(c.cbefore_begin(), 4), next(c.cbefore_begin(), 4));
+ assert(i == next(c.cbefore_begin(), 4));
+ assert(distance(c.begin(), c.end()) == 10);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 3);
+ assert(*next(c.begin(), 4) == 4);
+ assert(*next(c.begin(), 5) == 5);
+ assert(*next(c.begin(), 6) == 6);
+ assert(*next(c.begin(), 7) == 7);
+ assert(*next(c.begin(), 8) == 8);
+ assert(*next(c.begin(), 9) == 9);
+
+ i = c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 5));
+ assert(i == next(c.begin(), 2));
+ assert(distance(c.begin(), c.end()) == 8);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 4);
+ assert(*next(c.begin(), 3) == 5);
+ assert(*next(c.begin(), 4) == 6);
+ assert(*next(c.begin(), 5) == 7);
+ assert(*next(c.begin(), 6) == 8);
+ assert(*next(c.begin(), 7) == 9);
+
+ i = c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 3));
+ assert(i == next(c.begin(), 2));
+ assert(distance(c.begin(), c.end()) == 8);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 4);
+ assert(*next(c.begin(), 3) == 5);
+ assert(*next(c.begin(), 4) == 6);
+ assert(*next(c.begin(), 5) == 7);
+ assert(*next(c.begin(), 6) == 8);
+ assert(*next(c.begin(), 7) == 9);
+
+ i = c.erase_after(next(c.cbefore_begin(), 5), next(c.cbefore_begin(), 9));
+ assert(i == c.end());
+ assert(distance(c.begin(), c.end()) == 5);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 4);
+ assert(*next(c.begin(), 3) == 5);
+ assert(*next(c.begin(), 4) == 6);
+
+ i = c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 2));
+ assert(i == c.begin());
+ assert(distance(c.begin(), c.end()) == 4);
+ assert(*next(c.begin(), 0) == 1);
+ assert(*next(c.begin(), 1) == 4);
+ assert(*next(c.begin(), 2) == 5);
+ assert(*next(c.begin(), 3) == 6);
+
+ i = c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 5));
+ assert(i == c.begin());
+ assert(i == c.end());
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+
+ C::iterator i = c.erase_after(next(c.cbefore_begin(), 4), next(c.cbefore_begin(), 4));
+ assert(i == next(c.cbefore_begin(), 4));
+ assert(distance(c.begin(), c.end()) == 10);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 3);
+ assert(*next(c.begin(), 4) == 4);
+ assert(*next(c.begin(), 5) == 5);
+ assert(*next(c.begin(), 6) == 6);
+ assert(*next(c.begin(), 7) == 7);
+ assert(*next(c.begin(), 8) == 8);
+ assert(*next(c.begin(), 9) == 9);
+
+ i = c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 5));
+ assert(i == next(c.begin(), 2));
+ assert(distance(c.begin(), c.end()) == 8);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 4);
+ assert(*next(c.begin(), 3) == 5);
+ assert(*next(c.begin(), 4) == 6);
+ assert(*next(c.begin(), 5) == 7);
+ assert(*next(c.begin(), 6) == 8);
+ assert(*next(c.begin(), 7) == 9);
+
+ i = c.erase_after(next(c.cbefore_begin(), 2), next(c.cbefore_begin(), 3));
+ assert(i == next(c.begin(), 2));
+ assert(distance(c.begin(), c.end()) == 8);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 4);
+ assert(*next(c.begin(), 3) == 5);
+ assert(*next(c.begin(), 4) == 6);
+ assert(*next(c.begin(), 5) == 7);
+ assert(*next(c.begin(), 6) == 8);
+ assert(*next(c.begin(), 7) == 9);
+
+ i = c.erase_after(next(c.cbefore_begin(), 5), next(c.cbefore_begin(), 9));
+ assert(i == c.end());
+ assert(distance(c.begin(), c.end()) == 5);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 4);
+ assert(*next(c.begin(), 3) == 5);
+ assert(*next(c.begin(), 4) == 6);
+
+ i = c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 2));
+ assert(i == c.begin());
+ assert(distance(c.begin(), c.end()) == 4);
+ assert(*next(c.begin(), 0) == 1);
+ assert(*next(c.begin(), 1) == 4);
+ assert(*next(c.begin(), 2) == 5);
+ assert(*next(c.begin(), 3) == 6);
+
+ i = c.erase_after(next(c.cbefore_begin(), 0), next(c.cbefore_begin(), 5));
+ assert(i == c.begin());
+ assert(i == c.end());
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp
new file mode 100644
index 00000000000..4f51498bc65
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator erase_after(const_iterator p);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t[] = {0, 1, 2, 3, 4};
+ C c(std::begin(t), std::end(t));
+
+ C::iterator i = c.erase_after(next(c.cbefore_begin(), 4));
+ assert(i == c.end());
+ assert(distance(c.begin(), c.end()) == 4);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 3);
+
+ i = c.erase_after(next(c.cbefore_begin(), 0));
+ assert(i == c.begin());
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 1);
+ assert(*next(c.begin(), 1) == 2);
+ assert(*next(c.begin(), 2) == 3);
+
+ i = c.erase_after(next(c.cbefore_begin(), 1));
+ assert(i == next(c.begin()));
+ assert(distance(c.begin(), c.end()) == 2);
+ assert(*next(c.begin(), 0) == 1);
+ assert(*next(c.begin(), 1) == 3);
+
+ i = c.erase_after(next(c.cbefore_begin(), 1));
+ assert(i == c.end());
+ assert(distance(c.begin(), c.end()) == 1);
+ assert(*next(c.begin(), 0) == 1);
+
+ i = c.erase_after(next(c.cbefore_begin(), 0));
+ assert(i == c.begin());
+ assert(i == c.end());
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4};
+ C c(std::begin(t), std::end(t));
+
+ C::iterator i = c.erase_after(next(c.cbefore_begin(), 4));
+ assert(i == c.end());
+ assert(distance(c.begin(), c.end()) == 4);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 3);
+
+ i = c.erase_after(next(c.cbefore_begin(), 0));
+ assert(i == c.begin());
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 1);
+ assert(*next(c.begin(), 1) == 2);
+ assert(*next(c.begin(), 2) == 3);
+
+ i = c.erase_after(next(c.cbefore_begin(), 1));
+ assert(i == next(c.begin()));
+ assert(distance(c.begin(), c.end()) == 2);
+ assert(*next(c.begin(), 0) == 1);
+ assert(*next(c.begin(), 1) == 3);
+
+ i = c.erase_after(next(c.cbefore_begin(), 1));
+ assert(i == c.end());
+ assert(distance(c.begin(), c.end()) == 1);
+ assert(*next(c.begin(), 0) == 1);
+
+ i = c.erase_after(next(c.cbefore_begin(), 0));
+ assert(i == c.begin());
+ assert(i == c.end());
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp
new file mode 100644
index 00000000000..ec650b69572
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator insert_after(const_iterator p, const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ typedef C::iterator I;
+ C c;
+ I i = c.insert_after(c.cbefore_begin(), 0);
+ assert(i == c.begin());
+ assert(c.front() == 0);
+ assert(c.front() == 0);
+ assert(distance(c.begin(), c.end()) == 1);
+
+ i = c.insert_after(c.cbegin(), 1);
+ assert(i == next(c.begin()));
+ assert(c.front() == 0);
+ assert(*next(c.begin()) == 1);
+ assert(distance(c.begin(), c.end()) == 2);
+
+ i = c.insert_after(next(c.cbegin()), 2);
+ assert(i == next(c.begin(), 2));
+ assert(c.front() == 0);
+ assert(*next(c.begin()) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(distance(c.begin(), c.end()) == 3);
+
+ i = c.insert_after(c.cbegin(), 3);
+ assert(i == next(c.begin()));
+ assert(c.front() == 0);
+ assert(*next(c.begin(), 1) == 3);
+ assert(*next(c.begin(), 2) == 1);
+ assert(*next(c.begin(), 3) == 2);
+ assert(distance(c.begin(), c.end()) == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ typedef C::iterator I;
+ C c;
+ I i = c.insert_after(c.cbefore_begin(), 0);
+ assert(i == c.begin());
+ assert(c.front() == 0);
+ assert(c.front() == 0);
+ assert(distance(c.begin(), c.end()) == 1);
+
+ i = c.insert_after(c.cbegin(), 1);
+ assert(i == next(c.begin()));
+ assert(c.front() == 0);
+ assert(*next(c.begin()) == 1);
+ assert(distance(c.begin(), c.end()) == 2);
+
+ i = c.insert_after(next(c.cbegin()), 2);
+ assert(i == next(c.begin(), 2));
+ assert(c.front() == 0);
+ assert(*next(c.begin()) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(distance(c.begin(), c.end()) == 3);
+
+ i = c.insert_after(c.cbegin(), 3);
+ assert(i == next(c.begin()));
+ assert(c.front() == 0);
+ assert(*next(c.begin(), 1) == 3);
+ assert(*next(c.begin(), 2) == 1);
+ assert(*next(c.begin(), 3) == 2);
+ assert(distance(c.begin(), c.end()) == 4);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp
new file mode 100644
index 00000000000..4d301819980
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator insert_after(const_iterator p, initializer_list<value_type> il);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ typedef C::iterator I;
+ C c;
+ I i = c.insert_after(c.cbefore_begin(), {});
+ assert(i == c.before_begin());
+ assert(distance(c.begin(), c.end()) == 0);
+
+ i = c.insert_after(c.cbefore_begin(), {0, 1, 2});
+ assert(i == next(c.before_begin(), 3));
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+
+ i = c.insert_after(c.begin(), {3, 4});
+ assert(i == next(c.begin(), 2));
+ assert(distance(c.begin(), c.end()) == 5);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 3);
+ assert(*next(c.begin(), 2) == 4);
+ assert(*next(c.begin(), 3) == 1);
+ assert(*next(c.begin(), 4) == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ typedef C::iterator I;
+ C c;
+ I i = c.insert_after(c.cbefore_begin(), {});
+ assert(i == c.before_begin());
+ assert(distance(c.begin(), c.end()) == 0);
+
+ i = c.insert_after(c.cbefore_begin(), {0, 1, 2});
+ assert(i == next(c.before_begin(), 3));
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+
+ i = c.insert_after(c.begin(), {3, 4});
+ assert(i == next(c.begin(), 2));
+ assert(distance(c.begin(), c.end()) == 5);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 3);
+ assert(*next(c.begin(), 2) == 4);
+ assert(*next(c.begin(), 3) == 1);
+ assert(*next(c.begin(), 4) == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp
new file mode 100644
index 00000000000..103475f1eda
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class InputIterator>
+// iterator insert_after(const_iterator p,
+// InputIterator first, InputIterator last);
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ typedef C::iterator I;
+ typedef input_iterator<const T*> J;
+ C c;
+ const T t[] = {0, 1, 2, 3, 4};
+ I i = c.insert_after(c.cbefore_begin(), J(t), J(t));
+ assert(i == c.before_begin());
+ assert(distance(c.begin(), c.end()) == 0);
+
+ i = c.insert_after(c.cbefore_begin(), J(t), J(t+3));
+ assert(i == next(c.before_begin(), 3));
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+
+ i = c.insert_after(c.begin(), J(t+3), J(t+5));
+ assert(i == next(c.begin(), 2));
+ assert(distance(c.begin(), c.end()) == 5);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 3);
+ assert(*next(c.begin(), 2) == 4);
+ assert(*next(c.begin(), 3) == 1);
+ assert(*next(c.begin(), 4) == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ typedef C::iterator I;
+ typedef input_iterator<const T*> J;
+ C c;
+ const T t[] = {0, 1, 2, 3, 4};
+ I i = c.insert_after(c.cbefore_begin(), J(t), J(t));
+ assert(i == c.before_begin());
+ assert(distance(c.begin(), c.end()) == 0);
+
+ i = c.insert_after(c.cbefore_begin(), J(t), J(t+3));
+ assert(i == next(c.before_begin(), 3));
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+
+ i = c.insert_after(c.begin(), J(t+3), J(t+5));
+ assert(i == next(c.begin(), 2));
+ assert(distance(c.begin(), c.end()) == 5);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 3);
+ assert(*next(c.begin(), 2) == 4);
+ assert(*next(c.begin(), 3) == 1);
+ assert(*next(c.begin(), 4) == 2);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp
new file mode 100644
index 00000000000..4f0be520c30
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator insert_after(const_iterator p, value_type&& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef MoveOnly T;
+ typedef std::forward_list<T> C;
+ typedef C::iterator I;
+ C c;
+ I i = c.insert_after(c.cbefore_begin(), 0);
+ assert(i == c.begin());
+ assert(c.front() == 0);
+ assert(c.front() == 0);
+ assert(distance(c.begin(), c.end()) == 1);
+
+ i = c.insert_after(c.cbegin(), 1);
+ assert(i == next(c.begin()));
+ assert(c.front() == 0);
+ assert(*next(c.begin()) == 1);
+ assert(distance(c.begin(), c.end()) == 2);
+
+ i = c.insert_after(next(c.cbegin()), 2);
+ assert(i == next(c.begin(), 2));
+ assert(c.front() == 0);
+ assert(*next(c.begin()) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(distance(c.begin(), c.end()) == 3);
+
+ i = c.insert_after(c.cbegin(), 3);
+ assert(i == next(c.begin()));
+ assert(c.front() == 0);
+ assert(*next(c.begin(), 1) == 3);
+ assert(*next(c.begin(), 2) == 1);
+ assert(*next(c.begin(), 3) == 2);
+ assert(distance(c.begin(), c.end()) == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef MoveOnly T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ typedef C::iterator I;
+ C c;
+ I i = c.insert_after(c.cbefore_begin(), 0);
+ assert(i == c.begin());
+ assert(c.front() == 0);
+ assert(c.front() == 0);
+ assert(distance(c.begin(), c.end()) == 1);
+
+ i = c.insert_after(c.cbegin(), 1);
+ assert(i == next(c.begin()));
+ assert(c.front() == 0);
+ assert(*next(c.begin()) == 1);
+ assert(distance(c.begin(), c.end()) == 2);
+
+ i = c.insert_after(next(c.cbegin()), 2);
+ assert(i == next(c.begin(), 2));
+ assert(c.front() == 0);
+ assert(*next(c.begin()) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(distance(c.begin(), c.end()) == 3);
+
+ i = c.insert_after(c.cbegin(), 3);
+ assert(i == next(c.begin()));
+ assert(c.front() == 0);
+ assert(*next(c.begin(), 1) == 3);
+ assert(*next(c.begin(), 2) == 1);
+ assert(*next(c.begin(), 3) == 2);
+ assert(distance(c.begin(), c.end()) == 4);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.pass.cpp
new file mode 100644
index 00000000000..b2da2ecd3bb
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// iterator insert_after(const_iterator p, size_type n, const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ typedef C::iterator I;
+ C c;
+ I i = c.insert_after(c.cbefore_begin(), 0, 0);
+ assert(i == c.before_begin());
+ assert(distance(c.begin(), c.end()) == 0);
+
+ i = c.insert_after(c.cbefore_begin(), 3, 3);
+ assert(i == next(c.before_begin(), 3));
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 3);
+ assert(*next(c.begin(), 1) == 3);
+ assert(*next(c.begin(), 2) == 3);
+
+ i = c.insert_after(c.begin(), 2, 2);
+ assert(i == next(c.begin(), 2));
+ assert(distance(c.begin(), c.end()) == 5);
+ assert(*next(c.begin(), 0) == 3);
+ assert(*next(c.begin(), 1) == 2);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 3);
+ assert(*next(c.begin(), 4) == 3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ typedef C::iterator I;
+ C c;
+ I i = c.insert_after(c.cbefore_begin(), 0, 0);
+ assert(i == c.before_begin());
+ assert(distance(c.begin(), c.end()) == 0);
+
+ i = c.insert_after(c.cbefore_begin(), 3, 3);
+ assert(i == next(c.before_begin(), 3));
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 3);
+ assert(*next(c.begin(), 1) == 3);
+ assert(*next(c.begin(), 2) == 3);
+
+ i = c.insert_after(c.begin(), 2, 2);
+ assert(i == next(c.begin(), 2));
+ assert(distance(c.begin(), c.end()) == 5);
+ assert(*next(c.begin(), 0) == 3);
+ assert(*next(c.begin(), 1) == 2);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 3);
+ assert(*next(c.begin(), 4) == 3);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp
new file mode 100644
index 00000000000..276f2c9f8ed
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void pop_front();
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ typedef std::forward_list<T> C;
+ C c;
+ c.push_front(1);
+ c.push_front(3);
+ c.pop_front();
+ assert(distance(c.begin(), c.end()) == 1);
+ assert(c.front() == 1);
+ c.pop_front();
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef MoveOnly T;
+ typedef std::forward_list<T> C;
+ C c;
+ c.push_front(1);
+ c.push_front(3);
+ c.pop_front();
+ assert(distance(c.begin(), c.end()) == 1);
+ assert(c.front() == 1);
+ c.pop_front();
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ c.push_front(1);
+ c.push_front(3);
+ c.pop_front();
+ assert(distance(c.begin(), c.end()) == 1);
+ assert(c.front() == 1);
+ c.pop_front();
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef MoveOnly T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ c.push_front(1);
+ c.push_front(3);
+ c.pop_front();
+ assert(distance(c.begin(), c.end()) == 1);
+ assert(c.front() == 1);
+ c.pop_front();
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp
new file mode 100644
index 00000000000..85958afc1ce
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void push_front(const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C c;
+ c.push_front(1);
+ assert(c.front() == 1);
+ assert(distance(c.begin(), c.end()) == 1);
+ c.push_front(3);
+ assert(c.front() == 3);
+ assert(*next(c.begin()) == 1);
+ assert(distance(c.begin(), c.end()) == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ c.push_front(1);
+ assert(c.front() == 1);
+ assert(distance(c.begin(), c.end()) == 1);
+ c.push_front(3);
+ assert(c.front() == 3);
+ assert(*next(c.begin()) == 1);
+ assert(distance(c.begin(), c.end()) == 2);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.pass.cpp
new file mode 100644
index 00000000000..43c62eb00cb
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_exception_safety.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void push_front(const value_type& x);
+
+#include <forward_list>
+#include <cassert>
+
+// Flag that makes the copy constructor for CMyClass throw an exception
+static bool gCopyConstructorShouldThow = false;
+
+
+class CMyClass {
+ public: CMyClass();
+ public: CMyClass(const CMyClass& iOther);
+ public: ~CMyClass();
+
+ private: int fMagicValue;
+
+ private: static int kStartedConstructionMagicValue;
+ private: static int kFinishedConstructionMagicValue;
+};
+
+// Value for fMagicValue when the constructor has started running, but not yet finished
+int CMyClass::kStartedConstructionMagicValue = 0;
+// Value for fMagicValue when the constructor has finished running
+int CMyClass::kFinishedConstructionMagicValue = 12345;
+
+CMyClass::CMyClass() :
+ fMagicValue(kStartedConstructionMagicValue)
+{
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::CMyClass(const CMyClass& /*iOther*/) :
+ fMagicValue(kStartedConstructionMagicValue)
+{
+ // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
+ if (gCopyConstructorShouldThow) {
+ throw std::exception();
+ }
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::~CMyClass() {
+ // Only instances for which the constructor has finished running should be destructed
+ assert(fMagicValue == kFinishedConstructionMagicValue);
+}
+
+int main()
+{
+ CMyClass instance;
+ std::forward_list<CMyClass> vec;
+
+ vec.push_front(instance);
+
+ gCopyConstructorShouldThow = true;
+ try {
+ vec.push_front(instance);
+ }
+ catch (...) {
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp
new file mode 100644
index 00000000000..53181ec881e
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void push_front(value_type&& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef MoveOnly T;
+ typedef std::forward_list<T> C;
+ C c;
+ c.push_front(1);
+ assert(c.front() == 1);
+ assert(distance(c.begin(), c.end()) == 1);
+ c.push_front(3);
+ assert(c.front() == 3);
+ assert(*next(c.begin()) == 1);
+ assert(distance(c.begin(), c.end()) == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef MoveOnly T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ c.push_front(1);
+ assert(c.front() == 1);
+ assert(distance(c.begin(), c.end()) == 1);
+ c.push_front(3);
+ assert(c.front() == 3);
+ assert(*next(c.begin()) == 1);
+ assert(distance(c.begin(), c.end()) == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp
new file mode 100644
index 00000000000..ef7ef82626d
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void resize(size_type n);
+
+#include <forward_list>
+#include <cassert>
+
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef DefaultOnly T;
+ typedef std::forward_list<T> C;
+ C c;
+ c.resize(0);
+ assert(distance(c.begin(), c.end()) == 0);
+ c.resize(10);
+ assert(distance(c.begin(), c.end()) == 10);
+ c.resize(20);
+ assert(distance(c.begin(), c.end()) == 20);
+ c.resize(5);
+ assert(distance(c.begin(), c.end()) == 5);
+ c.resize(0);
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t[] = {0, 1, 2, 3, 4};
+ C c(std::begin(t), std::end(t));
+
+ c.resize(3);
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+
+ c.resize(6);
+ assert(distance(c.begin(), c.end()) == 6);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 0);
+ assert(*next(c.begin(), 4) == 0);
+ assert(*next(c.begin(), 5) == 0);
+
+ c.resize(6);
+ assert(distance(c.begin(), c.end()) == 6);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 0);
+ assert(*next(c.begin(), 4) == 0);
+ assert(*next(c.begin(), 5) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef DefaultOnly T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ c.resize(0);
+ assert(distance(c.begin(), c.end()) == 0);
+ c.resize(10);
+ assert(distance(c.begin(), c.end()) == 10);
+ c.resize(20);
+ assert(distance(c.begin(), c.end()) == 20);
+ c.resize(5);
+ assert(distance(c.begin(), c.end()) == 5);
+ c.resize(0);
+ assert(distance(c.begin(), c.end()) == 0);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4};
+ C c(std::begin(t), std::end(t));
+
+ c.resize(3);
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+
+ c.resize(6);
+ assert(distance(c.begin(), c.end()) == 6);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 0);
+ assert(*next(c.begin(), 4) == 0);
+ assert(*next(c.begin(), 5) == 0);
+
+ c.resize(6);
+ assert(distance(c.begin(), c.end()) == 6);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 0);
+ assert(*next(c.begin(), 4) == 0);
+ assert(*next(c.begin(), 5) == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp
new file mode 100644
index 00000000000..d4bd6b4e011
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void resize(size_type n, const value_type& v);
+
+#include <forward_list>
+#include <cassert>
+
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t[] = {0, 1, 2, 3, 4};
+ C c(std::begin(t), std::end(t));
+
+ c.resize(3, 10);
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+
+ c.resize(6, 10);
+ assert(distance(c.begin(), c.end()) == 6);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 10);
+ assert(*next(c.begin(), 4) == 10);
+ assert(*next(c.begin(), 5) == 10);
+
+ c.resize(6, 12);
+ assert(distance(c.begin(), c.end()) == 6);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 10);
+ assert(*next(c.begin(), 4) == 10);
+ assert(*next(c.begin(), 5) == 10);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4};
+ C c(std::begin(t), std::end(t));
+
+ c.resize(3, 10);
+ assert(distance(c.begin(), c.end()) == 3);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+
+ c.resize(6, 10);
+ assert(distance(c.begin(), c.end()) == 6);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 10);
+ assert(*next(c.begin(), 4) == 10);
+ assert(*next(c.begin(), 5) == 10);
+
+ c.resize(6, 12);
+ assert(distance(c.begin(), c.end()) == 6);
+ assert(*next(c.begin(), 0) == 0);
+ assert(*next(c.begin(), 1) == 1);
+ assert(*next(c.begin(), 2) == 2);
+ assert(*next(c.begin(), 3) == 10);
+ assert(*next(c.begin(), 4) == 10);
+ assert(*next(c.begin(), 5) == 10);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp
new file mode 100644
index 00000000000..3b6f853c84c
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void merge(forward_list&& x);
+
+#include <forward_list>
+#include <iterator>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {3, 5, 6, 7, 12, 13};
+ const T t2[] = {0, 1, 2, 4, 8, 9, 10, 11, 14, 15};
+ const T t3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.merge(c2);
+ C c3(std::begin(t3), std::end(t3));
+ assert(c1 == c3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {3, 5, 6, 7, 12, 13};
+ const T t2[] = {0, 1, 2, 4, 8, 9, 10, 11, 14, 15};
+ const T t3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.merge(c2);
+ C c3(std::begin(t3), std::end(t3));
+ assert(c1 == c3);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp
new file mode 100644
index 00000000000..7e873bdddd0
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class Compare> void merge(forward_list&& x, Compare comp);
+
+#include <forward_list>
+#include <iterator>
+#include <functional>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {13, 12, 7, 6, 5, 3};
+ const T t2[] = {15, 14, 11, 10, 9, 8, 4, 2, 1, 0};
+ const T t3[] = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.merge(c2, std::greater<T>());
+ C c3(std::begin(t3), std::end(t3));
+ assert(c1 == c3);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {13, 12, 7, 6, 5, 3};
+ const T t2[] = {15, 14, 11, 10, 9, 8, 4, 2, 1, 0};
+ const T t3[] = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.merge(c2, std::greater<T>());
+ C c3(std::begin(t3), std::end(t3));
+ assert(c1 == c3);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp
new file mode 100644
index 00000000000..18d4cae8cc6
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp
@@ -0,0 +1,155 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void remove(const value_type& v);
+
+#include <forward_list>
+#include <iterator>
+#include <cassert>
+
+#include "min_allocator.h"
+
+struct S {
+ S(int i) : i_(new int(i)) {}
+ S(const S &rhs) : i_(new int(*rhs.i_)) {}
+ S& operator = (const S &rhs) { *i_ = *rhs.i_; return *this; }
+ ~S () { delete i_; i_ = NULL; }
+ bool operator == (const S &rhs) const { return *i_ == *rhs.i_; }
+ int get () const { return *i_; }
+ int *i_;
+ };
+
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.remove(0);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {0, 0, 0, 0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2;
+ c1.remove(0);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {5, 5, 5};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.remove(0);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C c1;
+ C c2;
+ c1.remove(0);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {5, 5, 5, 0};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.remove(0);
+ assert(c1 == c2);
+ }
+ { // LWG issue #526
+ typedef int T;
+ typedef std::forward_list<T> C;
+ int t1[] = {1, 2, 1, 3, 5, 8, 11};
+ int t2[] = { 2, 3, 5, 8, 11};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.remove(c1.front());
+ assert(c1 == c2);
+ }
+ {
+ typedef S T;
+ typedef std::forward_list<T> C;
+ int t1[] = {1, 2, 1, 3, 5, 8, 11, 1};
+ int t2[] = { 2, 3, 5, 8, 11 };
+ C c;
+ for(int *ip = std::end(t1); ip != std::begin(t1);)
+ c.push_front(S(*--ip));
+ c.remove(c.front());
+ C::const_iterator it = c.begin();
+ for(int *ip = std::begin(t2); ip != std::end(t2); ++ip, ++it) {
+ assert ( it != c.end());
+ assert ( *ip == it->get());
+ }
+ assert ( it == c.end ());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.remove(0);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {0, 0, 0, 0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2;
+ c1.remove(0);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {5, 5, 5};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.remove(0);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c1;
+ C c2;
+ c1.remove(0);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {5, 5, 5, 0};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.remove(0);
+ assert(c1 == c2);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp
new file mode 100644
index 00000000000..ed408fbd685
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp
@@ -0,0 +1,155 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class Predicate> void remove_if(Predicate pred);
+
+#include <forward_list>
+#include <iterator>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "counting_predicates.hpp"
+
+
+bool g(int i)
+{
+ return i < 3;
+}
+
+int main()
+{
+ {
+ typedef int T;
+ typedef unary_counting_predicate<bool(*)(T), T> Predicate;
+ typedef std::forward_list<T> C;
+ const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ Predicate cp(g);
+ c1.remove_if(std::ref(cp));
+ assert(c1 == c2);
+ assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
+ }
+ {
+ typedef int T;
+ typedef unary_counting_predicate<bool(*)(T), T> Predicate;
+ typedef std::forward_list<T> C;
+ const T t1[] = {0, 0, 0, 0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2;
+ Predicate cp(g);
+ c1.remove_if(std::ref(cp));
+ assert(c1 == c2);
+ assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
+ }
+ {
+ typedef int T;
+ typedef unary_counting_predicate<bool(*)(T), T> Predicate;
+ typedef std::forward_list<T> C;
+ const T t1[] = {5, 5, 5};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ Predicate cp(g);
+ c1.remove_if(std::ref(cp));
+ assert(c1 == c2);
+ assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
+ }
+ {
+ typedef int T;
+ typedef unary_counting_predicate<bool(*)(T), T> Predicate;
+ typedef std::forward_list<T> C;
+ C c1;
+ C c2;
+ Predicate cp(g);
+ c1.remove_if(std::ref(cp));
+ assert(c1 == c2);
+ assert(cp.count() == 0);
+ }
+ {
+ typedef int T;
+ typedef unary_counting_predicate<bool(*)(T), T> Predicate;
+ typedef std::forward_list<T> C;
+ const T t1[] = {5, 5, 5, 0};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ Predicate cp(g);
+ c1.remove_if(std::ref(cp));
+ assert(c1 == c2);
+ assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef unary_counting_predicate<bool(*)(T), T> Predicate;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ Predicate cp(g);
+ c1.remove_if(std::ref(cp));
+ assert(c1 == c2);
+ assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
+ }
+ {
+ typedef int T;
+ typedef unary_counting_predicate<bool(*)(T), T> Predicate;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {0, 0, 0, 0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2;
+ Predicate cp(g);
+ c1.remove_if(std::ref(cp));
+ assert(c1 == c2);
+ assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
+ }
+ {
+ typedef int T;
+ typedef unary_counting_predicate<bool(*)(T), T> Predicate;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {5, 5, 5};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ Predicate cp(g);
+ c1.remove_if(std::ref(cp));
+ assert(c1 == c2);
+ assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
+ }
+ {
+ typedef int T;
+ typedef unary_counting_predicate<bool(*)(T), T> Predicate;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c1;
+ C c2;
+ Predicate cp(g);
+ c1.remove_if(std::ref(cp));
+ assert(c1 == c2);
+ assert(cp.count() == 0);
+ }
+ {
+ typedef int T;
+ typedef unary_counting_predicate<bool(*)(T), T> Predicate;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {5, 5, 5, 0};
+ const T t2[] = {5, 5, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ Predicate cp(g);
+ c1.remove_if(std::ref(cp));
+ assert(c1 == c2);
+ assert(cp.count() == std::distance(std::begin(t1), std::end(t1)));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/reverse.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/reverse.pass.cpp
new file mode 100644
index 00000000000..9bf0d03a885
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/reverse.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void reverse();
+
+#include <forward_list>
+#include <iterator>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(int N)
+{
+ C c;
+ for (int i = 0; i < N; ++i)
+ c.push_front(i);
+ c.reverse();
+ assert(distance(c.begin(), c.end()) == N);
+ typename C::const_iterator j = c.begin();
+ for (int i = 0; i < N; ++i, ++j)
+ assert(*j == i);
+}
+
+int main()
+{
+ for (int i = 0; i < 10; ++i)
+ test<std::forward_list<int> >(i);
+#if __cplusplus >= 201103L
+ for (int i = 0; i < 10; ++i)
+ test<std::forward_list<int, min_allocator<int>> >(i);
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp
new file mode 100644
index 00000000000..06e40c595ec
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/sort.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void sort();
+
+#include <forward_list>
+#include <iterator>
+#include <algorithm>
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(int N)
+{
+ typedef typename C::value_type T;
+ typedef std::vector<T> V;
+ V v;
+ for (int i = 0; i < N; ++i)
+ v.push_back(i);
+ std::random_shuffle(v.begin(), v.end());
+ C c(v.begin(), v.end());
+ c.sort();
+ assert(distance(c.begin(), c.end()) == N);
+ typename C::const_iterator j = c.begin();
+ for (int i = 0; i < N; ++i, ++j)
+ assert(*j == i);
+}
+
+int main()
+{
+ for (int i = 0; i < 40; ++i)
+ test<std::forward_list<int> >(i);
+#if __cplusplus >= 201103L
+ for (int i = 0; i < 40; ++i)
+ test<std::forward_list<int, min_allocator<int>> >(i);
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp
new file mode 100644
index 00000000000..8b6ca39b2aa
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class Compare> void sort(Compare comp);
+
+#include <forward_list>
+#include <iterator>
+#include <algorithm>
+#include <vector>
+#include <functional>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(int N)
+{
+ typedef typename C::value_type T;
+ typedef std::vector<T> V;
+ V v;
+ for (int i = 0; i < N; ++i)
+ v.push_back(i);
+ std::random_shuffle(v.begin(), v.end());
+ C c(v.begin(), v.end());
+ c.sort(std::greater<T>());
+ assert(distance(c.begin(), c.end()) == N);
+ typename C::const_iterator j = c.begin();
+ for (int i = 0; i < N; ++i, ++j)
+ assert(*j == N-1-i);
+}
+
+int main()
+{
+ for (int i = 0; i < 40; ++i)
+ test<std::forward_list<int> >(i);
+#if __cplusplus >= 201103L
+ for (int i = 0; i < 40; ++i)
+ test<std::forward_list<int, min_allocator<int>> >(i);
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp
new file mode 100644
index 00000000000..51da651970c
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void splice_after(const_iterator p, forward_list&& x);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+typedef int T;
+const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7};
+const T t2[] = {10, 11, 12, 13, 14, 15};
+const int size_t1 = std::end(t1) - std::begin(t1);
+const int size_t2 = std::end(t2) - std::begin(t2);
+
+template <class C>
+void
+testd(const C& c, int p, int l)
+{
+ typename C::const_iterator i = c.begin();
+ int n1 = 0;
+ for (; n1 < p; ++n1, ++i)
+ assert(*i == t1[n1]);
+ for (int n2 = 0; n2 < l; ++n2, ++i)
+ assert(*i == t2[n2]);
+ for (; n1 < size_t1; ++n1, ++i)
+ assert(*i == t1[n1]);
+ assert(distance(c.begin(), c.end()) == size_t1 + l);
+}
+
+int main()
+{
+ {
+ // splicing different containers
+ typedef std::forward_list<T> C;
+ for (int l = 0; l <= size_t2; ++l)
+ {
+ for (int p = 0; p <= size_t1; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+ C c2(t2, t2+l);
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2));
+ testd(c1, p, l);
+ }
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ // splicing different containers
+ typedef std::forward_list<T, min_allocator<T>> C;
+ for (int l = 0; l <= size_t2; ++l)
+ {
+ for (int p = 0; p <= size_t1; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+ C c2(t2, t2+l);
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2));
+ testd(c1, p, l);
+ }
+ }
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp
new file mode 100644
index 00000000000..296ffcd6955
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_one.pass.cpp
@@ -0,0 +1,140 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void splice_after(const_iterator p, forward_list&& x, const_iterator i);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+typedef int T;
+const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7};
+const T t2[] = {10, 11, 12};
+const int size_t1 = std::end(t1) - std::begin(t1);
+const int size_t2 = std::end(t2) - std::begin(t2);
+
+template <class C>
+void
+testd(const C& c, int p, int f)
+{
+ typename C::const_iterator i = c.begin();
+ int n1 = 0;
+ for (; n1 < p; ++n1, ++i)
+ assert(*i == t1[n1]);
+ for (int n2 = f; n2 < f+1; ++n2, ++i)
+ assert(*i == t2[n2]);
+ for (; n1 < size_t1; ++n1, ++i)
+ assert(*i == t1[n1]);
+ assert(distance(c.begin(), c.end()) == size_t1 + 1);
+}
+
+template <class C>
+void
+tests(const C& c, int p, int f)
+{
+ typename C::const_iterator i = c.begin();
+ int n = 0;
+ int d = 1;
+ if (p == f || p == f+1)
+ {
+ for (n = 0; n < size_t1; ++n, ++i)
+ assert(*i == t1[n]);
+ }
+ else if (p < f)
+ {
+ for (n = 0; n < p; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = f; n < f+1; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = p; n < f; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = f+1; n < size_t1; ++n, ++i)
+ assert(*i == t1[n]);
+ }
+ else // p > f+1
+ {
+ for (n = 0; n < f; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = f+1; n < p; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = f; n < f+1; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = p; n < size_t1; ++n, ++i)
+ assert(*i == t1[n]);
+ }
+ assert(distance(c.begin(), c.end()) == size_t1);
+}
+
+int main()
+{
+ {
+ // splicing different containers
+ typedef std::forward_list<T> C;
+ for (int f = 0; f <= size_t2-1; ++f)
+ {
+ for (int p = 0; p <= size_t1; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2),
+ next(c2.cbefore_begin(), f));
+ testd(c1, p, f);
+ }
+ }
+
+ // splicing within same container
+ for (int f = 0; f <= size_t1-1; ++f)
+ {
+ for (int p = 0; p <= size_t1; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
+ next(c1.cbefore_begin(), f));
+ tests(c1, p, f);
+ }
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ // splicing different containers
+ typedef std::forward_list<T, min_allocator<T>> C;
+ for (int f = 0; f <= size_t2-1; ++f)
+ {
+ for (int p = 0; p <= size_t1; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2),
+ next(c2.cbefore_begin(), f));
+ testd(c1, p, f);
+ }
+ }
+
+ // splicing within same container
+ for (int f = 0; f <= size_t1-1; ++f)
+ {
+ for (int p = 0; p <= size_t1; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
+ next(c1.cbefore_begin(), f));
+ tests(c1, p, f);
+ }
+ }
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp
new file mode 100644
index 00000000000..90a15995963
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp
@@ -0,0 +1,169 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void splice_after(const_iterator p, forward_list&& x,
+// const_iterator first, const_iterator last);
+
+#include <forward_list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+typedef int T;
+const T t1[] = {0, 1, 2, 3, 4, 5, 6, 7};
+const T t2[] = {10, 11, 12, 13, 14, 15};
+const int size_t1 = std::end(t1) - std::begin(t1);
+const int size_t2 = std::end(t2) - std::begin(t2);
+
+template <class C>
+void
+testd(const C& c, int p, int f, int l)
+{
+ typename C::const_iterator i = c.begin();
+ int n1 = 0;
+ for (; n1 < p; ++n1, ++i)
+ assert(*i == t1[n1]);
+ for (int n2 = f; n2 < l-1; ++n2, ++i)
+ assert(*i == t2[n2]);
+ for (; n1 < size_t1; ++n1, ++i)
+ assert(*i == t1[n1]);
+ assert(distance(c.begin(), c.end()) == size_t1 + (l > f+1 ? l-1-f : 0));
+}
+
+template <class C>
+void
+tests(const C& c, int p, int f, int l)
+{
+ typename C::const_iterator i = c.begin();
+ int n = 0;
+ int d = l > f+1 ? l-1-f : 0;
+ if (d == 0 || p == f)
+ {
+ for (n = 0; n < size_t1; ++n, ++i)
+ assert(*i == t1[n]);
+ }
+ else if (p < f)
+ {
+ for (n = 0; n < p; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = f; n < l-1; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = p; n < f; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = l-1; n < size_t1; ++n, ++i)
+ assert(*i == t1[n]);
+ }
+ else // p > f
+ {
+ for (n = 0; n < f; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = l-1; n < p; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = f; n < l-1; ++n, ++i)
+ assert(*i == t1[n]);
+ for (n = p; n < size_t1; ++n, ++i)
+ assert(*i == t1[n]);
+ }
+ assert(distance(c.begin(), c.end()) == size_t1);
+}
+
+int main()
+{
+ {
+ // splicing different containers
+ typedef std::forward_list<T> C;
+ for (int f = 0; f <= size_t2+1; ++f)
+ {
+ for (int l = f; l <= size_t2+1; ++l)
+ {
+ for (int p = 0; p <= size_t1; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2),
+ next(c2.cbefore_begin(), f), next(c2.cbefore_begin(), l));
+ testd(c1, p, f, l);
+ }
+ }
+ }
+
+ // splicing within same container
+ for (int f = 0; f <= size_t1+1; ++f)
+ {
+ for (int l = f; l <= size_t1; ++l)
+ {
+ for (int p = 0; p <= f; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
+ next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l));
+ tests(c1, p, f, l);
+ }
+ for (int p = l; p <= size_t1; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
+ next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l));
+ tests(c1, p, f, l);
+ }
+ }
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ // splicing different containers
+ typedef std::forward_list<T, min_allocator<T>> C;
+ for (int f = 0; f <= size_t2+1; ++f)
+ {
+ for (int l = f; l <= size_t2+1; ++l)
+ {
+ for (int p = 0; p <= size_t1; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c2),
+ next(c2.cbefore_begin(), f), next(c2.cbefore_begin(), l));
+ testd(c1, p, f, l);
+ }
+ }
+ }
+
+ // splicing within same container
+ for (int f = 0; f <= size_t1+1; ++f)
+ {
+ for (int l = f; l <= size_t1; ++l)
+ {
+ for (int p = 0; p <= f; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
+ next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l));
+ tests(c1, p, f, l);
+ }
+ for (int p = l; p <= size_t1; ++p)
+ {
+ C c1(std::begin(t1), std::end(t1));
+
+ c1.splice_after(next(c1.cbefore_begin(), p), std::move(c1),
+ next(c1.cbefore_begin(), f), next(c1.cbefore_begin(), l));
+ tests(c1, p, f, l);
+ }
+ }
+ }
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp
new file mode 100644
index 00000000000..25db6e64b8a
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/unique.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void unique();
+
+#include <forward_list>
+#include <iterator>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+ const T t2[] = {0, 5, 0, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique();
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {0, 0, 0, 0};
+ const T t2[] = {0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique();
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {5, 5, 5};
+ const T t2[] = {5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique();
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C c1;
+ C c2;
+ c1.unique();
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {5, 5, 5, 0};
+ const T t2[] = {5, 0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique();
+ assert(c1 == c2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+ const T t2[] = {0, 5, 0, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique();
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {0, 0, 0, 0};
+ const T t2[] = {0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique();
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {5, 5, 5};
+ const T t2[] = {5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique();
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c1;
+ C c2;
+ c1.unique();
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {5, 5, 5, 0};
+ const T t2[] = {5, 0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique();
+ assert(c1 == c2);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp
new file mode 100644
index 00000000000..b7dce20b709
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.ops/unique_pred.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class BinaryPredicate> void unique(BinaryPredicate binary_pred);
+
+#include <forward_list>
+#include <iterator>
+#include <cassert>
+
+#include "min_allocator.h"
+
+bool g(int x, int y)
+{
+ return x == y;
+}
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+ const T t2[] = {0, 5, 0, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique(g);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {0, 0, 0, 0};
+ const T t2[] = {0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique(g);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {5, 5, 5};
+ const T t2[] = {5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique(g);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C c1;
+ C c2;
+ c1.unique(g);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ const T t1[] = {5, 5, 5, 0};
+ const T t2[] = {5, 0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique(g);
+ assert(c1 == c2);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {0, 5, 5, 0, 0, 0, 5};
+ const T t2[] = {0, 5, 0, 5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique(g);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {0, 0, 0, 0};
+ const T t2[] = {0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique(g);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {5, 5, 5};
+ const T t2[] = {5};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique(g);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c1;
+ C c2;
+ c1.unique(g);
+ assert(c1 == c2);
+ }
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ const T t1[] = {5, 5, 5, 0};
+ const T t2[] = {5, 0};
+ C c1(std::begin(t1), std::end(t1));
+ C c2(std::begin(t2), std::end(t2));
+ c1.unique(g);
+ assert(c1 == c2);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/equal.pass.cpp
new file mode 100644
index 00000000000..ca673b58368
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/equal.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class T, class Allocator>
+// bool operator==(const forward_list<T, Allocator>& x,
+// const forward_list<T, Allocator>& y);
+//
+// template <class T, class Allocator>
+// bool operator!=(const forward_list<T, Allocator>& x,
+// const forward_list<T, Allocator>& y);
+
+#include <forward_list>
+#include <iterator>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(int N, int M)
+{
+ typedef typename C::value_type T;
+ C c1;
+ for (int i = 0; i < N; ++i)
+ c1.push_front(i);
+ C c2;
+ for (int i = 0; i < M; ++i)
+ c2.push_front(i);
+ if (N == M)
+ assert(c1 == c2);
+ else
+ assert(c1 != c2);
+ c2 = c1;
+ assert(c1 == c2);
+ if (N > 0)
+ {
+ c2.front() = N+1;
+ assert(c1 != c2);
+ }
+}
+
+int main()
+{
+ for (int i = 0; i < 10; ++i)
+ for (int j = 0; j < 10; ++j)
+ test<std::forward_list<int> >(i, j);
+#if __cplusplus >= 201103L
+ for (int i = 0; i < 10; ++i)
+ for (int j = 0; j < 10; ++j)
+ test<std::forward_list<int, min_allocator<int>> >(i, j);
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp
new file mode 100644
index 00000000000..2b2be7b6c22
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp
@@ -0,0 +1,259 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void swap(forward_list& x);
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A(1));
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A(2));
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A(1));
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A(2));
+ }
+ {
+ typedef int T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A(1));
+ C c2(A(2));
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A(1));
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A(2));
+ }
+ {
+ typedef int T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A(1));
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A(2));
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A(1));
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A(2));
+ }
+ {
+ typedef int T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A(1));
+ C c2(A(2));
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A(1));
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A(2));
+ }
+
+ {
+ typedef int T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A(1));
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A(2));
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A(2));
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A(1));
+ }
+ {
+ typedef int T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A(1));
+ C c2(A(2));
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A(2));
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A(1));
+ }
+ {
+ typedef int T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A(1));
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A(2));
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A(2));
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A(1));
+ }
+ {
+ typedef int T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A(1));
+ C c2(A(2));
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A(2));
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A(1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A());
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A());
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A());
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A());
+ }
+ {
+ typedef int T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A());
+ C c2(A{});
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A());
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A());
+ }
+ {
+ typedef int T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A{});
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A());
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A());
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A());
+ }
+ {
+ typedef int T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A{});
+ C c2(A{});
+ c1.swap(c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A());
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp
new file mode 100644
index 00000000000..d6ba5a47cbe
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp
@@ -0,0 +1,260 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class T, class Allocator>
+// void swap(forward_list<T, Allocator>& x, forward_list<T, Allocator>& y);
+
+#include <forward_list>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A(1));
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A(2));
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A(1));
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A(2));
+ }
+ {
+ typedef int T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A(1));
+ C c2(A(2));
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A(1));
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A(2));
+ }
+ {
+ typedef int T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A(1));
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A(2));
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A(1));
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A(2));
+ }
+ {
+ typedef int T;
+ typedef test_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A(1));
+ C c2(A(2));
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A(1));
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A(2));
+ }
+
+ {
+ typedef int T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A(1));
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A(2));
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A(2));
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A(1));
+ }
+ {
+ typedef int T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A(1));
+ C c2(A(2));
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A(2));
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A(1));
+ }
+ {
+ typedef int T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A(1));
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A(2));
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A(2));
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A(1));
+ }
+ {
+ typedef int T;
+ typedef other_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A(1));
+ C c2(A(2));
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A(2));
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A(1));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A());
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A());
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A());
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A());
+ }
+ {
+ typedef int T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ const T t1[] = {0, 1, 2, 3, 4, 5};
+ C c1(std::begin(t1), std::end(t1), A());
+ C c2(A{});
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A());
+
+ assert(distance(c2.begin(), c2.end()) == 6);
+ assert(*next(c2.begin(), 0) == 0);
+ assert(*next(c2.begin(), 1) == 1);
+ assert(*next(c2.begin(), 2) == 2);
+ assert(*next(c2.begin(), 3) == 3);
+ assert(*next(c2.begin(), 4) == 4);
+ assert(*next(c2.begin(), 5) == 5);
+ assert(c2.get_allocator() == A());
+ }
+ {
+ typedef int T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A{});
+ const T t2[] = {10, 11, 12};
+ C c2(std::begin(t2), std::end(t2), A());
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 3);
+ assert(*next(c1.begin(), 0) == 10);
+ assert(*next(c1.begin(), 1) == 11);
+ assert(*next(c1.begin(), 2) == 12);
+ assert(c1.get_allocator() == A());
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A());
+ }
+ {
+ typedef int T;
+ typedef min_allocator<T> A;
+ typedef std::forward_list<T, A> C;
+ C c1(A{});
+ C c2(A{});
+ swap(c1, c2);
+
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c1.get_allocator() == A());
+
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(c2.get_allocator() == A());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp
new file mode 100644
index 00000000000..42e245d007b
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/relational.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class T, class Allocator>
+// bool operator< (const forward_list<T, Allocator>& x,
+// const forward_list<T, Allocator>& y);
+//
+// template <class T, class Allocator>
+// bool operator> (const forward_list<T, Allocator>& x,
+// const forward_list<T, Allocator>& y);
+//
+// template <class T, class Allocator>
+// bool operator>=(const forward_list<T, Allocator>& x,
+// const forward_list<T, Allocator>& y);
+//
+// template <class T, class Allocator>
+// bool operator<=(const forward_list<T, Allocator>& x,
+// const forward_list<T, Allocator>& y);
+
+#include <forward_list>
+#include <iterator>
+#include <algorithm>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(int N, int M)
+{
+ typedef typename C::value_type T;
+ C c1;
+ for (int i = 0; i < N; ++i)
+ c1.push_front(i);
+ C c2;
+ for (int i = 0; i < M; ++i)
+ c2.push_front(i);
+ if (N < M)
+ assert(c1 < c2);
+ if (N <= M)
+ assert(c1 <= c2);
+ if (N >= M)
+ assert(c1 >= c2);
+ if (N > M)
+ assert(c1 > c2);
+}
+
+int main()
+{
+ for (int i = 0; i < 10; ++i)
+ for (int j = 0; j < 10; ++j)
+ test<std::forward_list<int> >(i, j);
+#if __cplusplus >= 201103L
+ for (int i = 0; i < 10; ++i)
+ for (int j = 0; j < 10; ++j)
+ test<std::forward_list<int, min_allocator<int>> >(i, j);
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp
new file mode 100644
index 00000000000..cde97d5f738
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.spec/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// void swap(forward_list& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <forward_list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+
+ some_alloc() {}
+ some_alloc(const some_alloc&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::forward_list<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/max_size.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/max_size.pass.cpp
new file mode 100644
index 00000000000..be7ebaf44b0
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// size_type max_size() const;
+
+#include <forward_list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::forward_list<T> C;
+ C c;
+ assert(c.max_size() > 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::forward_list<T, min_allocator<T>> C;
+ C c;
+ assert(c.max_size() > 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/forwardlist/types.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/types.pass.cpp
new file mode 100644
index 00000000000..c95548710bc
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+// template <class T, class Allocator = allocator<T>>
+// class forward_list
+// {
+// public:
+// typedef T value_type;
+// typedef Allocator allocator_type;
+//
+// typedef value_type& reference;
+// typedef const value_type& const_reference;
+// typedef typename allocator_traits<allocator_type>::pointer pointer;
+// typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
+// typedef typename allocator_traits<allocator_type>::size_type size_type;
+// typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+// ...
+// };
+
+#include <forward_list>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::forward_list<char> C;
+ static_assert((std::is_same<C::value_type, char>::value), "");
+ static_assert((std::is_same<C::allocator_type, std::allocator<char> >::value), "");
+ static_assert((std::is_same<C::reference, char&>::value), "");
+ static_assert((std::is_same<C::const_reference, const char&>::value), "");
+ static_assert((std::is_same<C::pointer, char*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const char*>::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::forward_list<char, min_allocator<char>> C;
+ static_assert((std::is_same<C::value_type, char>::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<char> >::value), "");
+ static_assert((std::is_same<C::reference, char&>::value), "");
+ static_assert((std::is_same<C::const_reference, const char&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<char>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const char>>::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/sequences/forwardlist/version.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/version.pass.cpp
new file mode 100644
index 00000000000..918c8dd5d73
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/forwardlist/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <forward_list>
+
+#include <forward_list>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/sequences/list/db_back.pass.cpp b/libcxx/test/std/containers/sequences/list/db_back.pass.cpp
new file mode 100644
index 00000000000..b16c0e90701
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/db_back.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call back() on empty container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ C c(1);
+ assert(c.back() == 0);
+ c.clear();
+ assert(c.back() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ C c(1);
+ assert(c.back() == 0);
+ c.clear();
+ assert(c.back() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/list/db_cback.pass.cpp b/libcxx/test/std/containers/sequences/list/db_cback.pass.cpp
new file mode 100644
index 00000000000..ba3977e16f4
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/db_cback.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call back() on empty const container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ const C c;
+ assert(c.back() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ const C c;
+ assert(c.back() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/list/db_cfront.pass.cpp b/libcxx/test/std/containers/sequences/list/db_cfront.pass.cpp
new file mode 100644
index 00000000000..d42290c43c0
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/db_cfront.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call front() on empty const container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ const C c;
+ assert(c.front() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ const C c;
+ assert(c.front() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/list/db_front.pass.cpp b/libcxx/test/std/containers/sequences/list/db_front.pass.cpp
new file mode 100644
index 00000000000..037b16035c6
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/db_front.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call front() on empty container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ C c(1);
+ assert(c.front() == 0);
+ c.clear();
+ assert(c.front() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ C c(1);
+ assert(c.front() == 0);
+ c.clear();
+ assert(c.front() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/list/db_iterators_6.pass.cpp b/libcxx/test/std/containers/sequences/list/db_iterators_6.pass.cpp
new file mode 100644
index 00000000000..a5b8020b373
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/db_iterators_6.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Decrement iterator prior to begin.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ C c(1);
+ C::iterator i = c.end();
+ --i;
+ assert(i == c.begin());
+ --i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.end();
+ --i;
+ assert(i == c.begin());
+ --i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/list/db_iterators_7.pass.cpp b/libcxx/test/std/containers/sequences/list/db_iterators_7.pass.cpp
new file mode 100644
index 00000000000..76a491b1184
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/db_iterators_7.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ C c(1);
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/list/db_iterators_8.pass.cpp b/libcxx/test/std/containers/sequences/list/db_iterators_8.pass.cpp
new file mode 100644
index 00000000000..1d1ee23a393
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/db_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ C c(1);
+ C::iterator i = c.end();
+ T j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.end();
+ T j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/list/db_iterators_9.pass.cpp b/libcxx/test/std/containers/sequences/list/db_iterators_9.pass.cpp
new file mode 100644
index 00000000000..d02fcd6e449
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/db_iterators_9.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Operations on "NULL" iterators
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) do { if (!x) throw 1; } while(0)
+
+#include <list>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+struct S { int val; };
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ unsigned lib_asserts;
+
+ typedef S T;
+ typedef std::list<T> C;
+ C::iterator i{};
+ C::const_iterator ci{};
+
+ lib_asserts = 0;
+ try { ++i; } catch (int) { ++lib_asserts; }
+ try { i++; } catch (int) { ++lib_asserts; }
+ try { ++ci; } catch (int) { ++lib_asserts; }
+ try { ci++; } catch (int) { ++lib_asserts; }
+ assert(lib_asserts == 4);
+
+ lib_asserts = 0;
+ try { --i; } catch (int) { ++lib_asserts; }
+ try { i--; } catch (int) { ++lib_asserts; }
+ try { --ci; } catch (int) { ++lib_asserts; }
+ try { ci--; } catch (int) { ++lib_asserts; }
+ assert(lib_asserts == 4);
+
+ lib_asserts = 0;
+ try { *i; } catch (int) { ++lib_asserts; }
+ try { *ci; } catch (int) { ++lib_asserts; }
+ try { (void) i->val; } catch (int) { ++lib_asserts; }
+ try { (void) ci->val; } catch (int) { ++lib_asserts; }
+ assert(lib_asserts == 4);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/list/iterators.pass.cpp b/libcxx/test/std/containers/sequences/list/iterators.pass.cpp
new file mode 100644
index 00000000000..a33ee3ecd2d
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/iterators.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator begin();
+// iterator end();
+// const_iterator begin() const;
+// const_iterator end() const;
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+
+#include <list>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+struct A
+{
+ int first;
+ int second;
+};
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ C c;
+ C::iterator i = c.begin();
+ C::iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ const C c;
+ C::const_iterator i = c.begin();
+ C::const_iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ C c;
+ C::const_iterator i = c.cbegin();
+ C::const_iterator j = c.cend();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ assert(i == c.end());
+ }
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ C::iterator i = c.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 1);
+ *i = 10;
+ assert(*i == 10);
+ assert(std::distance(c.begin(), c.end()) == 10);
+ }
+ {
+ typedef int T;
+ typedef std::list<T> C;
+ C::iterator i;
+ C::const_iterator j;
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ C c;
+ C::iterator i = c.begin();
+ C::iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ const C c;
+ C::const_iterator i = c.begin();
+ C::const_iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ C c;
+ C::const_iterator i = c.cbegin();
+ C::const_iterator j = c.cend();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ assert(i == c.end());
+ }
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ C::iterator i = c.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 1);
+ *i = 10;
+ assert(*i == 10);
+ assert(std::distance(c.begin(), c.end()) == 10);
+ }
+ {
+ typedef int T;
+ typedef std::list<T, min_allocator<T>> C;
+ C::iterator i;
+ C::const_iterator j;
+ }
+ {
+ typedef A T;
+ typedef std::list<T, min_allocator<T>> C;
+ C c = {A{1, 2}};
+ C::iterator i = c.begin();
+ i->first = 3;
+ C::const_iterator j = i;
+ assert(j->first == 3);
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ {
+ std::list<int> c;
+ std::list<int>::iterator ii1{}, ii2{};
+ std::list<int>::iterator ii4 = ii1;
+ std::list<int>::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+
+ assert ( ii1 != c.cbegin());
+ assert ( cii != c.begin());
+ }
+#endif
+
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.capacity/resize_size.pass.cpp b/libcxx/test/std/containers/sequences/list/list.capacity/resize_size.pass.cpp
new file mode 100644
index 00000000000..14629b173a6
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.capacity/resize_size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void resize(size_type sz);
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int> l(5, 2);
+ l.resize(2);
+ assert(l.size() == 2);
+ assert(std::distance(l.begin(), l.end()) == 2);
+ assert(l == std::list<int>(2, 2));
+ }
+ {
+ std::list<int> l(5, 2);
+ l.resize(10);
+ assert(l.size() == 10);
+ assert(std::distance(l.begin(), l.end()) == 10);
+ assert(l.front() == 2);
+ assert(l.back() == 0);
+ }
+#ifdef __LIBCPP_MOVE
+ {
+ std::list<DefaultOnly> l(10);
+ l.resize(5);
+ assert(l.size() == 5);
+ assert(std::distance(l.begin(), l.end()) == 5);
+ }
+ {
+ std::list<DefaultOnly> l(10);
+ l.resize(20);
+ assert(l.size() == 20);
+ assert(std::distance(l.begin(), l.end()) == 20);
+ }
+#endif // __LIBCPP_MOVE
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l(5, 2);
+ l.resize(2);
+ assert(l.size() == 2);
+ assert(std::distance(l.begin(), l.end()) == 2);
+ assert((l == std::list<int, min_allocator<int>>(2, 2)));
+ }
+ {
+ std::list<int, min_allocator<int>> l(5, 2);
+ l.resize(10);
+ assert(l.size() == 10);
+ assert(std::distance(l.begin(), l.end()) == 10);
+ assert(l.front() == 2);
+ assert(l.back() == 0);
+ }
+#ifdef __LIBCPP_MOVE
+ {
+ std::list<DefaultOnly, min_allocator<DefaultOnly>> l(10);
+ l.resize(5);
+ assert(l.size() == 5);
+ assert(std::distance(l.begin(), l.end()) == 5);
+ }
+ {
+ std::list<DefaultOnly, min_allocator<DefaultOnly>> l(10);
+ l.resize(20);
+ assert(l.size() == 20);
+ assert(std::distance(l.begin(), l.end()) == 20);
+ }
+#endif // __LIBCPP_MOVE
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.capacity/resize_size_value.pass.cpp b/libcxx/test/std/containers/sequences/list/list.capacity/resize_size_value.pass.cpp
new file mode 100644
index 00000000000..2738ffbbefd
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.capacity/resize_size_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void resize(size_type sz, const value_type& x);
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<double> l(5, 2);
+ l.resize(2, 3.5);
+ assert(l.size() == 2);
+ assert(std::distance(l.begin(), l.end()) == 2);
+ assert(l == std::list<double>(2, 2));
+ }
+ {
+ std::list<double> l(5, 2);
+ l.resize(10, 3.5);
+ assert(l.size() == 10);
+ assert(std::distance(l.begin(), l.end()) == 10);
+ assert(l.front() == 2);
+ assert(l.back() == 3.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<double, min_allocator<double>> l(5, 2);
+ l.resize(2, 3.5);
+ assert(l.size() == 2);
+ assert(std::distance(l.begin(), l.end()) == 2);
+ assert((l == std::list<double, min_allocator<double>>(2, 2)));
+ }
+ {
+ std::list<double, min_allocator<double>> l(5, 2);
+ l.resize(10, 3.5);
+ assert(l.size() == 10);
+ assert(std::distance(l.begin(), l.end()) == 10);
+ assert(l.front() == 2);
+ assert(l.back() == 3.5);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/assign_copy.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/assign_copy.pass.cpp
new file mode 100644
index 00000000000..b851eb9dc5a
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.cons/assign_copy.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list& operator=(const list& c);
+
+#include <list>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+ std::list<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == test_allocator<int>(3));
+ }
+ {
+ std::list<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+ std::list<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == other_allocator<int>(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+ std::list<int, min_allocator<int> > l2(l, min_allocator<int>());
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == min_allocator<int>());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 00000000000..24bd140c4e4
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.cons/assign_initializer_list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void assign(initializer_list<value_type> il);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::list<int> d;
+ d.assign({3, 4, 5, 6});
+ assert(d.size() == 4);
+ std::list<int>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> d;
+ d.assign({3, 4, 5, 6});
+ assert(d.size() == 4);
+ std::list<int, min_allocator<int>>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp
new file mode 100644
index 00000000000..99f0a98204f
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp
@@ -0,0 +1,82 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list& operator=(list&& c);
+
+#include <list>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(5));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+ {
+ std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(6));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
+ }
+ {
+ std::list<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+ std::list<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, other_allocator<MoveOnly> > l2(other_allocator<MoveOnly>(6));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+ std::list<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, min_allocator<MoveOnly> > l2(min_allocator<MoveOnly>{});
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/copy.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/copy.pass.cpp
new file mode 100644
index 00000000000..530690a925d
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.cons/copy.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(const list& c);
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int> l(3, 2);
+ std::list<int> l2 = l;
+ assert(l2 == l);
+ }
+ {
+ std::list<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+ std::list<int, test_allocator<int> > l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == l.get_allocator());
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ std::list<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+ std::list<int, other_allocator<int> > l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == other_allocator<int>(-2));
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l(3, 2);
+ std::list<int, min_allocator<int>> l2 = l;
+ assert(l2 == l);
+ }
+ {
+ std::list<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+ std::list<int, min_allocator<int> > l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == l.get_allocator());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/copy_alloc.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/copy_alloc.pass.cpp
new file mode 100644
index 00000000000..99fe9f115f9
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.cons/copy_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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(const list& c, const allocator_type& a);
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+ std::list<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+ assert(l2 == l);
+ assert(l2.get_allocator() == test_allocator<int>(3));
+ }
+ {
+ std::list<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+ std::list<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+ assert(l2 == l);
+ assert(l2.get_allocator() == other_allocator<int>(3));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+ std::list<int, min_allocator<int> > l2(l, min_allocator<int>());
+ assert(l2 == l);
+ assert(l2.get_allocator() == min_allocator<int>());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/default.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/default.pass.cpp
new file mode 100644
index 00000000000..c05bd74ca79
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.cons/default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// explicit list(const Alloc& = Alloc());
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int> l;
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<DefaultOnly> l;
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<int> l((std::allocator<int>()));
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l;
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<DefaultOnly, min_allocator<DefaultOnly>> l;
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<int, min_allocator<int>> l((min_allocator<int>()));
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<int> l = {};
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp
new file mode 100644
index 00000000000..f821fb4e7bb
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list()
+// noexcept(is_nothrow_default_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::list<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp
new file mode 100644
index 00000000000..9d9946b6896
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// explicit list(const Alloc& = Alloc());
+
+#include <list>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int> l;
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<int> l((std::allocator<int>()));
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<int, stack_allocator<int, 4> > l;
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l;
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+ {
+ std::list<int, min_allocator<int>> l((min_allocator<int>()));
+ assert(l.size() == 0);
+ assert(std::distance(l.begin(), l.end()) == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 00000000000..13c7e5b5797
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// ~list() // implied noexcept;
+
+#include <list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+ ~some_alloc() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::list<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp
new file mode 100644
index 00000000000..3307017989e
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.cons/initializer_list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(initializer_list<value_type> il);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::list<int> d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ std::list<int>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ std::list<int, min_allocator<int>>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp
new file mode 100644
index 00000000000..4a85e378c1c
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(initializer_list<value_type> il, const Allocator& a = allocator_type());
+
+#include <list>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::list<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3));
+ assert(d.get_allocator() == test_allocator<int>(3));
+ assert(d.size() == 4);
+ std::list<int>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>());
+ assert(d.get_allocator() == min_allocator<int>());
+ assert(d.size() == 4);
+ std::list<int, min_allocator<int>>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
new file mode 100644
index 00000000000..09eae8ab43c
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.cons/input_iterator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class InputIterator>
+// list(InputIterator first, InputIterator last, const Allocator& = Allocator());
+
+#include <list>
+#include <cassert>
+#include "test_iterators.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a[] = {0, 1, 2, 3};
+ std::list<int> l(input_iterator<const int*>(a),
+ input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])));
+ assert(l.size() == sizeof(a)/sizeof(a[0]));
+ assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+ int j = 0;
+ for (std::list<int>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+ assert(*i == j);
+ }
+ {
+ int a[] = {0, 1, 2, 3};
+ std::list<int> l(input_iterator<const int*>(a),
+ input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])),
+ std::allocator<int>());
+ assert(l.size() == sizeof(a)/sizeof(a[0]));
+ assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+ int j = 0;
+ for (std::list<int>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+ assert(*i == j);
+ }
+ {
+ int a[] = {0, 1, 2, 3};
+ std::list<int, stack_allocator<int, sizeof(a)/sizeof(a[0])> > l(input_iterator<const int*>(a),
+ input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])));
+ assert(l.size() == sizeof(a)/sizeof(a[0]));
+ assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+ int j = 0;
+ for (std::list<int>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+ assert(*i == j);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a[] = {0, 1, 2, 3};
+ std::list<int, min_allocator<int>> l(input_iterator<const int*>(a),
+ input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])));
+ assert(l.size() == sizeof(a)/sizeof(a[0]));
+ assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+ int j = 0;
+ for (std::list<int, min_allocator<int>>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+ assert(*i == j);
+ }
+ {
+ int a[] = {0, 1, 2, 3};
+ std::list<int, min_allocator<int>> l(input_iterator<const int*>(a),
+ input_iterator<const int*>(a + sizeof(a)/sizeof(a[0])),
+ min_allocator<int>());
+ assert(l.size() == sizeof(a)/sizeof(a[0]));
+ assert(std::distance(l.begin(), l.end()) == sizeof(a)/sizeof(a[0]));
+ int j = 0;
+ for (std::list<int, min_allocator<int>>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j)
+ assert(*i == j);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/move.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/move.pass.cpp
new file mode 100644
index 00000000000..44782b91075
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.cons/move.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(list&& c);
+
+#include <list>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, test_allocator<MoveOnly> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+ {
+ std::list<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+ std::list<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, other_allocator<MoveOnly> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+ std::list<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, min_allocator<MoveOnly> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int> l1 = {1, 2, 3};
+ std::list<int>::iterator i = l1.begin();
+ std::list<int> l2 = std::move(l1);
+ assert(*l2.erase(i) == 2);
+ assert(l2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp
new file mode 100644
index 00000000000..4730755db81
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(list&& c, const allocator_type& a);
+
+#include <list>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(6));
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
+ }
+ {
+ std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(5));
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == test_allocator<MoveOnly>(5));
+ }
+ {
+ std::list<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+ std::list<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, other_allocator<MoveOnly> > l2(std::move(l), other_allocator<MoveOnly>(4));
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == other_allocator<MoveOnly>(4));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+ std::list<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::list<MoveOnly, min_allocator<MoveOnly> > l2(std::move(l), min_allocator<MoveOnly>());
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == min_allocator<MoveOnly>());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 00000000000..d502e1c09c8
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list& operator=(list&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::list<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp
new file mode 100644
index 00000000000..2c10443f76b
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(list&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::list<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::list<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp
new file mode 100644
index 00000000000..7b7b8a327b8
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list& operator=(initializer_list<value_type> il);
+
+#include <list>
+#include <cassert>
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::list<int> d;
+ d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ std::list<int>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> d;
+ d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ std::list<int, min_allocator<int>>::iterator i = d.begin();
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/size_type.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/size_type.pass.cpp
new file mode 100644
index 00000000000..75b93a3dfb6
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.cons/size_type.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// explicit list(size_type n);
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test3(unsigned n, Allocator const &alloc = Allocator())
+{
+#if _LIBCPP_STD_VER > 11
+ typedef std::list<T, Allocator> C;
+ typedef typename C::const_iterator const_iterator;
+ {
+ C d(n, alloc);
+ assert(d.size() == n);
+ assert(std::distance(d.begin(), d.end()) == n);
+ assert(d.get_allocator() == alloc);
+ }
+#endif
+}
+
+
+int main()
+{
+ {
+ std::list<int> l(3);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int>::const_iterator i = l.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ }
+ {
+ std::list<int, stack_allocator<int, 3> > l(3);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int>::const_iterator i = l.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::list<int, min_allocator<int> > C;
+ C l(3, min_allocator<int> ());
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ C::const_iterator i = l.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ test3<int, min_allocator<int>> (3);
+ }
+#endif
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<DefaultOnly> l(3);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l(3);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int, min_allocator<int>>::const_iterator i = l.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ ++i;
+ assert(*i == 0);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<DefaultOnly, min_allocator<DefaultOnly>> l(3);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp b/libcxx/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp
new file mode 100644
index 00000000000..12da86da0a4
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// list(size_type n, const T& value, const Allocator& = Allocator());
+
+#include <list>
+#include <cassert>
+#include "DefaultOnly.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int> l(3, 2);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int>::const_iterator i = l.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l(3, 2, std::allocator<int>());
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int>::const_iterator i = l.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, stack_allocator<int, 3> > l(3, 2);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int>::const_iterator i = l.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l(3, 2);
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int, min_allocator<int>>::const_iterator i = l.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l(3, 2, min_allocator<int>());
+ assert(l.size() == 3);
+ assert(std::distance(l.begin(), l.end()) == 3);
+ std::list<int, min_allocator<int>>::const_iterator i = l.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/clear.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/clear.pass.cpp
new file mode 100644
index 00000000000..38696b6eb50
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/clear.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void clear();
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a[] = {1, 2, 3};
+ std::list<int> c(a, a+3);
+ c.clear();
+ assert(c.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ int a[] = {1, 2, 3};
+ std::list<int, min_allocator<int>> c(a, a+3);
+ c.clear();
+ assert(c.empty());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/emplace.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/emplace.pass.cpp
new file mode 100644
index 00000000000..6476d1d6c6a
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/emplace.pass.cpp
@@ -0,0 +1,88 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class... Args> void emplace(const_iterator p, Args&&... args);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+class A
+{
+ int i_;
+ double d_;
+
+ A(const A&);
+ A& operator=(const A&);
+public:
+ A(int i, double d)
+ : i_(i), d_(d) {}
+
+ int geti() const {return i_;}
+ double getd() const {return d_;}
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<A> c;
+ c.emplace(c.cbegin(), 2, 3.5);
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ c.emplace(c.cend(), 3, 4.5);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<A> c1;
+ std::list<A> c2;
+ std::list<A>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
+ assert(false);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<A, min_allocator<A>> c;
+ c.emplace(c.cbegin(), 2, 3.5);
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ c.emplace(c.cend(), 3, 4.5);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<A, min_allocator<A>> c1;
+ std::list<A, min_allocator<A>> c2;
+ std::list<A, min_allocator<A>>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
+ assert(false);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp
new file mode 100644
index 00000000000..5983efc59ad
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class... Args> void emplace_back(Args&&... args);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+class A
+{
+ int i_;
+ double d_;
+
+ A(const A&);
+ A& operator=(const A&);
+public:
+ A(int i, double d)
+ : i_(i), d_(d) {}
+
+ int geti() const {return i_;}
+ double getd() const {return d_;}
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<A> c;
+ c.emplace_back(2, 3.5);
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ c.emplace_back(3, 4.5);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<A, min_allocator<A>> c;
+ c.emplace_back(2, 3.5);
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ c.emplace_back(3, 4.5);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp
new file mode 100644
index 00000000000..e2e68e33138
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class... Args> void emplace_front(Args&&... args);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+class A
+{
+ int i_;
+ double d_;
+
+ A(const A&);
+ A& operator=(const A&);
+public:
+ A(int i, double d)
+ : i_(i), d_(d) {}
+
+ int geti() const {return i_;}
+ double getd() const {return d_;}
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<A> c;
+ c.emplace_front(2, 3.5);
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ c.emplace_front(3, 4.5);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 3);
+ assert(c.front().getd() == 4.5);
+ assert(c.back().geti() == 2);
+ assert(c.back().getd() == 3.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<A, min_allocator<A>> c;
+ c.emplace_front(2, 3.5);
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ c.emplace_front(3, 4.5);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 3);
+ assert(c.front().getd() == 4.5);
+ assert(c.back().geti() == 2);
+ assert(c.back().getd() == 3.5);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter.pass.cpp
new file mode 100644
index 00000000000..c1cc9004367
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator erase(const_iterator position);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::const_iterator i = l1.begin();
+ ++i;
+ std::list<int>::iterator j = l1.erase(i);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(*j == 3);
+ assert(*l1.begin() == 1);
+ assert(*next(l1.begin()) == 3);
+ j = l1.erase(j);
+ assert(j == l1.end());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(*l1.begin() == 1);
+ j = l1.erase(l1.begin());
+ assert(j == l1.end());
+ assert(l1.size() == 0);
+ assert(distance(l1.begin(), l1.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ ++i;
+ std::list<int, min_allocator<int>>::iterator j = l1.erase(i);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(*j == 3);
+ assert(*l1.begin() == 1);
+ assert(*next(l1.begin()) == 3);
+ j = l1.erase(j);
+ assert(j == l1.end());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(*l1.begin() == 1);
+ j = l1.erase(l1.begin());
+ assert(j == l1.end());
+ assert(l1.size() == 0);
+ assert(distance(l1.begin(), l1.end()) == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp
new file mode 100644
index 00000000000..18c15eb02c8
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_db1.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp
new file mode 100644
index 00000000000..61ff8409c96
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_db2.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a1, a1+3);
+ std::list<int>::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a1, a1+3);
+ std::list<int, min_allocator<int>>::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp
new file mode 100644
index 00000000000..bd3f66b4116
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+ assert(l1.size() == 3);
+ assert(distance(l1.cbegin(), l1.cend()) == 3);
+ assert(i == l1.begin());
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.cbegin(), l1.cend()) == 2);
+ assert(i == l1.begin());
+ assert(l1 == std::list<int>(a1+1, a1+3));
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+ assert(l1.size() == 1);
+ assert(distance(l1.cbegin(), l1.cend()) == 1);
+ assert(i == l1.begin());
+ assert(l1 == std::list<int>(a1+2, a1+3));
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+ assert(l1.size() == 0);
+ assert(distance(l1.cbegin(), l1.cend()) == 0);
+ assert(i == l1.begin());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+ assert(l1.size() == 3);
+ assert(distance(l1.cbegin(), l1.cend()) == 3);
+ assert(i == l1.begin());
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.cbegin(), l1.cend()) == 2);
+ assert(i == l1.begin());
+ assert((l1 == std::list<int, min_allocator<int>>(a1+1, a1+3)));
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+ assert(l1.size() == 1);
+ assert(distance(l1.cbegin(), l1.cend()) == 1);
+ assert(i == l1.begin());
+ assert((l1 == std::list<int, min_allocator<int>>(a1+2, a1+3)));
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+ assert(l1.size() == 0);
+ assert(distance(l1.cbegin(), l1.cend()) == 0);
+ assert(i == l1.begin());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp
new file mode 100644
index 00000000000..71ad497e7d9
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db1.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a1, a1+3);
+ std::list<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp
new file mode 100644
index 00000000000..db76b4de486
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db2.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a1, a1+3);
+ std::list<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp
new file mode 100644
index 00000000000..25c5c6147a0
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db3.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a1, a1+3);
+ std::list<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp
new file mode 100644
index 00000000000..35a4ceb4848
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <list>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp
new file mode 100644
index 00000000000..a82a2696e82
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator insert(const_iterator p, initializer_list<value_type> il);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::list<int> d(10, 1);
+ std::list<int>::iterator i = d.insert(next(d.cbegin(), 2), {3, 4, 5, 6});
+ assert(d.size() == 14);
+ assert(i == next(d.begin(), 2));
+ i = d.begin();
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> d(10, 1);
+ std::list<int, min_allocator<int>>::iterator i = d.insert(next(d.cbegin(), 2), {3, 4, 5, 6});
+ assert(d.size() == 14);
+ assert(i == next(d.begin(), 2));
+ i = d.begin();
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 3);
+ assert(*i++ == 4);
+ assert(*i++ == 5);
+ assert(*i++ == 6);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ assert(*i++ == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp
new file mode 100644
index 00000000000..d69deac36a9
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp
@@ -0,0 +1,185 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <InputIterator Iter>
+// iterator insert(const_iterator position, Iter first, Iter last);
+
+// UNSUPPORTED: asan, msan
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int throw_next = 0xFFFF;
+int count = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ if (throw_next == 0)
+ throw std::bad_alloc();
+ --throw_next;
+ ++count;
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ --count;
+ std::free(p);
+}
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int> l1;
+ std::list<int>::iterator i = l1.insert(l1.begin(), a1, a1+3);
+ assert(i == l1.begin());
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ int a2[] = {4, 5, 6};
+ i = l1.insert(i, a2, a2+3);
+ assert(*i == 4);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 3);
+ throw_next = 2;
+ int save_count = count;
+ try
+ {
+ i = l1.insert(i, a2, a2+3);
+ assert(false);
+ }
+ catch (...)
+ {
+ }
+ assert(save_count == count);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 3);
+ }
+ throw_next = 0xFFFF;
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int> v(100);
+ std::list<int> v2(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::list<int>::iterator i = v.insert(next(v2.cbegin(), 10), input_iterator<const int*>(a),
+ input_iterator<const int*>(a+N));
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>>::iterator i = l1.insert(l1.begin(), a1, a1+3);
+ assert(i == l1.begin());
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ int a2[] = {4, 5, 6};
+ i = l1.insert(i, a2, a2+3);
+ assert(*i == 4);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 3);
+ throw_next = 2;
+ int save_count = count;
+ try
+ {
+ i = l1.insert(i, a2, a2+3);
+ assert(false);
+ }
+ catch (...)
+ {
+ }
+ assert(save_count == count);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 3);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ throw_next = 0xFFFF;
+ std::list<int, min_allocator<int>> v(100);
+ std::list<int, min_allocator<int>> v2(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::list<int, min_allocator<int>>::iterator i = v.insert(next(v2.cbegin(), 10), input_iterator<const int*>(a),
+ input_iterator<const int*>(a+N));
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp
new file mode 100644
index 00000000000..27d0411fb04
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_rvalue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator insert(const_iterator position, value_type&& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<MoveOnly> l1;
+ l1.insert(l1.cend(), MoveOnly(1));
+ assert(l1.size() == 1);
+ assert(l1.front() == MoveOnly(1));
+ l1.insert(l1.cbegin(), MoveOnly(2));
+ assert(l1.size() == 2);
+ assert(l1.front() == MoveOnly(2));
+ assert(l1.back() == MoveOnly(1));
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int> v1(3);
+ std::list<int> v2(3);
+ v1.insert(v2.begin(), 4);
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<MoveOnly, min_allocator<MoveOnly>> l1;
+ l1.insert(l1.cend(), MoveOnly(1));
+ assert(l1.size() == 1);
+ assert(l1.front() == MoveOnly(1));
+ l1.insert(l1.cbegin(), MoveOnly(2));
+ assert(l1.size() == 2);
+ assert(l1.front() == MoveOnly(2));
+ assert(l1.back() == MoveOnly(1));
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int, min_allocator<int>> v1(3);
+ std::list<int, min_allocator<int>> v2(3);
+ v1.insert(v2.begin(), 4);
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
new file mode 100644
index 00000000000..a552e1f8360
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp
@@ -0,0 +1,106 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator insert(const_iterator position, size_type n, const value_type& x);
+
+// UNSUPPORTED: asan, msan
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int throw_next = 0xFFFF;
+int count = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ if (throw_next == 0)
+ throw std::bad_alloc();
+ --throw_next;
+ ++count;
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ --count;
+ std::free(p);
+}
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ int a2[] = {1, 4, 4, 4, 4, 4, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::iterator i = l1.insert(next(l1.cbegin()), 5, 4);
+ assert(i == next(l1.begin()));
+ assert(l1 == std::list<int>(a2, a2+8));
+ throw_next = 4;
+ int save_count = count;
+ try
+ {
+ i = l1.insert(i, 5, 5);
+ assert(false);
+ }
+ catch (...)
+ {
+ }
+ throw_next = 0xFFFF;
+ assert(save_count == count);
+ assert(l1 == std::list<int>(a2, a2+8));
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int> c1(100);
+ std::list<int> c2;
+ std::list<int>::iterator i = c1.insert(next(c2.cbegin(), 10), 5, 1);
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ int a2[] = {1, 4, 4, 4, 4, 4, 2, 3};
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>>::iterator i = l1.insert(next(l1.cbegin()), 5, 4);
+ assert(i == next(l1.begin()));
+ assert((l1 == std::list<int, min_allocator<int>>(a2, a2+8)));
+ throw_next = 4;
+ int save_count = count;
+ try
+ {
+ i = l1.insert(i, 5, 5);
+ assert(false);
+ }
+ catch (...)
+ {
+ }
+ throw_next = 0xFFFF;
+ assert(save_count == count);
+ assert((l1 == std::list<int, min_allocator<int>>(a2, a2+8)));
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int, min_allocator<int>> c1(100);
+ std::list<int, min_allocator<int>> c2;
+ std::list<int, min_allocator<int>>::iterator i = c1.insert(next(c2.cbegin(), 10), 5, 1);
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp
new file mode 100644
index 00000000000..093ad423cf8
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/insert_iter_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// iterator insert(const_iterator position, const value_type& x);
+
+// UNSUPPORTED: asan, msan
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cstdlib>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int throw_next = 0xFFFF;
+int count = 0;
+
+void* operator new(std::size_t s) throw(std::bad_alloc)
+{
+ if (throw_next == 0)
+ throw std::bad_alloc();
+ --throw_next;
+ ++count;
+ return std::malloc(s);
+}
+
+void operator delete(void* p) throw()
+{
+ --count;
+ std::free(p);
+}
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ int a2[] = {1, 4, 2, 3};
+ std::list<int> l1(a1, a1+3);
+ std::list<int>::iterator i = l1.insert(next(l1.cbegin()), 4);
+ assert(i == next(l1.begin()));
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l1 == std::list<int>(a2, a2+4));
+ throw_next = 0;
+ int save_count = count;
+ try
+ {
+ i = l1.insert(i, 5);
+ assert(false);
+ }
+ catch (...)
+ {
+ }
+ throw_next = 0xFFFF;
+ assert(save_count == count);
+ assert(l1 == std::list<int>(a2, a2+4));
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int> v1(3);
+ std::list<int> v2(3);
+ int i = 4;
+ v1.insert(v2.begin(), i);
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ int a2[] = {1, 4, 2, 3};
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>>::iterator i = l1.insert(next(l1.cbegin()), 4);
+ assert(i == next(l1.begin()));
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert((l1 == std::list<int, min_allocator<int>>(a2, a2+4)));
+ throw_next = 0;
+ int save_count = count;
+ try
+ {
+ i = l1.insert(i, 5);
+ assert(false);
+ }
+ catch (...)
+ {
+ }
+ throw_next = 0xFFFF;
+ assert(save_count == count);
+ assert((l1 == std::list<int, min_allocator<int>>(a2, a2+4)));
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int, min_allocator<int>> v1(3);
+ std::list<int, min_allocator<int>> v2(3);
+ int i = 4;
+ v1.insert(v2.begin(), i);
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/pop_back.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/pop_back.pass.cpp
new file mode 100644
index 00000000000..3add8518809
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/pop_back.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void pop_back();
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a[] = {1, 2, 3};
+ std::list<int> c(a, a+3);
+ c.pop_back();
+ assert(c == std::list<int>(a, a+2));
+ c.pop_back();
+ assert(c == std::list<int>(a, a+1));
+ c.pop_back();
+ assert(c.empty());
+#if _LIBCPP_DEBUG >= 1
+ c.pop_back();
+ assert(false);
+#endif
+ }
+#if __cplusplus >= 201103L
+ {
+ int a[] = {1, 2, 3};
+ std::list<int, min_allocator<int>> c(a, a+3);
+ c.pop_back();
+ assert((c == std::list<int, min_allocator<int>>(a, a+2)));
+ c.pop_back();
+ assert((c == std::list<int, min_allocator<int>>(a, a+1)));
+ c.pop_back();
+ assert(c.empty());
+#if _LIBCPP_DEBUG >= 1
+ c.pop_back();
+ assert(false);
+#endif
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/pop_front.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/pop_front.pass.cpp
new file mode 100644
index 00000000000..aec17cc08f4
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/pop_front.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void pop_front();
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a[] = {1, 2, 3};
+ std::list<int> c(a, a+3);
+ c.pop_front();
+ assert(c == std::list<int>(a+1, a+3));
+ c.pop_front();
+ assert(c == std::list<int>(a+2, a+3));
+ c.pop_front();
+ assert(c.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ int a[] = {1, 2, 3};
+ std::list<int, min_allocator<int>> c(a, a+3);
+ c.pop_front();
+ assert((c == std::list<int, min_allocator<int>>(a+1, a+3)));
+ c.pop_front();
+ assert((c == std::list<int, min_allocator<int>>(a+2, a+3)));
+ c.pop_front();
+ assert(c.empty());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/push_back.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/push_back.pass.cpp
new file mode 100644
index 00000000000..2638c541fa1
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/push_back.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void push_back(const value_type& x);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int> c;
+ for (int i = 0; i < 5; ++i)
+ c.push_back(i);
+ int a[] = {0, 1, 2, 3, 4};
+ assert(c == std::list<int>(a, a+5));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> c;
+ for (int i = 0; i < 5; ++i)
+ c.push_back(i);
+ int a[] = {0, 1, 2, 3, 4};
+ assert((c == std::list<int, min_allocator<int>>(a, a+5)));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/push_back_exception_safety.pass.cpp
new file mode 100644
index 00000000000..9d3c05e26b1
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/push_back_exception_safety.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void push_back(const value_type& x);
+
+#include <list>
+#include <cassert>
+
+// Flag that makes the copy constructor for CMyClass throw an exception
+static bool gCopyConstructorShouldThow = false;
+
+
+class CMyClass {
+ public: CMyClass();
+ public: CMyClass(const CMyClass& iOther);
+ public: ~CMyClass();
+
+ private: int fMagicValue;
+
+ private: static int kStartedConstructionMagicValue;
+ private: static int kFinishedConstructionMagicValue;
+};
+
+// Value for fMagicValue when the constructor has started running, but not yet finished
+int CMyClass::kStartedConstructionMagicValue = 0;
+// Value for fMagicValue when the constructor has finished running
+int CMyClass::kFinishedConstructionMagicValue = 12345;
+
+CMyClass::CMyClass() :
+ fMagicValue(kStartedConstructionMagicValue)
+{
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::CMyClass(const CMyClass& /*iOther*/) :
+ fMagicValue(kStartedConstructionMagicValue)
+{
+ // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
+ if (gCopyConstructorShouldThow) {
+ throw std::exception();
+ }
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::~CMyClass() {
+ // Only instances for which the constructor has finished running should be destructed
+ assert(fMagicValue == kFinishedConstructionMagicValue);
+}
+
+int main()
+{
+ CMyClass instance;
+ std::list<CMyClass> vec;
+
+ vec.push_back(instance);
+
+ gCopyConstructorShouldThow = true;
+ try {
+ vec.push_back(instance);
+ }
+ catch (...) {
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp
new file mode 100644
index 00000000000..070db9e8d6b
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void push_back(value_type&& x);
+
+#include <list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<MoveOnly> l1;
+ l1.push_back(MoveOnly(1));
+ assert(l1.size() == 1);
+ assert(l1.front() == MoveOnly(1));
+ l1.push_back(MoveOnly(2));
+ assert(l1.size() == 2);
+ assert(l1.front() == MoveOnly(1));
+ assert(l1.back() == MoveOnly(2));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<MoveOnly, min_allocator<MoveOnly>> l1;
+ l1.push_back(MoveOnly(1));
+ assert(l1.size() == 1);
+ assert(l1.front() == MoveOnly(1));
+ l1.push_back(MoveOnly(2));
+ assert(l1.size() == 2);
+ assert(l1.front() == MoveOnly(1));
+ assert(l1.back() == MoveOnly(2));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/push_front.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/push_front.pass.cpp
new file mode 100644
index 00000000000..b7f4febcd38
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/push_front.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void push_front(const value_type& x);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::list<int> c;
+ for (int i = 0; i < 5; ++i)
+ c.push_front(i);
+ int a[] = {4, 3, 2, 1, 0};
+ assert(c == std::list<int>(a, a+5));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> c;
+ for (int i = 0; i < 5; ++i)
+ c.push_front(i);
+ int a[] = {4, 3, 2, 1, 0};
+ assert((c == std::list<int, min_allocator<int>>(a, a+5)));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/push_front_exception_safety.pass.cpp
new file mode 100644
index 00000000000..6609005262e
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/push_front_exception_safety.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void push_front(const value_type& x);
+
+#include <list>
+#include <cassert>
+
+// Flag that makes the copy constructor for CMyClass throw an exception
+static bool gCopyConstructorShouldThow = false;
+
+
+class CMyClass {
+ public: CMyClass();
+ public: CMyClass(const CMyClass& iOther);
+ public: ~CMyClass();
+
+ private: int fMagicValue;
+
+ private: static int kStartedConstructionMagicValue;
+ private: static int kFinishedConstructionMagicValue;
+};
+
+// Value for fMagicValue when the constructor has started running, but not yet finished
+int CMyClass::kStartedConstructionMagicValue = 0;
+// Value for fMagicValue when the constructor has finished running
+int CMyClass::kFinishedConstructionMagicValue = 12345;
+
+CMyClass::CMyClass() :
+ fMagicValue(kStartedConstructionMagicValue)
+{
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::CMyClass(const CMyClass& /*iOther*/) :
+ fMagicValue(kStartedConstructionMagicValue)
+{
+ // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
+ if (gCopyConstructorShouldThow) {
+ throw std::exception();
+ }
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::~CMyClass() {
+ // Only instances for which the constructor has finished running should be destructed
+ assert(fMagicValue == kFinishedConstructionMagicValue);
+}
+
+int main()
+{
+ CMyClass instance;
+ std::list<CMyClass> vec;
+
+ vec.push_front(instance);
+
+ gCopyConstructorShouldThow = true;
+ try {
+ vec.push_front(instance);
+ }
+ catch (...) {
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp b/libcxx/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp
new file mode 100644
index 00000000000..8a3175504eb
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void push_front(value_type&& x);
+
+#include <list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::list<MoveOnly> l1;
+ l1.push_front(MoveOnly(1));
+ assert(l1.size() == 1);
+ assert(l1.front() == MoveOnly(1));
+ l1.push_front(MoveOnly(2));
+ assert(l1.size() == 2);
+ assert(l1.front() == MoveOnly(2));
+ assert(l1.back() == MoveOnly(1));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::list<MoveOnly, min_allocator<MoveOnly>> l1;
+ l1.push_front(MoveOnly(1));
+ assert(l1.size() == 1);
+ assert(l1.front() == MoveOnly(1));
+ l1.push_front(MoveOnly(2));
+ assert(l1.size() == 2);
+ assert(l1.front() == MoveOnly(2));
+ assert(l1.back() == MoveOnly(1));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/merge.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/merge.pass.cpp
new file mode 100644
index 00000000000..d226ed5dc64
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.ops/merge.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void merge(list& x);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ int a3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+ std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ c1.merge(c2);
+ assert(c1 == std::list<int>(a3, a3+sizeof(a3)/sizeof(a3[0])));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ int a3[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+ std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ c1.merge(c2);
+ assert((c1 == std::list<int, min_allocator<int>>(a3, a3+sizeof(a3)/sizeof(a3[0]))));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/merge_comp.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/merge_comp.pass.cpp
new file mode 100644
index 00000000000..ce861a5dcb8
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.ops/merge_comp.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class Compare> void merge(list& x, Compare comp);
+
+#include <list>
+#include <functional>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {10, 9, 7, 3, 1};
+ int a2[] = {11, 8, 6, 5, 4, 2, 0};
+ int a3[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+ std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ c1.merge(c2, std::greater<int>());
+ assert(c1 == std::list<int>(a3, a3+sizeof(a3)/sizeof(a3[0])));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {10, 9, 7, 3, 1};
+ int a2[] = {11, 8, 6, 5, 4, 2, 0};
+ int a3[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+ std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ c1.merge(c2, std::greater<int>());
+ assert((c1 == std::list<int, min_allocator<int>>(a3, a3+sizeof(a3)/sizeof(a3[0]))));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/remove.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/remove.pass.cpp
new file mode 100644
index 00000000000..f580c94ef48
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.ops/remove.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void remove(const value_type& value);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+struct S {
+ S(int i) : i_(new int(i)) {}
+ S(const S &rhs) : i_(new int(*rhs.i_)) {}
+ S& operator = (const S &rhs) { *i_ = *rhs.i_; return *this; }
+ ~S () { delete i_; i_ = NULL; }
+ bool operator == (const S &rhs) const { return *i_ == *rhs.i_; }
+ int get () const { return *i_; }
+ int *i_;
+ };
+
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3, 4};
+ int a2[] = {1, 2, 4};
+ std::list<int> c(a1, a1+4);
+ c.remove(3);
+ assert(c == std::list<int>(a2, a2+3));
+ }
+ { // LWG issue #526
+ int a1[] = {1, 2, 1, 3, 5, 8, 11};
+ int a2[] = { 2, 3, 5, 8, 11};
+ std::list<int> c(a1, a1+7);
+ c.remove(c.front());
+ assert(c == std::list<int>(a2, a2+5));
+ }
+ {
+ int a1[] = {1, 2, 1, 3, 5, 8, 11, 1};
+ int a2[] = { 2, 3, 5, 8, 11 };
+ std::list<S> c;
+ for(int *ip = a1; ip < a1+8; ++ip)
+ c.push_back(S(*ip));
+ c.remove(c.front());
+ std::list<S>::const_iterator it = c.begin();
+ for(int *ip = a2; ip < a2+5; ++ip, ++it) {
+ assert ( it != c.end());
+ assert ( *ip == it->get());
+ }
+ assert ( it == c.end ());
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3, 4};
+ int a2[] = {1, 2, 4};
+ std::list<int, min_allocator<int>> c(a1, a1+4);
+ c.remove(3);
+ assert((c == std::list<int, min_allocator<int>>(a2, a2+3)));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/remove_if.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/remove_if.pass.cpp
new file mode 100644
index 00000000000..162919ed85d
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.ops/remove_if.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class Pred> void remove_if(Pred pred);
+
+#include <list>
+#include <cassert>
+#include <functional>
+
+#include "min_allocator.h"
+#include "counting_predicates.hpp"
+
+bool even(int i)
+{
+ return i % 2 == 0;
+}
+
+bool g(int i)
+{
+ return i < 3;
+}
+
+typedef unary_counting_predicate<bool(*)(int), int> Predicate;
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3, 4};
+ int a2[] = {3, 4};
+ std::list<int> c(a1, a1+4);
+ Predicate cp(g);
+ c.remove_if(std::ref(cp));
+ assert(c == std::list<int>(a2, a2+2));
+ assert(cp.count() == 4);
+ }
+ {
+ int a1[] = {1, 2, 3, 4};
+ int a2[] = {1, 3};
+ std::list<int> c(a1, a1+4);
+ Predicate cp(even);
+ c.remove_if(std::ref(cp));
+ assert(c == std::list<int>(a2, a2+2));
+ assert(cp.count() == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3, 4};
+ int a2[] = {3, 4};
+ std::list<int, min_allocator<int>> c(a1, a1+4);
+ Predicate cp(g);
+ c.remove_if(std::ref(cp));
+ assert((c == std::list<int, min_allocator<int>>(a2, a2+2)));
+ assert(cp.count() == 4);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/reverse.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/reverse.pass.cpp
new file mode 100644
index 00000000000..046453ae538
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.ops/reverse.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void reverse();
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+ int a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+ std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c1.reverse();
+ assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+ int a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+ std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c1.reverse();
+ assert((c1 == std::list<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/sort.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/sort.pass.cpp
new file mode 100644
index 00000000000..1c11227237a
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.ops/sort.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void sort();
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
+ int a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+ std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c1.sort();
+ assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
+ int a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
+ std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c1.sort();
+ assert((c1 == std::list<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/sort_comp.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/sort_comp.pass.cpp
new file mode 100644
index 00000000000..28125ab83c0
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.ops/sort_comp.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class Compare> sort(Compare comp);
+
+#include <list>
+#include <functional>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
+ int a2[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+ std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c1.sort(std::greater<int>());
+ assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9};
+ int a2[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0};
+ std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c1.sort(std::greater<int>());
+ assert((c1 == std::list<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list.pass.cpp
new file mode 100644
index 00000000000..354871c20af
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list.pass.cpp
@@ -0,0 +1,803 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void splice(const_iterator position, list& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ int a2[] = {4, 5, 6};
+ {
+ std::list<int> l1;
+ std::list<int> l2;
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 0);
+ assert(distance(l1.begin(), l1.end()) == 0);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+1);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+2);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2;
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2;
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+1);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+1);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+2);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+2);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2;
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2;
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2;
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2(a2, a2+1);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2(a2, a2+1);
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2(a2, a2+1);
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2(a2, a2+2);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2(a2, a2+2);
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ std::list<int> l2(a2, a2+2);
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(next(l1.begin(), 3), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int> v1(3);
+ std::list<int> v2(3);
+ v1.splice(v2.begin(), v2);
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2;
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 0);
+ assert(distance(l1.begin(), l1.end()) == 0);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2;
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2;
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.end(), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2;
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2;
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2;
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 4);
+ assert(distance(l1.begin(), l1.end()) == 4);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.begin(), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(next(l1.begin()), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(next(l1.begin(), 2), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(next(l1.begin(), 3), l2);
+ assert(l1.size() == 6);
+ assert(distance(l1.begin(), l1.end()) == 6);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int, min_allocator<int>> v1(3);
+ std::list<int, min_allocator<int>> v2(3);
+ v1.splice(v2.begin(), v2);
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp
new file mode 100644
index 00000000000..5082c3f8517
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp
@@ -0,0 +1,357 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void splice(const_iterator position, list<T,Allocator>& x, iterator i);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ int a2[] = {4, 5, 6};
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+1);
+ l1.splice(l1.end(), l2, l2.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+2);
+ l1.splice(l1.end(), l2, l2.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 1);
+ assert(distance(l2.begin(), l2.end()) == 1);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ i = l2.begin();
+ assert(*i == 5);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+2);
+ l1.splice(l1.end(), l2, next(l2.begin()));
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 1);
+ assert(distance(l2.begin(), l2.end()) == 1);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 5);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, l2.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 2);
+ assert(distance(l2.begin(), l2.end()) == 2);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ i = l2.begin();
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, next(l2.begin()));
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 2);
+ assert(distance(l2.begin(), l2.end()) == 2);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 5);
+ i = l2.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int> l1;
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, next(l2.begin(), 2));
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 2);
+ assert(distance(l2.begin(), l2.end()) == 2);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 6);
+ i = l2.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ l1.splice(l1.begin(), l1, l1.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+1);
+ l1.splice(l1.begin(), l2, l2.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+1);
+ std::list<int> l2(a2, a2+1);
+ l1.splice(next(l1.begin()), l2, l2.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ l1.splice(l1.begin(), l1, l1.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ l1.splice(l1.begin(), l1, next(l1.begin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ l1.splice(next(l1.begin()), l1, l1.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int> l1(a1, a1+2);
+ l1.splice(next(l1.begin()), l1, next(l1.begin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int> v1(3);
+ std::list<int> v2(3);
+ v1.splice(v1.begin(), v2, v1.begin());
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(l1.end(), l2, l2.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(l1.end(), l2, l2.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 1);
+ assert(distance(l2.begin(), l2.end()) == 1);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ i = l2.begin();
+ assert(*i == 5);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+2);
+ l1.splice(l1.end(), l2, next(l2.begin()));
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 1);
+ assert(distance(l2.begin(), l2.end()) == 1);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 5);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, l2.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 2);
+ assert(distance(l2.begin(), l2.end()) == 2);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ i = l2.begin();
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, next(l2.begin()));
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 2);
+ assert(distance(l2.begin(), l2.end()) == 2);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 5);
+ i = l2.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 6);
+ }
+ {
+ std::list<int, min_allocator<int>> l1;
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, next(l2.begin(), 2));
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(l2.size() == 2);
+ assert(distance(l2.begin(), l2.end()) == 2);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 6);
+ i = l2.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 5);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ l1.splice(l1.begin(), l1, l1.begin());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(l1.begin(), l2, l2.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+1);
+ std::list<int, min_allocator<int>> l2(a2, a2+1);
+ l1.splice(next(l1.begin()), l2, l2.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(l2.size() == 0);
+ assert(distance(l2.begin(), l2.end()) == 0);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ l1.splice(l1.begin(), l1, l1.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ l1.splice(l1.begin(), l1, next(l1.begin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ l1.splice(next(l1.begin()), l1, l1.begin());
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+2);
+ l1.splice(next(l1.begin()), l1, next(l1.begin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int, min_allocator<int>> v1(3);
+ std::list<int, min_allocator<int>> v2(3);
+ v1.splice(v1.begin(), v2, v1.begin());
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp
new file mode 100644
index 00000000000..fcc4acceec5
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.ops/splice_pos_list_iter_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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void splice(const_iterator position, list& x, iterator first, iterator last);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ int a2[] = {4, 5, 6};
+ {
+ std::list<int> l1(a1, a1+3);
+ l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin()));
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin(), 2));
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin(), 3));
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.begin(), l2, next(l2.begin()), l2.end());
+ assert(l1.size() == 5);
+ assert(distance(l1.begin(), l1.end()) == 5);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ assert(l2.size() == 1);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(next(l1.begin()), l2, next(l2.begin()), l2.end());
+ assert(l1.size() == 5);
+ assert(distance(l1.begin(), l1.end()) == 5);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ assert(l2.size() == 1);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int> l1(a1, a1+3);
+ std::list<int> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, next(l2.begin()), l2.end());
+ assert(l1.size() == 5);
+ assert(distance(l1.begin(), l1.end()) == 5);
+ std::list<int>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ assert(l2.size() == 1);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int> v1(3);
+ std::list<int> v2(3);
+ v1.splice(v1.begin(), v2, v2.begin(), v1.end());
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin()));
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin(), 2));
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 3);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin(), 3));
+ assert(l1.size() == 3);
+ assert(distance(l1.begin(), l1.end()) == 3);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 1);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.begin(), l2, next(l2.begin()), l2.end());
+ assert(l1.size() == 5);
+ assert(distance(l1.begin(), l1.end()) == 5);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ assert(l2.size() == 1);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(next(l1.begin()), l2, next(l2.begin()), l2.end());
+ assert(l1.size() == 5);
+ assert(distance(l1.begin(), l1.end()) == 5);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ assert(l2.size() == 1);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+ {
+ std::list<int, min_allocator<int>> l1(a1, a1+3);
+ std::list<int, min_allocator<int>> l2(a2, a2+3);
+ l1.splice(l1.end(), l2, next(l2.begin()), l2.end());
+ assert(l1.size() == 5);
+ assert(distance(l1.begin(), l1.end()) == 5);
+ std::list<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 5);
+ ++i;
+ assert(*i == 6);
+ assert(l2.size() == 1);
+ i = l2.begin();
+ assert(*i == 4);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::list<int, min_allocator<int>> v1(3);
+ std::list<int, min_allocator<int>> v2(3);
+ v1.splice(v1.begin(), v2, v2.begin(), v1.end());
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/unique.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/unique.pass.cpp
new file mode 100644
index 00000000000..48cad1ddd15
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.ops/unique.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void unique();
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
+ int a2[] = {2, 1, 4, 3};
+ std::list<int> c(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c.unique();
+ assert(c == std::list<int>(a2, a2+4));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
+ int a2[] = {2, 1, 4, 3};
+ std::list<int, min_allocator<int>> c(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c.unique();
+ assert((c == std::list<int, min_allocator<int>>(a2, a2+4)));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp b/libcxx/test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp
new file mode 100644
index 00000000000..f8935b81f6a
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.ops/unique_pred.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class BinaryPred> void unique(BinaryPred pred);
+
+#include <list>
+#include <cassert>
+
+#include "min_allocator.h"
+
+bool g(int x, int y)
+{
+ return x == y;
+}
+
+int main()
+{
+ {
+ int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
+ int a2[] = {2, 1, 4, 3};
+ std::list<int> c(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c.unique(g);
+ assert(c == std::list<int>(a2, a2+4));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3};
+ int a2[] = {2, 1, 4, 3};
+ std::list<int, min_allocator<int>> c(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ c.unique(g);
+ assert((c == std::list<int, min_allocator<int>>(a2, a2+4)));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.special/db_swap_1.pass.cpp b/libcxx/test/std/containers/sequences/list/list.special/db_swap_1.pass.cpp
new file mode 100644
index 00000000000..f7171795cd5
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.special/db_swap_1.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class T, class Alloc>
+// void swap(list<T,Alloc>& x, list<T,Alloc>& y);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <list>
+#include <cassert>
+
+#include <__debug>
+#include "min_allocator.h"
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::list<int>::iterator i1 = c1.begin();
+ std::list<int>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ c2.erase(i1);
+ std::list<int>::iterator j = i1;
+ c1.erase(i1);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::list<int, min_allocator<int>>::iterator i1 = c1.begin();
+ std::list<int, min_allocator<int>>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ c2.erase(i1);
+ std::list<int, min_allocator<int>>::iterator j = i1;
+ c1.erase(i1);
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.special/swap.pass.cpp b/libcxx/test/std/containers/sequences/list/list.special/swap.pass.cpp
new file mode 100644
index 00000000000..bc5f4857edc
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.special/swap.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class T, class Alloc>
+// void swap(list<T,Alloc>& x, list<T,Alloc>& y);
+
+#include <list>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ swap(c1, c2);
+ assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+ assert(c2 == std::list<int>(a1, a1+sizeof(a1)/sizeof(a1[0])));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int> c1(a1, a1);
+ std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ swap(c1, c2);
+ assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int> c2(a2, a2);
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c2 == std::list<int>(a1, a1+sizeof(a1)/sizeof(a1[0])));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int> c1(a1, a1);
+ std::list<int> c2(a2, a2);
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ }
+#ifndef _LIBCPP_DEBUG_LEVEL
+// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef test_allocator<int> A;
+ std::list<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+ std::list<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+ swap(c1, c2);
+ assert((c1 == std::list<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A(1));
+ assert((c2 == std::list<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A(2));
+ }
+#endif
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef other_allocator<int> A;
+ std::list<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+ std::list<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+ swap(c1, c2);
+ assert((c1 == std::list<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A(2));
+ assert((c2 == std::list<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A(1));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ swap(c1, c2);
+ assert((c1 == std::list<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert((c2 == std::list<int, min_allocator<int>>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int, min_allocator<int>> c1(a1, a1);
+ std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ swap(c1, c2);
+ assert((c1 == std::list<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::list<int, min_allocator<int>> c2(a2, a2);
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert((c2 == std::list<int, min_allocator<int>>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::list<int, min_allocator<int>> c1(a1, a1);
+ std::list<int, min_allocator<int>> c2(a2, a2);
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ }
+#ifndef _LIBCPP_DEBUG_LEVEL
+// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef min_allocator<int> A;
+ std::list<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A());
+ std::list<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A());
+ swap(c1, c2);
+ assert((c1 == std::list<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A());
+ assert((c2 == std::list<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A());
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp
new file mode 100644
index 00000000000..7a23398e80a
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// void swap(list& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <list>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+
+ some_alloc() {}
+ some_alloc(const some_alloc&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::list<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::list<MoveOnly, test_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::list<MoveOnly, other_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::list<MoveOnly, some_alloc<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/types.pass.cpp b/libcxx/test/std/containers/sequences/list/types.pass.cpp
new file mode 100644
index 00000000000..95d7f5010f0
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/types.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+// template <class T, class Alloc = allocator<T> >
+// class list
+// {
+// public:
+//
+// // types:
+// typedef T value_type;
+// typedef Alloc 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;
+
+#include <list>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ static_assert((std::is_same<std::list<int>::value_type, int>::value), "");
+ static_assert((std::is_same<std::list<int>::allocator_type, std::allocator<int> >::value), "");
+ static_assert((std::is_same<std::list<int>::reference, std::allocator<int>::reference>::value), "");
+ static_assert((std::is_same<std::list<int>::const_reference, std::allocator<int>::const_reference>::value), "");
+ static_assert((std::is_same<std::list<int>::pointer, std::allocator<int>::pointer>::value), "");
+ static_assert((std::is_same<std::list<int>::const_pointer, std::allocator<int>::const_pointer>::value), "");
+#if __cplusplus >= 201103L
+ static_assert((std::is_same<std::list<int, min_allocator<int>>::value_type, int>::value), "");
+ static_assert((std::is_same<std::list<int, min_allocator<int>>::allocator_type, min_allocator<int> >::value), "");
+ static_assert((std::is_same<std::list<int, min_allocator<int>>::reference, int&>::value), "");
+ static_assert((std::is_same<std::list<int, min_allocator<int>>::const_reference, const int&>::value), "");
+ static_assert((std::is_same<std::list<int, min_allocator<int>>::pointer, min_pointer<int>>::value), "");
+ static_assert((std::is_same<std::list<int, min_allocator<int>>::const_pointer, min_pointer<const int>>::value), "");
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/list/version.pass.cpp b/libcxx/test/std/containers/sequences/list/version.pass.cpp
new file mode 100644
index 00000000000..097c013f52c
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/list/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <list>
+
+#include <list>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/sequences/nothing_to_do.pass.cpp b/libcxx/test/std/containers/sequences/nothing_to_do.pass.cpp
new file mode 100644
index 00000000000..b58f5c55b64
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/nothing_to_do.pass.cpp
@@ -0,0 +1,12 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp
new file mode 100644
index 00000000000..9501799ae3d
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(const vector& c);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool, test_allocator<bool> > l(3, 2, test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > l2(l, test_allocator<bool>(3));
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == test_allocator<bool>(3));
+ }
+ {
+ std::vector<bool, other_allocator<bool> > l(3, 2, other_allocator<bool>(5));
+ std::vector<bool, other_allocator<bool> > l2(l, other_allocator<bool>(3));
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == other_allocator<bool>(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool> > l(3, 2, min_allocator<bool>());
+ std::vector<bool, min_allocator<bool> > l2(l, min_allocator<bool>());
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == min_allocator<bool>());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp
new file mode 100644
index 00000000000..2925fbc6674
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/assign_initializer_list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void assign(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<bool> d;
+ d.assign({true, false, false, true});
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> d;
+ d.assign({true, false, false, true});
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/assign_move.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/assign_move.pass.cpp
new file mode 100644
index 00000000000..df98c817fd5
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/assign_move.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(vector&& c);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, test_allocator<bool> > l2(test_allocator<bool>(5));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+ {
+ std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, test_allocator<bool> > l2(test_allocator<bool>(6));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == test_allocator<bool>(6));
+ }
+ {
+ std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5));
+ std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, other_allocator<bool> > l2(other_allocator<bool>(6));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
+ std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, min_allocator<bool> > l2(min_allocator<bool>{});
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/capacity.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/capacity.pass.cpp
new file mode 100644
index 00000000000..63bff25f9f9
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/capacity.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// size_type capacity() const;
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v;
+ assert(v.capacity() == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ assert(v.capacity() >= 100);
+ v.push_back(0);
+ assert(v.capacity() >= 101);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v;
+ assert(v.capacity() == 0);
+ }
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ assert(v.capacity() >= 100);
+ v.push_back(0);
+ assert(v.capacity() >= 101);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/construct_default.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/construct_default.pass.cpp
new file mode 100644
index 00000000000..d3d6670bbf2
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/construct_default.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// vector(const Alloc& = Alloc());
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void
+test0()
+{
+ C c;
+ assert(c.__invariants());
+ assert(c.empty());
+ assert(c.get_allocator() == typename C::allocator_type());
+#if __cplusplus >= 201103L
+ C c1 = {};
+ assert(c1.__invariants());
+ assert(c1.empty());
+ assert(c1.get_allocator() == typename C::allocator_type());
+#endif
+}
+
+template <class C>
+void
+test1(const typename C::allocator_type& a)
+{
+ C c(a);
+ assert(c.__invariants());
+ assert(c.empty());
+ assert(c.get_allocator() == a);
+}
+
+int main()
+{
+ {
+ test0<std::vector<bool> >();
+ test1<std::vector<bool, test_allocator<bool> > >(test_allocator<bool>(3));
+ }
+#if __cplusplus >= 201103L
+ {
+ test0<std::vector<bool, min_allocator<bool>> >();
+ test1<std::vector<bool, min_allocator<bool> > >(min_allocator<bool>());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp
new file mode 100644
index 00000000000..94e6801825d
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// template <class InputIter> vector(InputIter first, InputIter last);
+
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C, class Iterator>
+void
+test(Iterator first, Iterator last)
+{
+ C c(first, last);
+ assert(c.__invariants());
+ assert(c.size() == std::distance(first, last));
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
+ assert(*i == *first);
+}
+
+int main()
+{
+ bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
+ bool* an = a + sizeof(a)/sizeof(a[0]);
+ test<std::vector<bool> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an));
+ test<std::vector<bool> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an));
+ test<std::vector<bool> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an));
+ test<std::vector<bool> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an));
+ test<std::vector<bool> >(a, an);
+#if __cplusplus >= 201103L
+ test<std::vector<bool, min_allocator<bool>> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an));
+ test<std::vector<bool, min_allocator<bool>> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an));
+ test<std::vector<bool, min_allocator<bool>> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an));
+ test<std::vector<bool, min_allocator<bool>> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an));
+ test<std::vector<bool, min_allocator<bool>> >(a, an);
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp
new file mode 100644
index 00000000000..ea9d41d342f
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// template <class InputIter> vector(InputIter first, InputIter last,
+// const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+template <class C, class Iterator>
+void
+test(Iterator first, Iterator last, const typename C::allocator_type& a)
+{
+ C c(first, last, a);
+ assert(c.__invariants());
+ assert(c.size() == std::distance(first, last));
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
+ assert(*i == *first);
+}
+
+int main()
+{
+ bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
+ bool* an = a + sizeof(a)/sizeof(a[0]);
+ {
+ std::allocator<bool> alloc;
+ test<std::vector<bool> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an), alloc);
+ test<std::vector<bool> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an), alloc);
+ test<std::vector<bool> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an), alloc);
+ test<std::vector<bool> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an), alloc);
+ test<std::vector<bool> >(a, an, alloc);
+ }
+#if __cplusplus >= 201103L
+ {
+ min_allocator<bool> alloc;
+ test<std::vector<bool, min_allocator<bool>> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an), alloc);
+ test<std::vector<bool, min_allocator<bool>> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an), alloc);
+ test<std::vector<bool, min_allocator<bool>> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an), alloc);
+ test<std::vector<bool, min_allocator<bool>> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an), alloc);
+ test<std::vector<bool, min_allocator<bool>> >(a, an, alloc);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/construct_size.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/construct_size.pass.cpp
new file mode 100644
index 00000000000..93ecbe87c38
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/construct_size.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// explicit vector(size_type n);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "test_allocator.h"
+
+template <class C>
+void
+test2(typename C::size_type n, typename C::allocator_type const& a = typename C::allocator_type ())
+{
+#if _LIBCPP_STD_VER > 11
+ C c(n, a);
+ assert(c.__invariants());
+ assert(c.size() == n);
+ assert(c.get_allocator() == a);
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+ assert(*i == typename C::value_type());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
+
+template <class C>
+void
+test1(typename C::size_type n)
+{
+ C c(n);
+ assert(c.__invariants());
+ assert(c.size() == n);
+ assert(c.get_allocator() == typename C::allocator_type());
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+ assert(*i == typename C::value_type());
+}
+
+template <class C>
+void
+test(typename C::size_type n)
+{
+ test1<C> ( n );
+ test2<C> ( n );
+}
+
+int main()
+{
+ test<std::vector<bool> >(50);
+#if __cplusplus >= 201103L
+ test<std::vector<bool, min_allocator<bool>> >(50);
+ test2<std::vector<bool, test_allocator<bool>> >( 100, test_allocator<bool>(23));
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp
new file mode 100644
index 00000000000..fc772f10dfc
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp
@@ -0,0 +1,37 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// vector(size_type n, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void
+test(typename C::size_type n, const typename C::value_type& x)
+{
+ C c(n, x);
+ assert(c.__invariants());
+ assert(c.size() == n);
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+ assert(*i == x);
+}
+
+int main()
+{
+ test<std::vector<bool> >(50, 3);
+#if __cplusplus >= 201103L
+ test<std::vector<bool, min_allocator<bool>> >(50, 3);
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp
new file mode 100644
index 00000000000..6cca948ed83
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// vector(size_type n, const value_type& x, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void
+test(typename C::size_type n, const typename C::value_type& x,
+ const typename C::allocator_type& a)
+{
+ C c(n, x, a);
+ assert(c.__invariants());
+ assert(a == c.get_allocator());
+ assert(c.size() == n);
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+ assert(*i == x);
+}
+
+int main()
+{
+ test<std::vector<bool> >(50, 3, std::allocator<bool>());
+#if __cplusplus >= 201103L
+ test<std::vector<bool, min_allocator<bool>> >(50, 3, min_allocator<bool>());
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/copy.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/copy.pass.cpp
new file mode 100644
index 00000000000..58822782ff8
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/copy.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// vector(const vector& v);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void
+test(const C& x)
+{
+ unsigned s = x.size();
+ C c(x);
+ assert(c.__invariants());
+ assert(c.size() == s);
+ assert(c == x);
+}
+
+int main()
+{
+ {
+ bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
+ bool* an = a + sizeof(a)/sizeof(a[0]);
+ test(std::vector<bool>(a, an));
+ }
+ {
+ std::vector<bool, test_allocator<bool> > v(3, 2, test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > v2 = v;
+ assert(v2 == v);
+ assert(v2.get_allocator() == v.get_allocator());
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ std::vector<bool, other_allocator<bool> > v(3, 2, other_allocator<bool>(5));
+ std::vector<bool, other_allocator<bool> > v2 = v;
+ assert(v2 == v);
+ assert(v2.get_allocator() == other_allocator<bool>(-2));
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
+ bool* an = a + sizeof(a)/sizeof(a[0]);
+ test(std::vector<bool, min_allocator<bool>>(a, an));
+ }
+ {
+ std::vector<bool, min_allocator<bool> > v(3, 2, min_allocator<bool>());
+ std::vector<bool, min_allocator<bool> > v2 = v;
+ assert(v2 == v);
+ assert(v2.get_allocator() == v.get_allocator());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp
new file mode 100644
index 00000000000..2f0192b995a
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(const vector& v, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+template <class C>
+void
+test(const C& x, const typename C::allocator_type& a)
+{
+ unsigned s = x.size();
+ C c(x, a);
+ assert(c.__invariants());
+ assert(c.size() == s);
+ assert(c == x);
+}
+
+int main()
+{
+ {
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ test(std::vector<bool>(a, an), std::allocator<bool>());
+ }
+ {
+ std::vector<bool, test_allocator<bool> > l(3, 2, test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > l2(l, test_allocator<bool>(3));
+ assert(l2 == l);
+ assert(l2.get_allocator() == test_allocator<bool>(3));
+ }
+ {
+ std::vector<bool, other_allocator<bool> > l(3, 2, other_allocator<bool>(5));
+ std::vector<bool, other_allocator<bool> > l2(l, other_allocator<bool>(3));
+ assert(l2 == l);
+ assert(l2.get_allocator() == other_allocator<bool>(3));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ test(std::vector<bool, min_allocator<bool>>(a, an), min_allocator<bool>());
+ }
+ {
+ std::vector<bool, min_allocator<bool> > l(3, 2, min_allocator<bool>());
+ std::vector<bool, min_allocator<bool> > l2(l, min_allocator<bool>());
+ assert(l2 == l);
+ assert(l2.get_allocator() == min_allocator<bool>());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp
new file mode 100644
index 00000000000..b94588ead93
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector<bool>()
+// noexcept(is_nothrow_default_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::vector<bool> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, test_allocator<bool>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, other_allocator<bool>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, some_alloc<bool>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp
new file mode 100644
index 00000000000..682e74ef03c
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// ~vector<bool>() // implied noexcept;
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+ ~some_alloc() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::vector<bool> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, test_allocator<bool>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, other_allocator<bool>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, some_alloc<bool>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/emplace.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/emplace.pass.cpp
new file mode 100644
index 00000000000..f3fd1e9926f
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/emplace.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// template <class... Args> iterator emplace(const_iterator pos, Args&&... args);
+
+#include <vector>
+#include <cassert>
+#include "min_allocator.h"
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::vector<bool> C;
+ C c;
+
+ C::iterator i = c.emplace(c.cbegin());
+ assert(i == c.begin());
+ assert(c.size() == 1);
+ assert(c.front() == false);
+
+ i = c.emplace(c.cend(), true);
+ assert(i == c.end()-1);
+ assert(c.size() == 2);
+ assert(c.front() == false);
+ assert(c.back() == true);
+
+ i = c.emplace(c.cbegin()+1, 1 == 1);
+ assert(i == c.begin()+1);
+ assert(c.size() == 3);
+ assert(c.front() == false);
+ assert(c[1] == true);
+ assert(c.back() == true);
+ }
+ {
+ typedef std::vector<bool, min_allocator<bool>> C;
+ C c;
+
+ C::iterator i = c.emplace(c.cbegin());
+ assert(i == c.begin());
+ assert(c.size() == 1);
+ assert(c.front() == false);
+
+ i = c.emplace(c.cend(), true);
+ assert(i == c.end()-1);
+ assert(c.size() == 2);
+ assert(c.front() == false);
+ assert(c.back() == true);
+
+ i = c.emplace(c.cbegin()+1, 1 == 1);
+ assert(i == c.begin()+1);
+ assert(c.size() == 3);
+ assert(c.size() == 3);
+ assert(c.front() == false);
+ assert(c[1] == true);
+ assert(c.back() == true);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp
new file mode 100644
index 00000000000..57aa47822f8
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/emplace_back.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector.bool
+
+// template <class... Args> void emplace_back(Args&&... args);
+
+#include <vector>
+#include <cassert>
+#include "min_allocator.h"
+
+
+int main()
+{
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::vector<bool> C;
+ C c;
+ c.emplace_back();
+ assert(c.size() == 1);
+ assert(c.front() == false);
+ c.emplace_back(true);
+ assert(c.size() == 2);
+ assert(c.front() == false);
+ assert(c.back() == true);
+ c.emplace_back(1 == 1);
+ assert(c.size() == 3);
+ assert(c.front() == false);
+ assert(c[1] == true);
+ assert(c.back() == true);
+ }
+ {
+ typedef std::vector<bool, min_allocator<bool>> C;
+ C c;
+
+ c.emplace_back();
+ assert(c.size() == 1);
+ assert(c.front() == false);
+ c.emplace_back(true);
+ assert(c.size() == 2);
+ assert(c.front() == false);
+ assert(c.back() == true);
+ c.emplace_back(1 == 1);
+ assert(c.size() == 3);
+ assert(c.front() == false);
+ assert(c[1] == true);
+ assert(c.back() == true);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp
new file mode 100644
index 00000000000..cbf26dd570a
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// iterator erase(const_iterator position);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ bool a1[] = {1, 0, 1};
+ {
+ std::vector<bool> l1(a1, a1+3);
+ std::vector<bool>::const_iterator i = l1.begin();
+ ++i;
+ std::vector<bool>::iterator j = l1.erase(i);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(*j == true);
+ assert(*l1.begin() == 1);
+ assert(*next(l1.begin()) == true);
+ j = l1.erase(j);
+ assert(j == l1.end());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(*l1.begin() == true);
+ j = l1.erase(l1.begin());
+ assert(j == l1.end());
+ assert(l1.size() == 0);
+ assert(distance(l1.begin(), l1.end()) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
+ std::vector<bool, min_allocator<bool>>::const_iterator i = l1.begin();
+ ++i;
+ std::vector<bool, min_allocator<bool>>::iterator j = l1.erase(i);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(*j == true);
+ assert(*l1.begin() == 1);
+ assert(*next(l1.begin()) == true);
+ j = l1.erase(j);
+ assert(j == l1.end());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(*l1.begin() == true);
+ j = l1.erase(l1.begin());
+ assert(j == l1.end());
+ assert(l1.size() == 0);
+ assert(distance(l1.begin(), l1.end()) == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp
new file mode 100644
index 00000000000..2c2c4cc4861
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/erase_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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ bool a1[] = {1, 0, 1};
+ {
+ std::vector<bool> l1(a1, a1+3);
+ std::vector<bool>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+ assert(l1.size() == 3);
+ assert(distance(l1.cbegin(), l1.cend()) == 3);
+ assert(i == l1.begin());
+ }
+ {
+ std::vector<bool> l1(a1, a1+3);
+ std::vector<bool>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.cbegin(), l1.cend()) == 2);
+ assert(i == l1.begin());
+ assert(l1 == std::vector<bool>(a1+1, a1+3));
+ }
+ {
+ std::vector<bool> l1(a1, a1+3);
+ std::vector<bool>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+ assert(l1.size() == 1);
+ assert(distance(l1.cbegin(), l1.cend()) == 1);
+ assert(i == l1.begin());
+ assert(l1 == std::vector<bool>(a1+2, a1+3));
+ }
+ {
+ std::vector<bool> l1(a1, a1+3);
+ std::vector<bool>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+ assert(l1.size() == 0);
+ assert(distance(l1.cbegin(), l1.cend()) == 0);
+ assert(i == l1.begin());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
+ std::vector<bool, min_allocator<bool>>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+ assert(l1.size() == 3);
+ assert(distance(l1.cbegin(), l1.cend()) == 3);
+ assert(i == l1.begin());
+ }
+ {
+ std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
+ std::vector<bool, min_allocator<bool>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.cbegin(), l1.cend()) == 2);
+ assert(i == l1.begin());
+ assert((l1 == std::vector<bool, min_allocator<bool>>(a1+1, a1+3)));
+ }
+ {
+ std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
+ std::vector<bool, min_allocator<bool>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+ assert(l1.size() == 1);
+ assert(distance(l1.cbegin(), l1.cend()) == 1);
+ assert(i == l1.begin());
+ assert((l1 == std::vector<bool, min_allocator<bool>>(a1+2, a1+3)));
+ }
+ {
+ std::vector<bool, min_allocator<bool>> l1(a1, a1+3);
+ std::vector<bool, min_allocator<bool>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+ assert(l1.size() == 0);
+ assert(distance(l1.cbegin(), l1.cend()) == 0);
+ assert(i == l1.begin());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/find.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/find.pass.cpp
new file mode 100644
index 00000000000..75567a9b7bb
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/find.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// std::find with vector<bool>::iterator
+
+// http://llvm.org/bugs/show_bug.cgi?id=16816
+
+#include <vector>
+#include <cassert>
+
+int main()
+{
+ {
+ for (unsigned i = 1; i < 256; ++i)
+ {
+ std::vector<bool> b(i,true);
+ std::vector<bool>::iterator j = std::find(b.begin()+1, b.end(), false);
+ assert(j-b.begin() == i);
+ assert(b.end() == j);
+ }
+ }
+ {
+ for (unsigned i = 1; i < 256; ++i)
+ {
+ std::vector<bool> b(i,false);
+ std::vector<bool>::iterator j = std::find(b.begin()+1, b.end(), true);
+ assert(j-b.begin() == i);
+ assert(b.end() == j);
+ }
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp
new file mode 100644
index 00000000000..b9b46865449
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/initializer_list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<bool> d = {true, false, false, true};
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> d = {true, false, false, true};
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp
new file mode 100644
index 00000000000..aea3ad763cd
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(initializer_list<value_type> il, const Allocator& a = allocator_type());
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<bool, test_allocator<bool>> d({true, false, false, true}, test_allocator<bool>(3));
+ assert(d.get_allocator() == test_allocator<bool>(3));
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> d({true, false, false, true}, min_allocator<bool>());
+ assert(d.get_allocator() == min_allocator<bool>());
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp
new file mode 100644
index 00000000000..c081cc81c59
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator insert(const_iterator p, initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<bool> d(10, true);
+ std::vector<bool>::iterator i = d.insert(d.cbegin() + 2, {false, true, true, false});
+ assert(d.size() == 14);
+ assert(i == d.begin() + 2);
+ assert(d[0] == true);
+ assert(d[1] == true);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ assert(d[4] == true);
+ assert(d[5] == false);
+ assert(d[6] == true);
+ assert(d[7] == true);
+ assert(d[8] == true);
+ assert(d[9] == true);
+ assert(d[10] == true);
+ assert(d[11] == true);
+ assert(d[12] == true);
+ assert(d[13] == true);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> d(10, true);
+ std::vector<bool, min_allocator<bool>>::iterator i = d.insert(d.cbegin() + 2, {false, true, true, false});
+ assert(d.size() == 14);
+ assert(i == d.begin() + 2);
+ assert(d[0] == true);
+ assert(d[1] == true);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ assert(d[4] == true);
+ assert(d[5] == false);
+ assert(d[6] == true);
+ assert(d[7] == true);
+ assert(d[8] == true);
+ assert(d[9] == true);
+ assert(d[10] == true);
+ assert(d[11] == true);
+ assert(d[12] == true);
+ assert(d[13] == true);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp
new file mode 100644
index 00000000000..e51f8b589c7
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp
@@ -0,0 +1,126 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// template <class Iter>
+// iterator insert(const_iterator position, Iter first, Iter last);
+
+#include <vector>
+#include <cassert>
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v(100);
+ bool a[] = {1, 0, 0, 1, 1};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const bool*>(a),
+ input_iterator<const bool*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ bool a[] = {1, 0, 0, 1, 1};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
+ forward_iterator<const bool*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ while(v.size() < v.capacity()) v.push_back(false);
+ size_t sz = v.size();
+ bool a[] = {1, 0, 0, 1, 1};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
+ forward_iterator<const bool*>(a+N));
+ assert(v.size() == sz + N);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ while(v.size() < v.capacity()) v.push_back(false);
+ v.pop_back(); v.pop_back(); v.pop_back();
+ size_t sz = v.size();
+ bool a[] = {1, 0, 0, 1, 1};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
+ forward_iterator<const bool*>(a+N));
+ assert(v.size() == sz + N);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ bool a[] = {1, 0, 0, 1, 1};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const bool*>(a),
+ input_iterator<const bool*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ bool a[] = {1, 0, 0, 1, 1};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const bool*>(a),
+ forward_iterator<const bool*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp
new file mode 100644
index 00000000000..710ad4885f0
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_size_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// iterator insert(const_iterator position, size_type n, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v(100);
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == 105);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ while(v.size() < v.capacity()) v.push_back(false);
+ size_t sz = v.size();
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == sz + 5);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ while(v.size() < v.capacity()) v.push_back(false);
+ v.pop_back(); v.pop_back();
+ size_t sz = v.size();
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == sz + 5);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == 105);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp
new file mode 100644
index 00000000000..51c4626de0d
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/insert_iter_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// iterator insert(const_iterator position, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v(100);
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == 101);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ while(v.size() < v.capacity()) v.push_back(false);
+ size_t sz = v.size();
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == sz + 1);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<bool> v(100);
+ while(v.size() < v.capacity()) v.push_back(false);
+ v.pop_back(); v.pop_back();
+ size_t sz = v.size();
+ std::vector<bool>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == sz + 1);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == 101);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/iterators.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/iterators.pass.cpp
new file mode 100644
index 00000000000..c54fa4a80a9
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/iterators.pass.cpp
@@ -0,0 +1,123 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator begin();
+// iterator end();
+// const_iterator begin() const;
+// const_iterator end() const;
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef bool T;
+ typedef std::vector<T> C;
+ C c;
+ C::iterator i = c.begin();
+ C::iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef bool T;
+ typedef std::vector<T> C;
+ const C c;
+ C::const_iterator i = c.begin();
+ C::const_iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef bool T;
+ typedef std::vector<T> C;
+ C c;
+ C::const_iterator i = c.cbegin();
+ C::const_iterator j = c.cend();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ assert(i == c.end());
+ }
+ {
+ typedef bool T;
+ typedef std::vector<T> C;
+ C::iterator i;
+ C::const_iterator j;
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef bool T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c;
+ C::iterator i = c.begin();
+ C::iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef bool T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const C c;
+ C::const_iterator i = c.begin();
+ C::const_iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef bool T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c;
+ C::const_iterator i = c.cbegin();
+ C::const_iterator j = c.cend();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ assert(i == c.end());
+ }
+ {
+ typedef bool T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C::iterator i;
+ C::const_iterator j;
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ std::vector<bool>::iterator ii1{}, ii2{};
+ std::vector<bool>::iterator ii4 = ii1;
+ std::vector<bool>::const_iterator cii{};
+ assert ( ii1 == ii2 );
+ assert ( ii1 == ii4 );
+
+ assert (!(ii1 != ii2 ));
+
+ assert ( (ii1 == cii ));
+ assert ( (cii == ii1 ));
+ assert (!(ii1 != cii ));
+ assert (!(cii != ii1 ));
+ assert (!(ii1 < cii ));
+ assert (!(cii < ii1 ));
+ assert ( (ii1 <= cii ));
+ assert ( (cii <= ii1 ));
+ assert (!(ii1 > cii ));
+ assert (!(cii > ii1 ));
+ assert ( (ii1 >= cii ));
+ assert ( (cii >= ii1 ));
+ assert (cii - ii1 == 0);
+ assert (ii1 - cii == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/move.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/move.pass.cpp
new file mode 100644
index 00000000000..e877292ced7
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/move.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&& c);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, test_allocator<bool> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+ {
+ std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5));
+ std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, other_allocator<bool> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
+ std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, min_allocator<bool> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp
new file mode 100644
index 00000000000..deee9326197
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/move_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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&& c, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, test_allocator<bool> > l2(std::move(l), test_allocator<bool>(6));
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == test_allocator<bool>(6));
+ }
+ {
+ std::vector<bool, test_allocator<bool> > l(test_allocator<bool>(5));
+ std::vector<bool, test_allocator<bool> > lo(test_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, test_allocator<bool> > l2(std::move(l), test_allocator<bool>(5));
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == test_allocator<bool>(5));
+ }
+ {
+ std::vector<bool, other_allocator<bool> > l(other_allocator<bool>(5));
+ std::vector<bool, other_allocator<bool> > lo(other_allocator<bool>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, other_allocator<bool> > l2(std::move(l), other_allocator<bool>(4));
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == other_allocator<bool>(4));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{});
+ std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{});
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ std::vector<bool, min_allocator<bool> > l2(std::move(l), min_allocator<bool>());
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == min_allocator<bool>());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp
new file mode 100644
index 00000000000..b580eb4ae3b
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/move_assign_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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(vector&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::vector<bool> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, test_allocator<bool>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, other_allocator<bool>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, some_alloc<bool>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp
new file mode 100644
index 00000000000..ab32bd0677b
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::vector<bool> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, test_allocator<bool>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, other_allocator<bool>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<bool, some_alloc<bool>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp
new file mode 100644
index 00000000000..ef3dc5d1079
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/op_equal_initializer_list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<bool> d;
+ d = {true, false, false, true};
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> d;
+ d = {true, false, false, true};
+ assert(d.size() == 4);
+ assert(d[0] == true);
+ assert(d[1] == false);
+ assert(d[2] == false);
+ assert(d[3] == true);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/push_back.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/push_back.pass.cpp
new file mode 100644
index 00000000000..c6b0fbf4185
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/push_back.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void push_back(const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ bool a[] = {0, 1, 1, 0, 1, 0, 0};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool> c;
+ for (unsigned i = 0; i < N; ++i)
+ {
+ c.push_back(a[i]);
+ assert(c.size() == i+1);
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == a[j]);
+ }
+ }
+#if __cplusplus >= 201103L
+ {
+ bool a[] = {0, 1, 1, 0, 1, 0, 0};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<bool, min_allocator<bool>> c;
+ for (unsigned i = 0; i < N; ++i)
+ {
+ c.push_back(a[i]);
+ assert(c.size() == i+1);
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == a[j]);
+ }
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp
new file mode 100644
index 00000000000..be717a3be8a
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/reserve.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void reserve(size_type n);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v;
+ v.reserve(10);
+ assert(v.capacity() >= 10);
+ }
+ {
+ std::vector<bool> v(100);
+ assert(v.capacity() >= 100);
+ v.reserve(50);
+ assert(v.size() == 100);
+ assert(v.capacity() >= 100);
+ v.reserve(150);
+ assert(v.size() == 100);
+ assert(v.capacity() >= 150);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v;
+ v.reserve(10);
+ assert(v.capacity() >= 10);
+ }
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ assert(v.capacity() >= 100);
+ v.reserve(50);
+ assert(v.size() == 100);
+ assert(v.capacity() >= 100);
+ v.reserve(150);
+ assert(v.size() == 100);
+ assert(v.capacity() >= 150);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/resize_size.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/resize_size.pass.cpp
new file mode 100644
index 00000000000..f75720c94ea
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/resize_size.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void resize(size_type sz);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v(100);
+ v.resize(50);
+ assert(v.size() == 50);
+ assert(v.capacity() >= 100);
+ v.resize(200);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ v.reserve(400);
+ v.resize(300); // check the case when resizing and we already have room
+ assert(v.size() == 300);
+ assert(v.capacity() >= 400);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ v.resize(50);
+ assert(v.size() == 50);
+ assert(v.capacity() >= 100);
+ v.resize(200);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ v.reserve(400);
+ v.resize(300); // check the case when resizing and we already have room
+ assert(v.size() == 300);
+ assert(v.capacity() >= 400);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp
new file mode 100644
index 00000000000..8cecf44d2fb
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void resize(size_type sz, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v(100);
+ v.resize(50, 1);
+ assert(v.size() == 50);
+ assert(v.capacity() >= 100);
+ assert(v == std::vector<bool>(50));
+ v.resize(200, 1);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ for (unsigned i = 0; i < 50; ++i)
+ assert(v[i] == 0);
+ for (unsigned i = 50; i < 200; ++i)
+ assert(v[i] == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ v.resize(50, 1);
+ assert(v.size() == 50);
+ assert(v.capacity() >= 100);
+ assert((v == std::vector<bool, min_allocator<bool>>(50)));
+ v.resize(200, 1);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ for (unsigned i = 0; i < 50; ++i)
+ assert(v[i] == 0);
+ for (unsigned i = 50; i < 200; ++i)
+ assert(v[i] == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp
new file mode 100644
index 00000000000..1f9fcac3d9b
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/shrink_to_fit.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void shrink_to_fit();
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v(100);
+ v.push_back(1);
+ v.shrink_to_fit();
+ assert(v.capacity() >= 101);
+ assert(v.size() >= 101);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v(100);
+ v.push_back(1);
+ v.shrink_to_fit();
+ assert(v.capacity() >= 101);
+ assert(v.size() >= 101);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/swap.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/swap.pass.cpp
new file mode 100644
index 00000000000..a92c6a6c165
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/swap.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// vector<bool>
+
+// void swap(vector& x);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<bool> v1(100);
+ std::vector<bool> v2(200);
+ v1.swap(v2);
+ assert(v1.size() == 200);
+ assert(v1.capacity() >= 200);
+ assert(v2.size() == 100);
+ assert(v2.capacity() >= 100);
+ }
+ {
+ typedef test_allocator<bool> A;
+ std::vector<bool, A> v1(100, true, A(1));
+ std::vector<bool, A> v2(200, false, A(2));
+ swap(v1, v2);
+ assert(v1.size() == 200);
+ assert(v1.capacity() >= 200);
+ assert(v2.size() == 100);
+ assert(v2.capacity() >= 100);
+ assert(v1.get_allocator() == A(1));
+ assert(v2.get_allocator() == A(2));
+ }
+ {
+ typedef other_allocator<bool> A;
+ std::vector<bool, A> v1(100, true, A(1));
+ std::vector<bool, A> v2(200, false, A(2));
+ swap(v1, v2);
+ assert(v1.size() == 200);
+ assert(v1.capacity() >= 200);
+ assert(v2.size() == 100);
+ assert(v2.capacity() >= 100);
+ assert(v1.get_allocator() == A(2));
+ assert(v2.get_allocator() == A(1));
+ }
+ {
+ std::vector<bool> v(2);
+ std::vector<bool>::reference r1 = v[0];
+ std::vector<bool>::reference r2 = v[1];
+ r1 = true;
+ using std::swap;
+ swap(r1, r2);
+ assert(v[0] == false);
+ assert(v[1] == true);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<bool, min_allocator<bool>> v1(100);
+ std::vector<bool, min_allocator<bool>> v2(200);
+ v1.swap(v2);
+ assert(v1.size() == 200);
+ assert(v1.capacity() >= 200);
+ assert(v2.size() == 100);
+ assert(v2.capacity() >= 100);
+ }
+ {
+ typedef min_allocator<bool> A;
+ std::vector<bool, A> v1(100, true, A());
+ std::vector<bool, A> v2(200, false, A());
+ swap(v1, v2);
+ assert(v1.size() == 200);
+ assert(v1.capacity() >= 200);
+ assert(v2.size() == 100);
+ assert(v2.capacity() >= 100);
+ assert(v1.get_allocator() == A());
+ assert(v2.get_allocator() == A());
+ }
+ {
+ std::vector<bool, min_allocator<bool>> v(2);
+ std::vector<bool, min_allocator<bool>>::reference r1 = v[0];
+ std::vector<bool, min_allocator<bool>>::reference r2 = v[1];
+ r1 = true;
+ using std::swap;
+ swap(r1, r2);
+ assert(v[0] == false);
+ assert(v[1] == true);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp
new file mode 100644
index 00000000000..bcaf161119f
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/swap_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void swap(vector& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+
+ some_alloc() {}
+ some_alloc(const some_alloc&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::vector<bool> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::vector<bool, test_allocator<bool>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::vector<bool, other_allocator<bool>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::vector<bool, some_alloc<bool>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/types.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/types.pass.cpp
new file mode 100644
index 00000000000..b266b3bbb92
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/types.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Test nested types and default template args:
+
+// template <class Allocator>
+// class vector<bool, Allocator
+// {
+// public:
+// typedef T value_type;
+// typedef Allocator allocator_type;
+// typedef implementation-defined iterator;
+// typedef implementation-defined const_iterator;
+// typedef typename allocator_type::size_type size_type;
+// typedef typename allocator_type::difference_type difference_type;
+// typedef typename allocator_type::pointer pointer;
+// typedef typename allocator_type::const_pointer const_pointer;
+// typedef std::reverse_iterator<iterator> reverse_iterator;
+// typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+// };
+
+#include <vector>
+#include <iterator>
+#include <type_traits>
+
+#include "test_allocator.h"
+#include "../../Copyable.h"
+#include "min_allocator.h"
+
+template <class Allocator>
+void
+test()
+{
+ typedef std::vector<bool, Allocator> C;
+
+ static_assert((std::is_same<typename C::value_type, bool>::value), "");
+ static_assert((std::is_same<typename C::value_type, typename Allocator::value_type>::value), "");
+ static_assert((std::is_same<typename C::allocator_type, Allocator>::value), "");
+ static_assert((std::is_same<typename C::size_type, typename std::allocator_traits<Allocator>::size_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type, typename std::allocator_traits<Allocator>::difference_type>::value), "");
+ static_assert((std::is_same<
+ typename std::iterator_traits<typename C::iterator>::iterator_category,
+ std::random_access_iterator_tag>::value), "");
+ static_assert((std::is_same<
+ typename std::iterator_traits<typename C::const_iterator>::iterator_category,
+ std::random_access_iterator_tag>::value), "");
+ static_assert((std::is_same<
+ typename C::reverse_iterator,
+ std::reverse_iterator<typename C::iterator> >::value), "");
+ static_assert((std::is_same<
+ typename C::const_reverse_iterator,
+ std::reverse_iterator<typename C::const_iterator> >::value), "");
+}
+
+int main()
+{
+ test<test_allocator<bool> >();
+ test<std::allocator<bool> >();
+ static_assert((std::is_same<std::vector<bool>::allocator_type,
+ std::allocator<bool> >::value), "");
+#if __cplusplus >= 201103L
+ test<min_allocator<bool> >();
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp
new file mode 100644
index 00000000000..ea2262cd9c1
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector.bool/vector_bool.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <functional>
+
+// template <class T>
+// struct hash
+// : public unary_function<T, size_t>
+// {
+// size_t operator()(T val) const;
+// };
+
+// Not very portable
+
+#include <vector>
+#include <cassert>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::vector<bool> T;
+ typedef std::hash<T> H;
+ static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+ H>::value), "");
+ bool ba[] = {true, false, true, true, false};
+ T vb(std::begin(ba), std::end(ba));
+ H h;
+ assert(h(vb) != 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::vector<bool, min_allocator<bool>> T;
+ typedef std::hash<T> H;
+ static_assert((std::is_base_of<std::unary_function<T, std::size_t>,
+ H>::value), "");
+ bool ba[] = {true, false, true, true, false};
+ T vb(std::begin(ba), std::end(ba));
+ H h;
+ assert(h(vb) != 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/asan.pass.cpp b/libcxx/test/std/containers/sequences/vector/asan.pass.cpp
new file mode 100644
index 00000000000..86c02b29562
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/asan.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// reference operator[](size_type n);
+
+#include <vector>
+#include <cassert>
+#include <cstdlib>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+#ifndef _LIBCPP_HAS_NO_ASAN
+extern "C" void __asan_set_error_exit_code(int);
+
+int main()
+{
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ c.reserve(2*c.size());
+ T foo = c[c.size()]; // bad, but not caught by ASAN
+ }
+#endif
+
+ __asan_set_error_exit_code(0);
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ c.reserve(2*c.size());
+ assert(is_contiguous_container_asan_correct(c));
+ assert(!__sanitizer_verify_contiguous_container ( c.data(), c.data() + 1, c.data() + c.capacity()));
+ T foo = c[c.size()]; // should trigger ASAN
+ assert(false); // if we got here, ASAN didn't trigger
+ }
+}
+#else
+int main () { return 0; }
+#endif
diff --git a/libcxx/test/std/containers/sequences/vector/asan_throw.pass.cc b/libcxx/test/std/containers/sequences/vector/asan_throw.pass.cc
new file mode 100644
index 00000000000..a1dce4a3b44
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/asan_throw.pass.cc
@@ -0,0 +1,198 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// Test asan vector annotations with a class that throws in a CTOR.
+
+#include <vector>
+#include <cassert>
+
+#include "asan_testing.h"
+
+class X {
+public:
+ X(const X &x) { Init(x.a); }
+ X(char arg) { Init(arg); }
+ X() { Init(42); }
+ X &operator=(const X &x) {
+ Init(x.a);
+ return *this;
+ }
+ void Init(char arg) {
+ if (arg == 42)
+ throw 0;
+ if (arg == 66)
+ arg = 42;
+ a = arg;
+ }
+ char get() const { return a; }
+ void set(char arg) { a = arg; }
+
+private:
+ char a;
+};
+
+void test_push_back() {
+ std::vector<X> v;
+ v.reserve(2);
+ v.push_back(X(2));
+ assert(v.size() == 1);
+ try {
+ v.push_back(X(66));
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 1);
+ }
+ assert(v.size() == 1);
+ assert(is_contiguous_container_asan_correct(v));
+}
+
+void test_emplace_back() {
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ std::vector<X> v;
+ v.reserve(2);
+ v.push_back(X(2));
+ assert(v.size() == 1);
+ try {
+ v.emplace_back(42);
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 1);
+ }
+ assert(v.size() == 1);
+ assert(is_contiguous_container_asan_correct(v));
+#endif // _LIBCPP_HAS_NO_VARIADICS
+}
+
+void test_insert_range() {
+ std::vector<X> v;
+ v.reserve(4);
+ v.push_back(X(1));
+ v.push_back(X(2));
+ assert(v.size() == 2);
+ assert(v.capacity() >= 4);
+ try {
+ char a[2] = {21, 42};
+ v.insert(v.end(), a, a + 2);
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 3);
+ }
+ assert(v.size() == 3);
+ assert(is_contiguous_container_asan_correct(v));
+}
+
+void test_insert() {
+ std::vector<X> v;
+ v.reserve(3);
+ v.insert(v.end(), X(1));
+ v.insert(v.begin(), X(2));
+ assert(v.size() == 2);
+ try {
+ v.insert(v.end(), X(66));
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 2);
+ }
+ assert(v.size() == 2);
+ assert(is_contiguous_container_asan_correct(v));
+}
+
+void test_emplace() {
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ std::vector<X> v;
+ v.reserve(3);
+ v.insert(v.end(), X(1));
+ v.insert(v.begin(), X(2));
+ assert(v.size() == 2);
+ try {
+ v.emplace(v.end(), 42);
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 2);
+ }
+ assert(v.size() == 2);
+ assert(is_contiguous_container_asan_correct(v));
+#endif // _LIBCPP_HAS_NO_VARIADICS
+}
+
+void test_insert_range2() {
+ std::vector<X> v;
+ v.reserve(4);
+ v.insert(v.end(), X(1));
+ v.insert(v.begin(), X(2));
+ assert(v.size() == 2);
+ assert(v.capacity() >= 4);
+ try {
+ char a[2] = {10, 42};
+ v.insert(v.begin(), a, a + 2);
+ assert(0);
+ } catch (int e) {
+ assert(v.size() <= 4);
+ assert(is_contiguous_container_asan_correct(v));
+ return;
+ }
+ assert(0);
+}
+
+void test_insert_n() {
+ std::vector<X> v;
+ v.reserve(10);
+ v.insert(v.end(), X(1));
+ v.insert(v.begin(), X(2));
+ assert(v.size() == 2);
+ try {
+ v.insert(v.begin(), 1, X(66));
+ assert(0);
+ } catch (int e) {
+ assert(v.size() <= 3);
+ assert(is_contiguous_container_asan_correct(v));
+ return;
+ }
+ assert(0);
+}
+
+void test_resize() {
+ std::vector<X> v;
+ v.reserve(3);
+ v.push_back(X(0));
+ try {
+ v.resize(3);
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 1);
+ }
+ assert(v.size() == 1);
+ assert(is_contiguous_container_asan_correct(v));
+}
+
+void test_resize_param() {
+ std::vector<X> v;
+ v.reserve(3);
+ v.push_back(X(0));
+ try {
+ v.resize(3, X(66));
+ assert(0);
+ } catch (int e) {
+ assert(v.size() == 1);
+ }
+ assert(v.size() == 1);
+ assert(is_contiguous_container_asan_correct(v));
+}
+
+int main() {
+ test_push_back();
+ test_emplace_back();
+ test_insert_range();
+ test_insert();
+ test_emplace();
+ test_insert_range2();
+ test_insert_n();
+ test_resize();
+ test_resize_param();
+}
diff --git a/libcxx/test/std/containers/sequences/vector/const_value_type.pass.cpp b/libcxx/test/std/containers/sequences/vector/const_value_type.pass.cpp
new file mode 100644
index 00000000000..e16e439dec4
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/const_value_type.pass.cpp
@@ -0,0 +1,22 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector<const int> v; // an extension
+
+#include <vector>
+#include <type_traits>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ std::vector<const int> v = {1, 2, 3};
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/db_back.pass.cpp b/libcxx/test/std/containers/sequences/vector/db_back.pass.cpp
new file mode 100644
index 00000000000..05f3d07712e
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/db_back.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call back() on empty container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ assert(c.back() == 0);
+ c.clear();
+ assert(c.back() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ assert(c.back() == 0);
+ c.clear();
+ assert(c.back() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/vector/db_cback.pass.cpp b/libcxx/test/std/containers/sequences/vector/db_cback.pass.cpp
new file mode 100644
index 00000000000..5eb1a353e8b
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/db_cback.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call back() on empty const container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ const C c;
+ assert(c.back() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const C c;
+ assert(c.back() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/vector/db_cfront.pass.cpp b/libcxx/test/std/containers/sequences/vector/db_cfront.pass.cpp
new file mode 100644
index 00000000000..5e54da1d444
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/db_cfront.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call front() on empty const container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ const C c;
+ assert(c.front() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const C c;
+ assert(c.front() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/vector/db_cindex.pass.cpp b/libcxx/test/std/containers/sequences/vector/db_cindex.pass.cpp
new file mode 100644
index 00000000000..133aa565282
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/db_cindex.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Index const vector out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ const C c(1);
+ assert(c[0] == 0);
+ assert(c[1] == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const C c(1);
+ assert(c[0] == 0);
+ assert(c[1] == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/vector/db_front.pass.cpp b/libcxx/test/std/containers/sequences/vector/db_front.pass.cpp
new file mode 100644
index 00000000000..388058fb315
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/db_front.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call front() on empty container.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ assert(c.front() == 0);
+ c.clear();
+ assert(c.front() == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ assert(c.front() == 0);
+ c.clear();
+ assert(c.front() == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/vector/db_index.pass.cpp b/libcxx/test/std/containers/sequences/vector/db_index.pass.cpp
new file mode 100644
index 00000000000..1daf076da67
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/db_index.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Index vector out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ assert(c[0] == 0);
+ c.clear();
+ assert(c[0] == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ assert(c[0] == 0);
+ c.clear();
+ assert(c[0] == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/vector/db_iterators_2.pass.cpp b/libcxx/test/std/containers/sequences/vector/db_iterators_2.pass.cpp
new file mode 100644
index 00000000000..2d43843067b
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/db_iterators_2.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Compare iterators from different containers with <.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c1;
+ C c2;
+ bool b = c1.begin() < c2.begin();
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c1;
+ C c2;
+ bool b = c1.begin() < c2.begin();
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/vector/db_iterators_3.pass.cpp b/libcxx/test/std/containers/sequences/vector/db_iterators_3.pass.cpp
new file mode 100644
index 00000000000..051d66c3339
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/db_iterators_3.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Subtract iterators from different containers.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c1;
+ C c2;
+ int i = c1.begin() - c2.begin();
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c1;
+ C c2;
+ int i = c1.begin() - c2.begin();
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/vector/db_iterators_4.pass.cpp b/libcxx/test/std/containers/sequences/vector/db_iterators_4.pass.cpp
new file mode 100644
index 00000000000..4c2aa628de1
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/db_iterators_4.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Index iterator out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ C::iterator i = c.begin();
+ assert(i[0] == 0);
+ assert(i[1] == 0);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.begin();
+ assert(i[0] == 0);
+ assert(i[1] == 0);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/vector/db_iterators_5.pass.cpp b/libcxx/test/std/containers/sequences/vector/db_iterators_5.pass.cpp
new file mode 100644
index 00000000000..1b1090499c2
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/db_iterators_5.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Add to iterator out of bounds.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ C::iterator i = c.begin();
+ i += 1;
+ assert(i == c.end());
+ i = c.begin();
+ i += 2;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.begin();
+ i += 1;
+ assert(i == c.end());
+ i = c.begin();
+ i += 2;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/vector/db_iterators_6.pass.cpp b/libcxx/test/std/containers/sequences/vector/db_iterators_6.pass.cpp
new file mode 100644
index 00000000000..424bc939b13
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/db_iterators_6.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Decrement iterator prior to begin.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ C::iterator i = c.end();
+ --i;
+ assert(i == c.begin());
+ --i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.end();
+ --i;
+ assert(i == c.begin());
+ --i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/vector/db_iterators_7.pass.cpp b/libcxx/test/std/containers/sequences/vector/db_iterators_7.pass.cpp
new file mode 100644
index 00000000000..72cdb10cbc8
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/db_iterators_7.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/vector/db_iterators_8.pass.cpp b/libcxx/test/std/containers/sequences/vector/db_iterators_8.pass.cpp
new file mode 100644
index 00000000000..7b898533197
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/db_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c(1);
+ C::iterator i = c.end();
+ T j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.end();
+ T j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/vector/iterators.pass.cpp b/libcxx/test/std/containers/sequences/vector/iterators.pass.cpp
new file mode 100644
index 00000000000..75a08287a86
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/iterators.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator begin();
+// iterator end();
+// const_iterator begin() const;
+// const_iterator end() const;
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+
+#include <vector>
+#include <cassert>
+#include <iterator>
+
+#include "min_allocator.h"
+
+struct A
+{
+ int first;
+ int second;
+};
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c;
+ C::iterator i = c.begin();
+ C::iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ const C c;
+ C::const_iterator i = c.begin();
+ C::const_iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C c;
+ C::const_iterator i = c.cbegin();
+ C::const_iterator j = c.cend();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ assert(i == c.end());
+ }
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ C::iterator i = c.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 1);
+ *i = 10;
+ assert(*i == 10);
+ assert(std::distance(c.begin(), c.end()) == 10);
+ }
+ {
+ typedef int T;
+ typedef std::vector<T> C;
+ C::iterator i;
+ C::const_iterator j;
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c;
+ C::iterator i = c.begin();
+ C::iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const C c;
+ C::const_iterator i = c.begin();
+ C::const_iterator j = c.end();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ }
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c;
+ C::const_iterator i = c.cbegin();
+ C::const_iterator j = c.cend();
+ assert(std::distance(i, j) == 0);
+ assert(i == j);
+ assert(i == c.end());
+ }
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
+ C c(std::begin(t), std::end(t));
+ C::iterator i = c.begin();
+ assert(*i == 0);
+ ++i;
+ assert(*i == 1);
+ *i = 10;
+ assert(*i == 10);
+ assert(std::distance(c.begin(), c.end()) == 10);
+ }
+ {
+ typedef int T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C::iterator i;
+ C::const_iterator j;
+ }
+ {
+ typedef A T;
+ typedef std::vector<T, min_allocator<T>> C;
+ C c = {A{1, 2}};
+ C::iterator i = c.begin();
+ i->first = 3;
+ C::const_iterator j = i;
+ assert(j->first == 3);
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::vector<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 ));
+ assert (!(ii1 < cii ));
+ assert (!(cii < ii1 ));
+ assert ( (ii1 <= cii ));
+ assert ( (cii <= ii1 ));
+ assert (!(ii1 > cii ));
+ assert (!(cii > ii1 ));
+ assert ( (ii1 >= cii ));
+ assert ( (cii >= ii1 ));
+ assert (cii - ii1 == 0);
+ assert (ii1 - cii == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/types.pass.cpp b/libcxx/test/std/containers/sequences/vector/types.pass.cpp
new file mode 100644
index 00000000000..3504de6f75d
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Test nested types and default template args:
+
+// template <class T, class Allocator = allocator<T> >
+// class vector
+// {
+// public:
+// typedef T value_type;
+// typedef Allocator allocator_type;
+// typedef typename allocator_type::reference reference;
+// typedef typename allocator_type::const_reference const_reference;
+// typedef implementation-defined iterator;
+// typedef implementation-defined const_iterator;
+// typedef typename allocator_type::size_type size_type;
+// typedef typename allocator_type::difference_type difference_type;
+// typedef typename allocator_type::pointer pointer;
+// typedef typename allocator_type::const_pointer const_pointer;
+// typedef std::reverse_iterator<iterator> reverse_iterator;
+// typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+// };
+
+#include <vector>
+#include <iterator>
+#include <type_traits>
+
+#include "test_allocator.h"
+#include "../../Copyable.h"
+#include "min_allocator.h"
+
+template <class T, class Allocator>
+void
+test()
+{
+ typedef std::vector<T, Allocator> C;
+
+ static_assert((std::is_same<typename C::value_type, T>::value), "");
+ static_assert((std::is_same<typename C::value_type, typename Allocator::value_type>::value), "");
+ static_assert((std::is_same<typename C::allocator_type, Allocator>::value), "");
+ static_assert((std::is_same<typename C::size_type, typename Allocator::size_type>::value), "");
+ static_assert((std::is_same<typename C::difference_type, typename Allocator::difference_type>::value), "");
+ static_assert((std::is_same<typename C::reference, typename Allocator::reference>::value), "");
+ static_assert((std::is_same<typename C::const_reference, typename Allocator::const_reference>::value), "");
+ static_assert((std::is_same<typename C::pointer, typename Allocator::pointer>::value), "");
+ static_assert((std::is_same<typename C::const_pointer, typename Allocator::const_pointer>::value), "");
+ static_assert((std::is_same<
+ typename std::iterator_traits<typename C::iterator>::iterator_category,
+ std::random_access_iterator_tag>::value), "");
+ static_assert((std::is_same<
+ typename std::iterator_traits<typename C::const_iterator>::iterator_category,
+ std::random_access_iterator_tag>::value), "");
+ static_assert((std::is_same<
+ typename C::reverse_iterator,
+ std::reverse_iterator<typename C::iterator> >::value), "");
+ static_assert((std::is_same<
+ typename C::const_reverse_iterator,
+ std::reverse_iterator<typename C::const_iterator> >::value), "");
+}
+
+int main()
+{
+ test<int, test_allocator<int> >();
+ test<int*, std::allocator<int*> >();
+ test<Copyable, test_allocator<Copyable> >();
+ static_assert((std::is_same<std::vector<char>::allocator_type,
+ std::allocator<char> >::value), "");
+#if __cplusplus >= 201103L
+ static_assert((std::is_same<std::vector<int, min_allocator<int>>::value_type, int>::value), "");
+ static_assert((std::is_same<std::vector<int, min_allocator<int>>::allocator_type, min_allocator<int> >::value), "");
+ static_assert((std::is_same<std::vector<int, min_allocator<int>>::reference, int&>::value), "");
+ static_assert((std::is_same<std::vector<int, min_allocator<int>>::const_reference, const int&>::value), "");
+ static_assert((std::is_same<std::vector<int, min_allocator<int>>::pointer, min_pointer<int>>::value), "");
+ static_assert((std::is_same<std::vector<int, min_allocator<int>>::const_pointer, min_pointer<const int>>::value), "");
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp
new file mode 100644
index 00000000000..21082c839f5
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp
@@ -0,0 +1,48 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// size_type capacity() const;
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v;
+ assert(v.capacity() == 0);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int> v(100);
+ assert(v.capacity() == 100);
+ v.push_back(0);
+ assert(v.capacity() > 101);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v;
+ assert(v.capacity() == 0);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ assert(v.capacity() == 100);
+ v.push_back(0);
+ assert(v.capacity() > 101);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp
new file mode 100644
index 00000000000..4df5702f2ad
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/reserve.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void reserve(size_type n);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v;
+ v.reserve(10);
+ assert(v.capacity() >= 10);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int> v(100);
+ assert(v.capacity() == 100);
+ v.reserve(50);
+ assert(v.size() == 100);
+ assert(v.capacity() == 100);
+ v.reserve(150);
+ assert(v.size() == 100);
+ assert(v.capacity() == 150);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int, stack_allocator<int, 250> > v(100);
+ assert(v.capacity() == 100);
+ v.reserve(50);
+ assert(v.size() == 100);
+ assert(v.capacity() == 100);
+ v.reserve(150);
+ assert(v.size() == 100);
+ assert(v.capacity() == 150);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v;
+ v.reserve(10);
+ assert(v.capacity() >= 10);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ assert(v.capacity() == 100);
+ v.reserve(50);
+ assert(v.size() == 100);
+ assert(v.capacity() == 100);
+ v.reserve(150);
+ assert(v.size() == 100);
+ assert(v.capacity() == 150);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp
new file mode 100644
index 00000000000..a47c5131d8a
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void resize(size_type sz);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<MoveOnly> v(100);
+ v.resize(50);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v));
+ v.resize(200);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<MoveOnly, stack_allocator<MoveOnly, 300> > v(100);
+ v.resize(50);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v));
+ v.resize(200);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<int> v(100);
+ v.resize(50);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v));
+ v.resize(200);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int, stack_allocator<int, 300> > v(100);
+ v.resize(50);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v));
+ v.resize(200);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ std::vector<MoveOnly, min_allocator<MoveOnly>> v(100);
+ v.resize(50);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v));
+ v.resize(200);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp
new file mode 100644
index 00000000000..de5126b03d1
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/resize_size_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void resize(size_type sz, const value_type& x);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v(100);
+ v.resize(50, 1);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(v == std::vector<int>(50));
+ v.resize(200, 1);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ for (unsigned i = 0; i < 50; ++i)
+ assert(v[i] == 0);
+ for (unsigned i = 50; i < 200; ++i)
+ assert(v[i] == 1);
+ }
+ {
+ std::vector<int, stack_allocator<int, 300> > v(100);
+ v.resize(50, 1);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ v.resize(200, 1);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ v.resize(50, 1);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v));
+ assert((v == std::vector<int, min_allocator<int>>(50)));
+ v.resize(200, 1);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ for (unsigned i = 0; i < 50; ++i)
+ assert(v[i] == 0);
+ for (unsigned i = 50; i < 200; ++i)
+ assert(v[i] == 1);
+ }
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ v.resize(50, 1);
+ assert(v.size() == 50);
+ assert(v.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v));
+ v.resize(200, 1);
+ assert(v.size() == 200);
+ assert(v.capacity() >= 200);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp
new file mode 100644
index 00000000000..49ab9cc71de
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void shrink_to_fit();
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v(100);
+ v.push_back(1);
+ assert(is_contiguous_container_asan_correct(v));
+ v.shrink_to_fit();
+ assert(v.capacity() == 101);
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int, stack_allocator<int, 401> > v(100);
+ v.push_back(1);
+ assert(is_contiguous_container_asan_correct(v));
+ v.shrink_to_fit();
+ assert(v.capacity() == 101);
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ {
+ std::vector<int, stack_allocator<int, 400> > v(100);
+ v.push_back(1);
+ assert(is_contiguous_container_asan_correct(v));
+ v.shrink_to_fit();
+ assert(v.capacity() == 200);
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ v.push_back(1);
+ assert(is_contiguous_container_asan_correct(v));
+ v.shrink_to_fit();
+ assert(v.capacity() == 101);
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp
new file mode 100644
index 00000000000..f3d9289c36e
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void swap(vector& x);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v1(100);
+ std::vector<int> v2(200);
+ assert(is_contiguous_container_asan_correct(v1));
+ assert(is_contiguous_container_asan_correct(v2));
+ v1.swap(v2);
+ assert(v1.size() == 200);
+ assert(v1.capacity() == 200);
+ assert(is_contiguous_container_asan_correct(v1));
+ assert(v2.size() == 100);
+ assert(v2.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v2));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v1(100);
+ std::vector<int, min_allocator<int>> v2(200);
+ assert(is_contiguous_container_asan_correct(v1));
+ assert(is_contiguous_container_asan_correct(v2));
+ v1.swap(v2);
+ assert(v1.size() == 200);
+ assert(v1.capacity() == 200);
+ assert(is_contiguous_container_asan_correct(v1));
+ assert(v2.size() == 100);
+ assert(v2.capacity() == 100);
+ assert(is_contiguous_container_asan_correct(v2));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp
new file mode 100644
index 00000000000..6f02c3b7bc2
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(const vector& c);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::vector<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+ std::vector<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == test_allocator<int>(3));
+ }
+ {
+ std::vector<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+ std::vector<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == other_allocator<int>(5));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+ std::vector<int, min_allocator<int> > l2(l, min_allocator<int>());
+ l2 = l;
+ assert(l2 == l);
+ assert(l2.get_allocator() == min_allocator<int>());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp
new file mode 100644
index 00000000000..f5c06b1a1bd
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void assign(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<int> d;
+ d.assign({3, 4, 5, 6});
+ assert(d.size() == 4);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> d;
+ d.assign({3, 4, 5, 6});
+ assert(d.size() == 4);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp
new file mode 100644
index 00000000000..d87ac8636b0
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/assign_move.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(vector&& c);
+
+#include <vector>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(5));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+ {
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(6));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+ {
+ std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, other_allocator<MoveOnly> > l2(other_allocator<MoveOnly>(6));
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+ std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, min_allocator<MoveOnly> > l2(min_allocator<MoveOnly>{});
+ l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp
new file mode 100644
index 00000000000..75772bef78a
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(const Alloc& = Alloc());
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "../../../NotConstructible.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C>
+void
+test0()
+{
+ C c;
+ assert(c.__invariants());
+ assert(c.empty());
+ assert(c.get_allocator() == typename C::allocator_type());
+ assert(is_contiguous_container_asan_correct(c));
+#if __cplusplus >= 201103L
+ C c1 = {};
+ assert(c1.__invariants());
+ assert(c1.empty());
+ assert(c1.get_allocator() == typename C::allocator_type());
+ assert(is_contiguous_container_asan_correct(c1));
+#endif
+}
+
+template <class C>
+void
+test1(const typename C::allocator_type& a)
+{
+ C c(a);
+ assert(c.__invariants());
+ assert(c.empty());
+ assert(c.get_allocator() == a);
+ assert(is_contiguous_container_asan_correct(c));
+}
+
+int main()
+{
+ {
+ test0<std::vector<int> >();
+ test0<std::vector<NotConstructible> >();
+ test1<std::vector<int, test_allocator<int> > >(test_allocator<int>(3));
+ test1<std::vector<NotConstructible, test_allocator<NotConstructible> > >
+ (test_allocator<NotConstructible>(5));
+ }
+ {
+ std::vector<int, stack_allocator<int, 10> > v;
+ assert(v.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ test0<std::vector<int, min_allocator<int>> >();
+ test0<std::vector<NotConstructible, min_allocator<NotConstructible>> >();
+ test1<std::vector<int, min_allocator<int> > >(min_allocator<int>{});
+ test1<std::vector<NotConstructible, min_allocator<NotConstructible> > >
+ (min_allocator<NotConstructible>{});
+ }
+ {
+ std::vector<int, min_allocator<int> > v;
+ assert(v.empty());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
new file mode 100644
index 00000000000..36e231acce1
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class InputIter> vector(InputIter first, InputIter last);
+
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C, class Iterator>
+void
+test(Iterator first, Iterator last)
+{
+ C c(first, last);
+ assert(c.__invariants());
+ assert(c.size() == std::distance(first, last));
+ assert(is_contiguous_container_asan_correct(c));
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
+ assert(*i == *first);
+}
+
+int main()
+{
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ test<std::vector<int> >(input_iterator<const int*>(a), input_iterator<const int*>(an));
+ test<std::vector<int> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));
+ test<std::vector<int> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));
+ test<std::vector<int> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));
+ test<std::vector<int> >(a, an);
+
+ test<std::vector<int, stack_allocator<int, 63> > >(input_iterator<const int*>(a), input_iterator<const int*>(an));
+ test<std::vector<int, stack_allocator<int, 18> > >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));
+ test<std::vector<int, stack_allocator<int, 18> > >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));
+ test<std::vector<int, stack_allocator<int, 18> > >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));
+ test<std::vector<int, stack_allocator<int, 18> > >(a, an);
+#if __cplusplus >= 201103L
+ test<std::vector<int, min_allocator<int>> >(input_iterator<const int*>(a), input_iterator<const int*>(an));
+ test<std::vector<int, min_allocator<int>> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an));
+ test<std::vector<int, min_allocator<int>> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an));
+ test<std::vector<int, min_allocator<int>> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an));
+ test<std::vector<int> >(a, an);
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
new file mode 100644
index 00000000000..7fa748a90d7
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class InputIter> vector(InputIter first, InputIter last,
+// const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C, class Iterator, class A>
+void
+test(Iterator first, Iterator last, const A& a)
+{
+ C c(first, last, a);
+ assert(c.__invariants());
+ assert(c.size() == std::distance(first, last));
+ assert(is_contiguous_container_asan_correct(c));
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first)
+ assert(*i == *first);
+}
+
+#if __cplusplus >= 201103L
+
+template <class T>
+struct implicit_conv_allocator : min_allocator<T>
+{
+ implicit_conv_allocator(void* p) {}
+ implicit_conv_allocator(const implicit_conv_allocator&) = default;
+};
+
+#endif
+
+int main()
+{
+ {
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ std::allocator<int> alloc;
+ test<std::vector<int> >(input_iterator<const int*>(a), input_iterator<const int*>(an), alloc);
+ test<std::vector<int> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an), alloc);
+ test<std::vector<int> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an), alloc);
+ test<std::vector<int> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an), alloc);
+ test<std::vector<int> >(a, an, alloc);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ min_allocator<int> alloc;
+ test<std::vector<int, min_allocator<int>> >(input_iterator<const int*>(a), input_iterator<const int*>(an), alloc);
+ test<std::vector<int, min_allocator<int>> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an), alloc);
+ test<std::vector<int, min_allocator<int>> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an), alloc);
+ test<std::vector<int, min_allocator<int>> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an), alloc);
+ test<std::vector<int, min_allocator<int>> >(a, an, alloc);
+ test<std::vector<int, implicit_conv_allocator<int>> >(a, an, nullptr);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp
new file mode 100644
index 00000000000..e03389593f1
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// explicit vector(size_type n);
+
+#include <vector>
+#include <cassert>
+
+#include "DefaultOnly.h"
+#include "min_allocator.h"
+#include "test_allocator.h"
+#include "asan_testing.h"
+
+template <class C>
+void
+test2(typename C::size_type n, typename C::allocator_type const& a = typename C::allocator_type ())
+{
+#if _LIBCPP_STD_VER > 11
+ C c(n, a);
+ assert(c.__invariants());
+ assert(c.size() == n);
+ assert(c.get_allocator() == a);
+ assert(is_contiguous_container_asan_correct(c));
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+ assert(*i == typename C::value_type());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
+
+template <class C>
+void
+test1(typename C::size_type n)
+{
+ C c(n);
+ assert(c.__invariants());
+ assert(c.size() == n);
+ assert(c.get_allocator() == typename C::allocator_type());
+ assert(is_contiguous_container_asan_correct(c));
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+ assert(*i == typename C::value_type());
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
+
+template <class C>
+void
+test(typename C::size_type n)
+{
+ test1<C> ( n );
+ test2<C> ( n );
+}
+
+int main()
+{
+ test<std::vector<int> >(50);
+ test<std::vector<DefaultOnly> >(500);
+ assert(DefaultOnly::count == 0);
+#if __cplusplus >= 201103L
+ test<std::vector<int, min_allocator<int>> >(50);
+ test<std::vector<DefaultOnly, min_allocator<DefaultOnly>> >(500);
+ test2<std::vector<DefaultOnly, test_allocator<DefaultOnly>> >( 100, test_allocator<DefaultOnly>(23));
+ assert(DefaultOnly::count == 0);
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp
new file mode 100644
index 00000000000..5b6c4985704
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(size_type n, const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C>
+void
+test(typename C::size_type n, const typename C::value_type& x)
+{
+ C c(n, x);
+ assert(c.__invariants());
+ assert(c.size() == n);
+ assert(is_contiguous_container_asan_correct(c));
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+ assert(*i == x);
+}
+
+int main()
+{
+ test<std::vector<int> >(50, 3);
+ test<std::vector<int, stack_allocator<int, 50> > >(50, 5);
+#if __cplusplus >= 201103L
+ test<std::vector<int, min_allocator<int>> >(50, 3);
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp
new file mode 100644
index 00000000000..c62b84104ab
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(size_type n, const value_type& x, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C>
+void
+test(typename C::size_type n, const typename C::value_type& x,
+ const typename C::allocator_type& a)
+{
+ C c(n, x, a);
+ assert(c.__invariants());
+ assert(a == c.get_allocator());
+ assert(c.size() == n);
+ assert(is_contiguous_container_asan_correct(c));
+ for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i)
+ assert(*i == x);
+}
+
+int main()
+{
+ test<std::vector<int> >(50, 3, std::allocator<int>());
+#if __cplusplus >= 201103L
+ test<std::vector<int, min_allocator<int>> >(50, 3, min_allocator<int>());
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
new file mode 100644
index 00000000000..677963deeb8
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(const vector& v);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C>
+void
+test(const C& x)
+{
+ unsigned s = x.size();
+ C c(x);
+ assert(c.__invariants());
+ assert(c.size() == s);
+ assert(c == x);
+ assert(is_contiguous_container_asan_correct(c));
+}
+
+int main()
+{
+ {
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ test(std::vector<int>(a, an));
+ }
+ {
+ std::vector<int, test_allocator<int> > v(3, 2, test_allocator<int>(5));
+ std::vector<int, test_allocator<int> > v2 = v;
+ assert(is_contiguous_container_asan_correct(v));
+ assert(is_contiguous_container_asan_correct(v2));
+ assert(v2 == v);
+ assert(v2.get_allocator() == v.get_allocator());
+ assert(is_contiguous_container_asan_correct(v));
+ assert(is_contiguous_container_asan_correct(v2));
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ std::vector<int, other_allocator<int> > v(3, 2, other_allocator<int>(5));
+ std::vector<int, other_allocator<int> > v2 = v;
+ assert(is_contiguous_container_asan_correct(v));
+ assert(is_contiguous_container_asan_correct(v2));
+ assert(v2 == v);
+ assert(v2.get_allocator() == other_allocator<int>(-2));
+ assert(is_contiguous_container_asan_correct(v));
+ assert(is_contiguous_container_asan_correct(v2));
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ test(std::vector<int, min_allocator<int>>(a, an));
+ }
+ {
+ std::vector<int, min_allocator<int> > v(3, 2, min_allocator<int>());
+ std::vector<int, min_allocator<int> > v2 = v;
+ assert(is_contiguous_container_asan_correct(v));
+ assert(is_contiguous_container_asan_correct(v2));
+ assert(v2 == v);
+ assert(v2.get_allocator() == v.get_allocator());
+ assert(is_contiguous_container_asan_correct(v));
+ assert(is_contiguous_container_asan_correct(v2));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp
new file mode 100644
index 00000000000..128328c2a7d
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(const vector& v, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+template <class C>
+void
+test(const C& x, const typename C::allocator_type& a)
+{
+ unsigned s = x.size();
+ C c(x, a);
+ assert(c.__invariants());
+ assert(c.size() == s);
+ assert(c == x);
+ assert(is_contiguous_container_asan_correct(c));
+}
+
+int main()
+{
+ {
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ test(std::vector<int>(a, an), std::allocator<int>());
+ }
+ {
+ std::vector<int, test_allocator<int> > l(3, 2, test_allocator<int>(5));
+ std::vector<int, test_allocator<int> > l2(l, test_allocator<int>(3));
+ assert(l2 == l);
+ assert(l2.get_allocator() == test_allocator<int>(3));
+ }
+ {
+ std::vector<int, other_allocator<int> > l(3, 2, other_allocator<int>(5));
+ std::vector<int, other_allocator<int> > l2(l, other_allocator<int>(3));
+ assert(l2 == l);
+ assert(l2.get_allocator() == other_allocator<int>(3));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0};
+ int* an = a + sizeof(a)/sizeof(a[0]);
+ test(std::vector<int, min_allocator<int>>(a, an), min_allocator<int>());
+ }
+ {
+ std::vector<int, min_allocator<int> > l(3, 2, min_allocator<int>());
+ std::vector<int, min_allocator<int> > l2(l, min_allocator<int>());
+ assert(l2 == l);
+ assert(l2.get_allocator() == min_allocator<int>());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp
new file mode 100644
index 00000000000..1a4a1898cc6
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/default.recursive.pass.cpp
@@ -0,0 +1,23 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+// class vector
+// vector();
+
+#include <vector>
+
+struct X
+{
+ std::vector<X> q;
+};
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp
new file mode 100644
index 00000000000..3fc33b68d39
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector()
+// noexcept(is_nothrow_default_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::vector<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp
new file mode 100644
index 00000000000..0d73e9ef4d4
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// ~vector() // implied noexcept;
+
+#include <vector>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+#if __has_feature(cxx_noexcept)
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+ ~some_alloc() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::vector<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp
new file mode 100644
index 00000000000..7eb834ff387
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<int> d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp
new file mode 100644
index 00000000000..5d7ae884e38
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(initializer_list<value_type> il, const Allocator& a = allocator_type());
+
+#include <vector>
+#include <cassert>
+
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3));
+ assert(d.get_allocator() == test_allocator<int>(3));
+ assert(d.size() == 4);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>());
+ assert(d.get_allocator() == min_allocator<int>());
+ assert(d.size() == 4);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/move.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/move.pass.cpp
new file mode 100644
index 00000000000..bb61d54948b
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/move.pass.cpp
@@ -0,0 +1,103 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&& c);
+
+#include <vector>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+ {
+ std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, other_allocator<MoveOnly> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ assert(is_contiguous_container_asan_correct(c1));
+ std::vector<int>::const_iterator i = c1.begin();
+ std::vector<int> c2 = std::move(c1);
+ assert(is_contiguous_container_asan_correct(c2));
+ std::vector<int>::iterator j = c2.erase(i);
+ assert(*j == 3);
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+ std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, min_allocator<MoveOnly> > l2 = std::move(l);
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == lo.get_allocator());
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ assert(is_contiguous_container_asan_correct(c1));
+ std::vector<int, min_allocator<int>>::const_iterator i = c1.begin();
+ std::vector<int, min_allocator<int>> c2 = std::move(c1);
+ assert(is_contiguous_container_asan_correct(c2));
+ std::vector<int, min_allocator<int>>::iterator j = c2.erase(i);
+ assert(*j == 3);
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp
new file mode 100644
index 00000000000..1923e68f75e
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&& c, const allocator_type& a);
+
+#include <vector>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(6));
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == test_allocator<MoveOnly>(6));
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+ {
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(5));
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == test_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+ {
+ std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5));
+ std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5));
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, other_allocator<MoveOnly> > l2(std::move(l), other_allocator<MoveOnly>(4));
+ assert(l2 == lo);
+ assert(!l.empty());
+ assert(l2.get_allocator() == other_allocator<MoveOnly>(4));
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{});
+ std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{});
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ for (int i = 1; i <= 3; ++i)
+ {
+ l.push_back(i);
+ lo.push_back(i);
+ }
+ assert(is_contiguous_container_asan_correct(l));
+ assert(is_contiguous_container_asan_correct(lo));
+ std::vector<MoveOnly, min_allocator<MoveOnly> > l2(std::move(l), min_allocator<MoveOnly>());
+ assert(l2 == lo);
+ assert(l.empty());
+ assert(l2.get_allocator() == min_allocator<MoveOnly>());
+ assert(is_contiguous_container_asan_correct(l2));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp
new file mode 100644
index 00000000000..158370f4e1a
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(vector&& c)
+// noexcept(
+// allocator_type::propagate_on_container_move_assignment::value &&
+// is_nothrow_move_assignable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::vector<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp
new file mode 100644
index 00000000000..a2e36ccdf08
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector(vector&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+ some_alloc(const some_alloc&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::vector<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp
new file mode 100644
index 00000000000..592b7146276
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// vector& operator=(initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<int> d;
+ d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> d;
+ d = {3, 4, 5, 6};
+ assert(d.size() == 4);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(d[0] == 3);
+ assert(d[1] == 4);
+ assert(d[2] == 5);
+ assert(d[3] == 6);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.data/data.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.data/data.pass.cpp
new file mode 100644
index 00000000000..aed56bc0931
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.data/data.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// pointer data();
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v;
+ assert(v.data() == 0);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int> v(100);
+ assert(v.data() == &v.front());
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v;
+ assert(v.data() == 0);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ assert(v.data() == &v.front());
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp
new file mode 100644
index 00000000000..cb6062694e4
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// const_pointer data() const;
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ const std::vector<int> v;
+ assert(v.data() == 0);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ const std::vector<int> v(100);
+ assert(v.data() == &v.front());
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#if __cplusplus >= 201103L
+ {
+ const std::vector<int, min_allocator<int>> v;
+ assert(v.data() == 0);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ const std::vector<int, min_allocator<int>> v(100);
+ assert(v.data() == &v.front());
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp
new file mode 100644
index 00000000000..8af6bdacd0a
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class... Args> iterator emplace(const_iterator pos, Args&&... args);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+class A
+{
+ int i_;
+ double d_;
+
+ A(const A&);
+ A& operator=(const A&);
+public:
+ A(int i, double d)
+ : i_(i), d_(d) {}
+
+ A(A&& a)
+ : i_(a.i_),
+ d_(a.d_)
+ {
+ a.i_ = 0;
+ a.d_ = 0;
+ }
+
+ A& operator=(A&& a)
+ {
+ i_ = a.i_;
+ d_ = a.d_;
+ a.i_ = 0;
+ a.d_ = 0;
+ return *this;
+ }
+
+ int geti() const {return i_;}
+ double getd() const {return d_;}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<A> c;
+ std::vector<A>::iterator i = c.emplace(c.cbegin(), 2, 3.5);
+ assert(i == c.begin());
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(is_contiguous_container_asan_correct(c));
+ i = c.emplace(c.cend(), 3, 4.5);
+ assert(i == c.end()-1);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ assert(is_contiguous_container_asan_correct(c));
+ i = c.emplace(c.cbegin()+1, 4, 6.5);
+ assert(i == c.begin()+1);
+ assert(c.size() == 3);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c[1].geti() == 4);
+ assert(c[1].getd() == 6.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ assert(is_contiguous_container_asan_correct(c));
+ }
+ {
+ std::vector<A, stack_allocator<A, 7> > c;
+ std::vector<A, stack_allocator<A, 7> >::iterator i = c.emplace(c.cbegin(), 2, 3.5);
+ assert(i == c.begin());
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(is_contiguous_container_asan_correct(c));
+ i = c.emplace(c.cend(), 3, 4.5);
+ assert(i == c.end()-1);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ assert(is_contiguous_container_asan_correct(c));
+ i = c.emplace(c.cbegin()+1, 4, 6.5);
+ assert(i == c.begin()+1);
+ assert(c.size() == 3);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c[1].geti() == 4);
+ assert(c[1].getd() == 6.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ assert(is_contiguous_container_asan_correct(c));
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<A> c1;
+ std::vector<A> c2;
+ std::vector<A>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::vector<A, min_allocator<A>> c;
+ std::vector<A, min_allocator<A>>::iterator i = c.emplace(c.cbegin(), 2, 3.5);
+ assert(i == c.begin());
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ i = c.emplace(c.cend(), 3, 4.5);
+ assert(i == c.end()-1);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ i = c.emplace(c.cbegin()+1, 4, 6.5);
+ assert(i == c.begin()+1);
+ assert(c.size() == 3);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c[1].geti() == 4);
+ assert(c[1].getd() == 6.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<A, min_allocator<A>> c1;
+ std::vector<A, min_allocator<A>> c2;
+ std::vector<A, min_allocator<A>>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5);
+ assert(false);
+ }
+#endif
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp
new file mode 100644
index 00000000000..bbf91a4255d
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_back.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class... Args> void emplace_back(Args&&... args);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+class A
+{
+ int i_;
+ double d_;
+
+ A(const A&);
+ A& operator=(const A&);
+public:
+ A(int i, double d)
+ : i_(i), d_(d) {}
+
+ A(A&& a)
+ : i_(a.i_),
+ d_(a.d_)
+ {
+ a.i_ = 0;
+ a.d_ = 0;
+ }
+
+ A& operator=(A&& a)
+ {
+ i_ = a.i_;
+ d_ = a.d_;
+ a.i_ = 0;
+ a.d_ = 0;
+ return *this;
+ }
+
+ int geti() const {return i_;}
+ double getd() const {return d_;}
+};
+
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<A> c;
+ c.emplace_back(2, 3.5);
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(is_contiguous_container_asan_correct(c));
+ c.emplace_back(3, 4.5);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ assert(is_contiguous_container_asan_correct(c));
+ }
+ {
+ std::vector<A, stack_allocator<A, 4> > c;
+ c.emplace_back(2, 3.5);
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(is_contiguous_container_asan_correct(c));
+ c.emplace_back(3, 4.5);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ assert(is_contiguous_container_asan_correct(c));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<A, min_allocator<A>> c;
+ c.emplace_back(2, 3.5);
+ assert(c.size() == 1);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(is_contiguous_container_asan_correct(c));
+ c.emplace_back(3, 4.5);
+ assert(c.size() == 2);
+ assert(c.front().geti() == 2);
+ assert(c.front().getd() == 3.5);
+ assert(c.back().geti() == 3);
+ assert(c.back().getd() == 4.5);
+ assert(is_contiguous_container_asan_correct(c));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp
new file mode 100644
index 00000000000..85a47073bcb
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class... Args> iterator emplace(const_iterator pos, Args&&... args);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<int> v;
+ v.reserve(3);
+ assert(is_contiguous_container_asan_correct(v));
+ v = { 1, 2, 3 };
+ v.emplace(v.begin(), v.back());
+ assert(v[0] == 3);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int> v;
+ v.reserve(4);
+ assert(is_contiguous_container_asan_correct(v));
+ v = { 1, 2, 3 };
+ v.emplace(v.begin(), v.back());
+ assert(v[0] == 3);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v;
+ v.reserve(3);
+ assert(is_contiguous_container_asan_correct(v));
+ v = { 1, 2, 3 };
+ v.emplace(v.begin(), v.back());
+ assert(v[0] == 3);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+ {
+ std::vector<int, min_allocator<int>> v;
+ v.reserve(4);
+ assert(is_contiguous_container_asan_correct(v));
+ v = { 1, 2, 3 };
+ v.emplace(v.begin(), v.back());
+ assert(v[0] == 3);
+ assert(is_contiguous_container_asan_correct(v));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp
new file mode 100644
index 00000000000..7a850edda27
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator erase(const_iterator position);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int> l1(a1, a1+3);
+ std::vector<int>::const_iterator i = l1.begin();
+ assert(is_contiguous_container_asan_correct(l1));
+ ++i;
+ std::vector<int>::iterator j = l1.erase(i);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(*j == 3);
+ assert(*l1.begin() == 1);
+ assert(*next(l1.begin()) == 3);
+ assert(is_contiguous_container_asan_correct(l1));
+ j = l1.erase(j);
+ assert(j == l1.end());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(*l1.begin() == 1);
+ assert(is_contiguous_container_asan_correct(l1));
+ j = l1.erase(l1.begin());
+ assert(j == l1.end());
+ assert(l1.size() == 0);
+ assert(distance(l1.begin(), l1.end()) == 0);
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ std::vector<int, min_allocator<int>>::const_iterator i = l1.begin();
+ assert(is_contiguous_container_asan_correct(l1));
+ ++i;
+ std::vector<int, min_allocator<int>>::iterator j = l1.erase(i);
+ assert(l1.size() == 2);
+ assert(distance(l1.begin(), l1.end()) == 2);
+ assert(*j == 3);
+ assert(*l1.begin() == 1);
+ assert(*next(l1.begin()) == 3);
+ assert(is_contiguous_container_asan_correct(l1));
+ j = l1.erase(j);
+ assert(j == l1.end());
+ assert(l1.size() == 1);
+ assert(distance(l1.begin(), l1.end()) == 1);
+ assert(*l1.begin() == 1);
+ assert(is_contiguous_container_asan_correct(l1));
+ j = l1.erase(l1.begin());
+ assert(j == l1.end());
+ assert(l1.size() == 0);
+ assert(distance(l1.begin(), l1.end()) == 0);
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp
new file mode 100644
index 00000000000..0478d24c79f
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db1.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int> l1(a1, a1+3);
+ std::vector<int>::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ std::vector<int, min_allocator<int>>::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp
new file mode 100644
index 00000000000..c394f197402
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db2.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int> l1(a1, a1+3);
+ std::vector<int> l2(a1, a1+3);
+ std::vector<int>::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ std::vector<int, min_allocator<int>> l2(a1, a1+3);
+ std::vector<int, min_allocator<int>>::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp
new file mode 100644
index 00000000000..bfc18bc4864
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator erase(const_iterator first, const_iterator last);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ int a1[] = {1, 2, 3};
+ {
+ std::vector<int> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+ assert(l1.size() == 3);
+ assert(distance(l1.cbegin(), l1.cend()) == 3);
+ assert(i == l1.begin());
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<int> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.cbegin(), l1.cend()) == 2);
+ assert(i == l1.begin());
+ assert(l1 == std::vector<int>(a1+1, a1+3));
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<int> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+ assert(l1.size() == 1);
+ assert(distance(l1.cbegin(), l1.cend()) == 1);
+ assert(i == l1.begin());
+ assert(l1 == std::vector<int>(a1+2, a1+3));
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<int> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+ assert(l1.size() == 0);
+ assert(distance(l1.cbegin(), l1.cend()) == 0);
+ assert(i == l1.begin());
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<std::vector<int> > outer(2, std::vector<int>(1));
+ assert(is_contiguous_container_asan_correct(outer));
+ assert(is_contiguous_container_asan_correct(outer[0]));
+ assert(is_contiguous_container_asan_correct(outer[1]));
+ outer.erase(outer.begin(), outer.begin());
+ assert(outer.size() == 2);
+ assert(outer[0].size() == 1);
+ assert(outer[1].size() == 1);
+ assert(is_contiguous_container_asan_correct(outer));
+ assert(is_contiguous_container_asan_correct(outer[0]));
+ assert(is_contiguous_container_asan_correct(outer[1]));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), l1.cbegin());
+ assert(l1.size() == 3);
+ assert(distance(l1.cbegin(), l1.cend()) == 3);
+ assert(i == l1.begin());
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin()));
+ assert(l1.size() == 2);
+ assert(distance(l1.cbegin(), l1.cend()) == 2);
+ assert(i == l1.begin());
+ assert((l1 == std::vector<int, min_allocator<int>>(a1+1, a1+3)));
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2));
+ assert(l1.size() == 1);
+ assert(distance(l1.cbegin(), l1.cend()) == 1);
+ assert(i == l1.begin());
+ assert((l1 == std::vector<int, min_allocator<int>>(a1+2, a1+3)));
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ assert(is_contiguous_container_asan_correct(l1));
+ std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3));
+ assert(l1.size() == 0);
+ assert(distance(l1.cbegin(), l1.cend()) == 0);
+ assert(i == l1.begin());
+ assert(is_contiguous_container_asan_correct(l1));
+ }
+ {
+ std::vector<std::vector<int, min_allocator<int>>, min_allocator<std::vector<int, min_allocator<int>>>> outer(2, std::vector<int, min_allocator<int>>(1));
+ assert(is_contiguous_container_asan_correct(outer));
+ assert(is_contiguous_container_asan_correct(outer[0]));
+ assert(is_contiguous_container_asan_correct(outer[1]));
+ outer.erase(outer.begin(), outer.begin());
+ assert(outer.size() == 2);
+ assert(outer[0].size() == 1);
+ assert(outer[1].size() == 1);
+ assert(is_contiguous_container_asan_correct(outer));
+ assert(is_contiguous_container_asan_correct(outer[0]));
+ assert(is_contiguous_container_asan_correct(outer[1]));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp
new file mode 100644
index 00000000000..af6d0f75789
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int> l1(a1, a1+3);
+ std::vector<int> l2(a1, a1+3);
+ std::vector<int>::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ std::vector<int, min_allocator<int>> l2(a1, a1+3);
+ std::vector<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp
new file mode 100644
index 00000000000..eee2c66c5c8
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int> l1(a1, a1+3);
+ std::vector<int> l2(a1, a1+3);
+ std::vector<int>::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ std::vector<int, min_allocator<int>> l2(a1, a1+3);
+ std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp
new file mode 100644
index 00000000000..505067d05a1
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int> l1(a1, a1+3);
+ std::vector<int> l2(a1, a1+3);
+ std::vector<int>::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ std::vector<int, min_allocator<int>> l2(a1, a1+3);
+ std::vector<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1);
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp
new file mode 100644
index 00000000000..c7e4131cb49
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <vector>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int> l1(a1, a1+3);
+ std::vector<int>::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 2, 3};
+ std::vector<int, min_allocator<int>> l1(a1, a1+3);
+ std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin());
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp
new file mode 100644
index 00000000000..30b80178801
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator insert(const_iterator p, initializer_list<value_type> il);
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ std::vector<int> d(10, 1);
+ std::vector<int>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
+ assert(d.size() == 14);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(i == d.begin() + 2);
+ assert(d[0] == 1);
+ assert(d[1] == 1);
+ assert(d[2] == 3);
+ assert(d[3] == 4);
+ assert(d[4] == 5);
+ assert(d[5] == 6);
+ assert(d[6] == 1);
+ assert(d[7] == 1);
+ assert(d[8] == 1);
+ assert(d[9] == 1);
+ assert(d[10] == 1);
+ assert(d[11] == 1);
+ assert(d[12] == 1);
+ assert(d[13] == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> d(10, 1);
+ std::vector<int, min_allocator<int>>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6});
+ assert(d.size() == 14);
+ assert(is_contiguous_container_asan_correct(d));
+ assert(i == d.begin() + 2);
+ assert(d[0] == 1);
+ assert(d[1] == 1);
+ assert(d[2] == 3);
+ assert(d[3] == 4);
+ assert(d[4] == 5);
+ assert(d[5] == 6);
+ assert(d[6] == 1);
+ assert(d[7] == 1);
+ assert(d[8] == 1);
+ assert(d[9] == 1);
+ assert(d[10] == 1);
+ assert(d[11] == 1);
+ assert(d[12] == 1);
+ assert(d[13] == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp
new file mode 100644
index 00000000000..782437be87f
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class Iter>
+// iterator insert(const_iterator position, Iter first, Iter last);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "test_iterators.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const int*>(a),
+ input_iterator<const int*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int> v(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
+ forward_iterator<const int*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int> v(100);
+ while(v.size() < v.capacity()) v.push_back(0); // force reallocation
+ size_t sz = v.size();
+ int a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
+ forward_iterator<const int*>(a+N));
+ assert(v.size() == sz + N);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int> v(100);
+ v.reserve(128); // force no reallocation
+ size_t sz = v.size();
+ int a[] = {1, 2, 3, 4, 5};
+ const unsigned N = sizeof(a)/sizeof(a[0]);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
+ forward_iterator<const int*>(a+N));
+ assert(v.size() == sz + N);
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int, stack_allocator<int, 308> > v(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const int*>(a),
+ input_iterator<const int*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int, stack_allocator<int, 300> > v(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
+ forward_iterator<const int*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int> v(100);
+ std::vector<int> v2(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int>::iterator i = v.insert(v2.cbegin() + 10, input_iterator<const int*>(a),
+ input_iterator<const int*>(a+N));
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const int*>(a),
+ input_iterator<const int*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a),
+ forward_iterator<const int*>(a+N));
+ assert(v.size() == 100 + N);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (int k = 0; k < N; ++j, ++k)
+ assert(v[j] == a[k]);
+ for (; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ std::vector<int, min_allocator<int>> v2(100);
+ int a[] = {1, 2, 3, 4, 5};
+ const int N = sizeof(a)/sizeof(a[0]);
+ std::vector<int, min_allocator<int>>::iterator i = v.insert(v2.cbegin() + 10, input_iterator<const int*>(a),
+ input_iterator<const int*>(a+N));
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp
new file mode 100644
index 00000000000..cf3715ccb6f
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator insert(const_iterator position, value_type&& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<MoveOnly> v(100);
+ std::vector<MoveOnly>::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == MoveOnly());
+ assert(v[j] == MoveOnly(3));
+ for (++j; j < 101; ++j)
+ assert(v[j] == MoveOnly());
+ }
+ {
+ std::vector<MoveOnly, stack_allocator<MoveOnly, 300> > v(100);
+ std::vector<MoveOnly, stack_allocator<MoveOnly, 300> >::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == MoveOnly());
+ assert(v[j] == MoveOnly(3));
+ for (++j; j < 101; ++j)
+ assert(v[j] == MoveOnly());
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int> v1(3);
+ std::vector<int> v2(3);
+ v1.insert(v2.begin(), 4);
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::vector<MoveOnly, min_allocator<MoveOnly>> v(100);
+ std::vector<MoveOnly, min_allocator<MoveOnly>>::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3));
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == MoveOnly());
+ assert(v[j] == MoveOnly(3));
+ for (++j; j < 101; ++j)
+ assert(v[j] == MoveOnly());
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int, min_allocator<int>> v1(3);
+ std::vector<int, min_allocator<int>> v2(3);
+ v1.insert(v2.begin(), 4);
+ assert(false);
+ }
+#endif
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp
new file mode 100644
index 00000000000..6997284f258
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator insert(const_iterator position, size_type n, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v(100);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == 105);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int> v(100);
+ while(v.size() < v.capacity()) v.push_back(0); // force reallocation
+ size_t sz = v.size();
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == sz + 5);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int> v(100);
+ v.reserve(128); // force no reallocation
+ size_t sz = v.size();
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == sz + 5);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int, stack_allocator<int, 300> > v(100);
+ std::vector<int, stack_allocator<int, 300> >::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == 105);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int> c1(100);
+ std::vector<int> c2;
+ std::vector<int>::iterator i = c1.insert(c2.cbegin() + 10, 5, 1);
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == 105);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, 5, 1);
+ assert(v.size() == 105);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ for (; j < 15; ++j)
+ assert(v[j] == 1);
+ for (++j; j < 105; ++j)
+ assert(v[j] == 0);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int, min_allocator<int>> c1(100);
+ std::vector<int, min_allocator<int>> c2;
+ std::vector<int, min_allocator<int>>::iterator i = c1.insert(c2.cbegin() + 10, 5, 1);
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp
new file mode 100644
index 00000000000..782e752157a
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp
@@ -0,0 +1,116 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// iterator insert(const_iterator position, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> v(100);
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < 101; ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int> v(100);
+ while(v.size() < v.capacity()) v.push_back(0); // force reallocation
+ size_t sz = v.size();
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == sz + 1);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int> v(100);
+ while(v.size() < v.capacity()) v.push_back(0);
+ v.pop_back(); v.pop_back(); // force no reallocation
+ size_t sz = v.size();
+ std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == sz + 1);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < v.size(); ++j)
+ assert(v[j] == 0);
+ }
+ {
+ std::vector<int, stack_allocator<int, 300> > v(100);
+ std::vector<int, stack_allocator<int, 300> >::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < 101; ++j)
+ assert(v[j] == 0);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int> v1(3);
+ std::vector<int> v2(3);
+ int i = 4;
+ v1.insert(v2.begin(), i);
+ assert(false);
+ }
+#endif
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> v(100);
+ std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, 1);
+ assert(v.size() == 101);
+ assert(is_contiguous_container_asan_correct(v));
+ assert(i == v.begin() + 10);
+ int j;
+ for (j = 0; j < 10; ++j)
+ assert(v[j] == 0);
+ assert(v[j] == 1);
+ for (++j; j < 101; ++j)
+ assert(v[j] == 0);
+ }
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::vector<int, min_allocator<int>> v1(3);
+ std::vector<int, min_allocator<int>> v2(3);
+ int i = 4;
+ v1.insert(v2.begin(), i);
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp
new file mode 100644
index 00000000000..62fa60103ba
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/pop_back.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void pop_back();
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+
+#if _LIBCPP_DEBUG >= 1
+#include <cstdlib>
+#include <exception>
+
+#endif
+
+int main()
+{
+ {
+ std::vector<int> c;
+ c.push_back(1);
+ assert(c.size() == 1);
+ c.pop_back();
+ assert(c.size() == 0);
+#if _LIBCPP_DEBUG >= 1
+ c.pop_back();
+ assert(false);
+#endif
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> c;
+ c.push_back(1);
+ assert(c.size() == 1);
+ c.pop_back();
+ assert(c.size() == 0);
+#if _LIBCPP_DEBUG >= 1
+ c.pop_back();
+ assert(false);
+#endif
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp
new file mode 100644
index 00000000000..eeeba6242d9
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void push_back(const value_type& x);
+
+#include <vector>
+#include <cassert>
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ std::vector<int> c;
+ c.push_back(0);
+ assert(c.size() == 1);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(1);
+ assert(c.size() == 2);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(2);
+ assert(c.size() == 3);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(3);
+ assert(c.size() == 4);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(4);
+ assert(c.size() == 5);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ }
+ {
+ std::vector<int, stack_allocator<int, 15> > c;
+ c.push_back(0);
+ assert(c.size() == 1);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(1);
+ assert(c.size() == 2);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(2);
+ assert(c.size() == 3);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(3);
+ assert(c.size() == 4);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(4);
+ assert(c.size() == 5);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<int, min_allocator<int>> c;
+ c.push_back(0);
+ assert(c.size() == 1);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(1);
+ assert(c.size() == 2);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(2);
+ assert(c.size() == 3);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(3);
+ assert(c.size() == 4);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ c.push_back(4);
+ assert(c.size() == 5);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == j);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp
new file mode 100644
index 00000000000..6615a25a620
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void push_back(const value_type& x);
+
+#include <vector>
+#include <cassert>
+
+#include "asan_testing.h"
+
+// Flag that makes the copy constructor for CMyClass throw an exception
+static bool gCopyConstructorShouldThow = false;
+
+
+class CMyClass {
+ public: CMyClass(int tag);
+ public: CMyClass(const CMyClass& iOther);
+ public: ~CMyClass();
+
+ bool equal(const CMyClass &rhs) const
+ { return fTag == rhs.fTag && fMagicValue == rhs.fMagicValue; }
+ private:
+ int fMagicValue;
+ int fTag;
+
+ private: static int kStartedConstructionMagicValue;
+ private: static int kFinishedConstructionMagicValue;
+};
+
+// Value for fMagicValue when the constructor has started running, but not yet finished
+int CMyClass::kStartedConstructionMagicValue = 0;
+// Value for fMagicValue when the constructor has finished running
+int CMyClass::kFinishedConstructionMagicValue = 12345;
+
+CMyClass::CMyClass(int tag) :
+ fMagicValue(kStartedConstructionMagicValue), fTag(tag)
+{
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::CMyClass(const CMyClass& iOther) :
+ fMagicValue(kStartedConstructionMagicValue), fTag(iOther.fTag)
+{
+ // If requested, throw an exception _before_ setting fMagicValue to kFinishedConstructionMagicValue
+ if (gCopyConstructorShouldThow) {
+ throw std::exception();
+ }
+ // Signal that the constructor has finished running
+ fMagicValue = kFinishedConstructionMagicValue;
+}
+
+CMyClass::~CMyClass() {
+ // Only instances for which the constructor has finished running should be destructed
+ assert(fMagicValue == kFinishedConstructionMagicValue);
+}
+
+bool operator==(const CMyClass &lhs, const CMyClass &rhs) { return lhs.equal(rhs); }
+
+int main()
+{
+ CMyClass instance(42);
+ std::vector<CMyClass> vec;
+
+ vec.push_back(instance);
+ std::vector<CMyClass> vec2(vec);
+ assert(is_contiguous_container_asan_correct(vec));
+ assert(is_contiguous_container_asan_correct(vec2));
+
+ gCopyConstructorShouldThow = true;
+ try {
+ vec.push_back(instance);
+ }
+ catch (...) {
+ assert(vec==vec2);
+ assert(is_contiguous_container_asan_correct(vec));
+ }
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
new file mode 100644
index 00000000000..be488931263
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void push_back(value_type&& x);
+
+#include <vector>
+#include <cassert>
+#include "../../../MoveOnly.h"
+#include "../../../stack_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ std::vector<MoveOnly> c;
+ c.push_back(MoveOnly(0));
+ assert(c.size() == 1);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(1));
+ assert(c.size() == 2);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(2));
+ assert(c.size() == 3);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(3));
+ assert(c.size() == 4);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(4));
+ assert(c.size() == 5);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ }
+ {
+ std::vector<MoveOnly, stack_allocator<MoveOnly, 15> > c;
+ c.push_back(MoveOnly(0));
+ assert(c.size() == 1);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(1));
+ assert(c.size() == 2);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(2));
+ assert(c.size() == 3);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(3));
+ assert(c.size() == 4);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(4));
+ assert(c.size() == 5);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ }
+#if __cplusplus >= 201103L
+ {
+ std::vector<MoveOnly, min_allocator<MoveOnly>> c;
+ c.push_back(MoveOnly(0));
+ assert(c.size() == 1);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(1));
+ assert(c.size() == 2);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(2));
+ assert(c.size() == 3);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(3));
+ assert(c.size() == 4);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ c.push_back(MoveOnly(4));
+ assert(c.size() == 5);
+ assert(is_contiguous_container_asan_correct(c));
+ for (int j = 0; j < c.size(); ++j)
+ assert(c[j] == MoveOnly(j));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.special/db_swap_1.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.special/db_swap_1.pass.cpp
new file mode 100644
index 00000000000..e7f6a0011e1
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.special/db_swap_1.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class T, class Alloc>
+// void swap(vector<T,Alloc>& x, vector<T,Alloc>& y);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <vector>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::vector<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::vector<int>::iterator i1 = c1.begin();
+ std::vector<int>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ c2.erase(i1);
+ c1.erase(i1);
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::vector<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::vector<int, min_allocator<int>>::iterator i1 = c1.begin();
+ std::vector<int, min_allocator<int>>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ c2.erase(i1);
+ c1.erase(i1);
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.special/swap.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.special/swap.pass.cpp
new file mode 100644
index 00000000000..27001aef744
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.special/swap.pass.cpp
@@ -0,0 +1,187 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// template <class T, class Alloc>
+// void swap(vector<T,Alloc>& x, vector<T,Alloc>& y);
+
+#include <vector>
+#include <cassert>
+#include "test_allocator.h"
+#include "min_allocator.h"
+#include "asan_testing.h"
+
+int main()
+{
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::vector<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert(c1 == std::vector<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+ assert(c2 == std::vector<int>(a1, a1+sizeof(a1)/sizeof(a1[0])));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int> c1(a1, a1);
+ std::vector<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert(c1 == std::vector<int>(a2, a2+sizeof(a2)/sizeof(a2[0])));
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::vector<int> c2(a2, a2);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c2 == std::vector<int>(a1, a1+sizeof(a1)/sizeof(a1[0])));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int> c1(a1, a1);
+ std::vector<int> c2(a2, a2);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+#ifndef _LIBCPP_DEBUG_LEVEL
+// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef test_allocator<int> A;
+ std::vector<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+ std::vector<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+ swap(c1, c2);
+ assert((c1 == std::vector<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A(1));
+ assert((c2 == std::vector<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A(2));
+ }
+#endif
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef other_allocator<int> A;
+ std::vector<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1));
+ std::vector<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert((c1 == std::vector<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A(2));
+ assert((c2 == std::vector<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A(1));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+#if __cplusplus >= 201103L
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::vector<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert((c1 == std::vector<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert((c2 == std::vector<int, min_allocator<int>>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int, min_allocator<int>> c1(a1, a1);
+ std::vector<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert((c1 == std::vector<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::vector<int, min_allocator<int>> c2(a2, a2);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert((c2 == std::vector<int, min_allocator<int>>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::vector<int, min_allocator<int>> c1(a1, a1);
+ std::vector<int, min_allocator<int>> c2(a2, a2);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert(c1.empty());
+ assert(distance(c1.begin(), c1.end()) == 0);
+ assert(c2.empty());
+ assert(distance(c2.begin(), c2.end()) == 0);
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+#ifndef _LIBCPP_DEBUG_LEVEL
+// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ typedef min_allocator<int> A;
+ std::vector<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A());
+ std::vector<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A());
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ swap(c1, c2);
+ assert((c1 == std::vector<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0]))));
+ assert(c1.get_allocator() == A());
+ assert((c2 == std::vector<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0]))));
+ assert(c2.get_allocator() == A());
+ assert(is_contiguous_container_asan_correct(c1));
+ assert(is_contiguous_container_asan_correct(c2));
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp b/libcxx/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp
new file mode 100644
index 00000000000..996712a33aa
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/vector.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+// void swap(vector& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <vector>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+
+template <class T>
+struct some_alloc
+{
+ typedef T value_type;
+
+ some_alloc() {}
+ some_alloc(const some_alloc&);
+ void deallocate(void*, unsigned) {}
+
+ typedef std::true_type propagate_on_container_swap;
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::vector<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/sequences/vector/version.pass.cpp b/libcxx/test/std/containers/sequences/vector/version.pass.cpp
new file mode 100644
index 00000000000..2c4fa1263de
--- /dev/null
+++ b/libcxx/test/std/containers/sequences/vector/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <vector>
+
+#include <vector>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/stack_allocator.h b/libcxx/test/std/containers/stack_allocator.h
new file mode 100644
index 00000000000..d5fab025c9d
--- /dev/null
+++ b/libcxx/test/std/containers/stack_allocator.h
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef STACK_ALLOCATOR_H
+#define STACK_ALLOCATOR_H
+
+#include <cstddef>
+#include <new>
+
+template <class T, std::size_t N>
+class stack_allocator
+{
+ char buf_[sizeof(T)*N];
+ char* ptr_;
+public:
+ typedef T value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef std::size_t size_type;
+ typedef std::ptrdiff_t difference_type;
+
+ template <class U> struct rebind {typedef stack_allocator<U, N> other;};
+
+ stack_allocator() : ptr_(buf_) {}
+
+private:
+ stack_allocator(const stack_allocator&);// = delete;
+ stack_allocator& operator=(const stack_allocator&);// = delete;
+
+public:
+ pointer allocate(size_type n, const void* = 0)
+ {
+ if (n > N - (ptr_ - buf_) / sizeof(value_type)) {
+#ifndef _LIBCPP_NO_EXCEPTIONS
+ throw std::bad_alloc();
+#else
+ std::terminate();
+#endif
+ }
+ pointer r = (T*)ptr_;
+ ptr_ += n * sizeof(T);
+ return r;
+ }
+ void deallocate(pointer p, size_type n)
+ {
+ if ((char*)(p + n) == ptr_)
+ ptr_ = (char*)p;
+ }
+
+ size_type max_size() const {return N;}
+};
+
+template <class T, std::size_t N>
+inline
+void
+swap(stack_allocator<T, N>& x, stack_allocator<T, N>& y) {}
+
+#endif // STACK_ALLOCATOR_H
diff --git a/libcxx/test/std/containers/test_compare.h b/libcxx/test/std/containers/test_compare.h
new file mode 100644
index 00000000000..9c54799172e
--- /dev/null
+++ b/libcxx/test/std/containers/test_compare.h
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TEST_COMPARE_H
+#define TEST_COMPARE_H
+
+#include <cstddef>
+#include <type_traits>
+#include <cstdlib>
+#include <new>
+#include <climits>
+
+template <class C>
+class test_compare
+ : private C
+{
+ int data_;
+public:
+ explicit test_compare(int data = 0) : data_(data) {}
+
+ typename C::result_type
+ operator()(typename std::add_lvalue_reference<const typename C::first_argument_type>::type x,
+ typename std::add_lvalue_reference<const typename C::second_argument_type>::type y) const
+ {return C::operator()(x, y);}
+
+ bool operator==(const test_compare& c) const
+ {return data_ == c.data_;}
+};
+
+#endif // TEST_COMPARE_H
diff --git a/libcxx/test/std/containers/test_hash.h b/libcxx/test/std/containers/test_hash.h
new file mode 100644
index 00000000000..1a70e7cbdd9
--- /dev/null
+++ b/libcxx/test/std/containers/test_hash.h
@@ -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.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TEST_HASH_H
+#define TEST_HASH_H
+
+#include <cstddef>
+#include <type_traits>
+
+template <class C>
+class test_hash
+ : private C
+{
+ int data_;
+public:
+ explicit test_hash(int data = 0) : data_(data) {}
+
+ std::size_t
+ operator()(typename std::add_lvalue_reference<const typename C::argument_type>::type x) const
+ {return C::operator()(x);}
+
+ bool operator==(const test_hash& c) const
+ {return data_ == c.data_;}
+};
+
+#endif // TEST_HASH_H
diff --git a/libcxx/test/std/containers/unord/next_prime.pass.cpp b/libcxx/test/std/containers/unord/next_prime.pass.cpp
new file mode 100644
index 00000000000..266d7f1f9d1
--- /dev/null
+++ b/libcxx/test/std/containers/unord/next_prime.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.
+//
+//===----------------------------------------------------------------------===//
+//
+// REQUIRES: long_tests
+
+// Not a portable test
+
+// <__hash_table>
+
+// size_t __next_prime(size_t n);
+
+// If n == 0, return 0, else return the lowest prime greater than or equal to n
+
+#include <__hash_table>
+#include <cassert>
+
+bool
+is_prime(size_t n)
+{
+ switch (n)
+ {
+ case 0:
+ case 1:
+ return false;
+ }
+ for (size_t i = 2; i*i <= n; ++i)
+ {
+ if (n % i == 0)
+ return false;
+ }
+ return true;
+}
+
+int main()
+{
+ assert(std::__next_prime(0) == 0);
+ for (std::size_t n = 1; n <= 100000; ++n)
+ {
+ std::size_t p = std::__next_prime(n);
+ assert(p >= n);
+ for (std::size_t i = n; i < p; ++i)
+ assert(!is_prime(i));
+ assert(is_prime(p));
+ }
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/bucket.pass.cpp b/libcxx/test/std/containers/unord/unord.map/bucket.pass.cpp
new file mode 100644
index 00000000000..6837294e35b
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/bucket.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type bucket(const key_type& __k) const;
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ size_t bc = c.bucket_count();
+ assert(bc >= 5);
+ for (size_t i = 0; i < 13; ++i)
+ assert(c.bucket(i) == i % bc);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ size_t bc = c.bucket_count();
+ assert(bc >= 5);
+ for (size_t i = 0; i < 13; ++i)
+ assert(c.bucket(i) == i % bc);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c;
+ C::size_type i = c.bucket(3);
+ assert(false);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/bucket_count.pass.cpp b/libcxx/test/std/containers/unord/unord.map/bucket_count.pass.cpp
new file mode 100644
index 00000000000..d3e80d86379
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/bucket_count.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type bucket_count() const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.bucket_count() == 0);
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 11);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.bucket_count() == 0);
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 11);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/bucket_size.pass.cpp b/libcxx/test/std/containers/unord/unord.map/bucket_size.pass.cpp
new file mode 100644
index 00000000000..f3ab8fff4e4
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/bucket_size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type bucket_size(size_type n) const
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 5);
+ assert(c.bucket_size(0) == 0);
+ assert(c.bucket_size(1) == 1);
+ assert(c.bucket_size(2) == 1);
+ assert(c.bucket_size(3) == 1);
+ assert(c.bucket_size(4) == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 5);
+ assert(c.bucket_size(0) == 0);
+ assert(c.bucket_size(1) == 1);
+ assert(c.bucket_size(2) == 1);
+ assert(c.bucket_size(3) == 1);
+ assert(c.bucket_size(4) == 1);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c;
+ C::size_type i = c.bucket_size(3);
+ assert(false);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/compare.pass.cpp b/libcxx/test/std/containers/unord/unord.map/compare.pass.cpp
new file mode 100644
index 00000000000..8979a3a34ad
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/compare.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// http://llvm.org/bugs/show_bug.cgi?id=16538
+// http://llvm.org/bugs/show_bug.cgi?id=16549
+
+#include <unordered_map>
+
+struct Key {
+ template <typename T> Key(const T&) {}
+ bool operator== (const Key&) const { return true; }
+};
+
+namespace std
+{
+ template <>
+ struct hash<Key>
+ {
+ size_t operator()(Key const &) const {return 0;}
+ };
+}
+
+int
+main()
+{
+ std::unordered_map<Key, int>::iterator it =
+ std::unordered_map<Key, int>().find(Key(0));
+ std::pair<std::unordered_map<Key, int>::iterator, bool> result =
+ std::unordered_map<Key, int>().insert(std::make_pair(Key(0), 0));
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/count.pass.cpp b/libcxx/test/std/containers/unord/unord.map/count.pass.cpp
new file mode 100644
index 00000000000..50abb53464e
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/count.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type count(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.count(30) == 1);
+ assert(c.count(5) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.count(30) == 1);
+ assert(c.count(5) == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/db_iterators_7.pass.cpp b/libcxx/test/std/containers/unord/unord.map/db_iterators_7.pass.cpp
new file mode 100644
index 00000000000..b8db0a35ffc
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/db_iterators_7.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.map/db_iterators_8.pass.cpp b/libcxx/test/std/containers/unord/unord.map/db_iterators_8.pass.cpp
new file mode 100644
index 00000000000..c923dd77862
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/db_iterators_8.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.end();
+ C::value_type j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.end();
+ C::value_type j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.map/db_local_iterators_7.pass.cpp b/libcxx/test/std/containers/unord/unord.map/db_local_iterators_7.pass.cpp
new file mode 100644
index 00000000000..fa1886bfff1
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/db_local_iterators_7.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Increment local_iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c(1);
+ C::local_iterator i = c.begin(0);
+ ++i;
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c(1);
+ C::local_iterator i = c.begin(0);
+ ++i;
+ ++i;
+ assert(false);
+ }
+#endif
+
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.map/db_local_iterators_8.pass.cpp b/libcxx/test/std/containers/unord/unord.map/db_local_iterators_8.pass.cpp
new file mode 100644
index 00000000000..4b071cad7b4
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/db_local_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c(1);
+ C::local_iterator i = c.end(0);
+ C::value_type j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c(1);
+ C::local_iterator i = c.end(0);
+ C::value_type j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.map/eq.pass.cpp b/libcxx/test/std/containers/unord/unord.map/eq.pass.cpp
new file mode 100644
index 00000000000..9258378eb09
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/eq.pass.cpp
@@ -0,0 +1,163 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash, class Pred, class Alloc>
+// bool
+// operator==(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
+// const unordered_map<Key, T, Hash, Pred, Alloc>& y);
+//
+// template <class Key, class T, class Hash, class Pred, class Alloc>
+// bool
+// operator!=(const unordered_map<Key, T, Hash, Pred, Alloc>& x,
+// const unordered_map<Key, T, Hash, Pred, Alloc>& y);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2;
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2 = c1;
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a), std::end(a));
+ C c2 = c1;
+ c2.rehash(30);
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ c2.insert(P(90, "ninety"));
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ c1.insert(P(90, "ninety"));
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2;
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2 = c1;
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a), std::end(a));
+ C c2 = c1;
+ c2.rehash(30);
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ c2.insert(P(90, "ninety"));
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ c1.insert(P(90, "ninety"));
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/equal_range_const.pass.cpp b/libcxx/test/std/containers/unord/unord.map/equal_range_const.pass.cpp
new file mode 100644
index 00000000000..fe166c965b1
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/equal_range_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/equal_range_non_const.pass.cpp b/libcxx/test/std/containers/unord/unord.map/equal_range_non_const.pass.cpp
new file mode 100644
index 00000000000..9e8d1a9644c
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/equal_range_non_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// pair<iterator, iterator> equal_range(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef C::iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/find_const.pass.cpp b/libcxx/test/std/containers/unord/unord.map/find_const.pass.cpp
new file mode 100644
index 00000000000..120efa3061b
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/find_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// const_iterator find(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ C::const_iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ C::const_iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/find_non_const.pass.cpp b/libcxx/test/std/containers/unord/unord.map/find_non_const.pass.cpp
new file mode 100644
index 00000000000..7582a796dd7
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/find_non_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator find(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ C::iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ C::iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.end());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/iterators.pass.cpp b/libcxx/test/std/containers/unord/unord.map/iterators.pass.cpp
new file mode 100644
index 00000000000..47b1d738668
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/iterators.pass.cpp
@@ -0,0 +1,128 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator begin() {return __table_.begin();}
+// iterator end() {return __table_.end();}
+// const_iterator begin() const {return __table_.begin();}
+// const_iterator end() const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend() const {return __table_.end();}
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i;
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::const_iterator i;
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i;
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::const_iterator i;
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::unordered_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/unord/unord.map/load_factor.pass.cpp b/libcxx/test/std/containers/unord/unord.map/load_factor.pass.cpp
new file mode 100644
index 00000000000..472e41abf6e
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/load_factor.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// float load_factor() const
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.load_factor() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.load_factor() == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/local_iterators.pass.cpp b/libcxx/test/std/containers/unord/unord.map/local_iterators.pass.cpp
new file mode 100644
index 00000000000..770b1ace7a3
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/local_iterators.pass.cpp
@@ -0,0 +1,421 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// local_iterator begin (size_type n);
+// local_iterator end (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend (size_type n) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 1);
+ assert(i->second == "one");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 2);
+ assert(i->second == "two");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/max_bucket_count.pass.cpp b/libcxx/test/std/containers/unord/unord.map/max_bucket_count.pass.cpp
new file mode 100644
index 00000000000..b4ca8eb0447
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/max_bucket_count.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type max_bucket_count() const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_bucket_count() > 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_bucket_count() > 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/max_load_factor.pass.cpp b/libcxx/test/std/containers/unord/unord.map/max_load_factor.pass.cpp
new file mode 100644
index 00000000000..69fd70d2a17
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/max_load_factor.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// float max_load_factor() const;
+// void max_load_factor(float mlf);
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ C c;
+ assert(c.max_load_factor() == 1);
+ c.max_load_factor(2.5);
+ assert(c.max_load_factor() == 2.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ C c;
+ assert(c.max_load_factor() == 1);
+ c.max_load_factor(2.5);
+ assert(c.max_load_factor() == 2.5);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_map<int, std::string> C;
+ C c;
+ c.max_load_factor(0);
+ assert(false);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/max_size.pass.cpp b/libcxx/test/std/containers/unord/unord.map/max_size.pass.cpp
new file mode 100644
index 00000000000..7d5ae3a8e46
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/max_size.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type max_size() const;
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::unordered_map<int, int> u;
+ assert(u.max_size() > 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::unordered_map<int, int, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, int>>> u;
+ assert(u.max_size() > 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/rehash.pass.cpp b/libcxx/test/std/containers/unord/unord.map/rehash.pass.cpp
new file mode 100644
index 00000000000..84ece235551
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/rehash.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void rehash(size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+}
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 5);
+ c.rehash(3);
+ assert(c.bucket_count() == 5);
+ test(c);
+ c.max_load_factor(2);
+ c.rehash(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.rehash(31);
+ assert(c.bucket_count() == 31);
+ test(c);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 5);
+ c.rehash(3);
+ assert(c.bucket_count() == 5);
+ test(c);
+ c.max_load_factor(2);
+ c.rehash(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.rehash(31);
+ assert(c.bucket_count() == 31);
+ test(c);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/reserve.pass.cpp b/libcxx/test/std/containers/unord/unord.map/reserve.pass.cpp
new file mode 100644
index 00000000000..48667cdc7f9
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/reserve.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void reserve(size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+}
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 5);
+ c.reserve(3);
+ assert(c.bucket_count() == 5);
+ test(c);
+ c.max_load_factor(2);
+ c.reserve(3);
+ assert(c.bucket_count() >= 2);
+ test(c);
+ c.reserve(31);
+ assert(c.bucket_count() >= 16);
+ test(c);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 5);
+ c.reserve(3);
+ assert(c.bucket_count() == 5);
+ test(c);
+ c.max_load_factor(2);
+ c.reserve(3);
+ assert(c.bucket_count() >= 2);
+ test(c);
+ c.reserve(31);
+ assert(c.bucket_count() >= 16);
+ test(c);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/swap_member.pass.cpp b/libcxx/test/std/containers/unord/unord.map/swap_member.pass.cpp
new file mode 100644
index 00000000000..8ab1eb6211b
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/swap_member.pass.cpp
@@ -0,0 +1,572 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void swap(unordered_map& __u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../test_compare.h"
+#include "../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/types.pass.cpp b/libcxx/test/std/containers/unord/unord.map/types.pass.cpp
new file mode 100644
index 00000000000..b53ff8e1540
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/types.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+// {
+// public:
+// // types
+// typedef Key key_type;
+// typedef T mapped_type;
+// typedef Hash hasher;
+// typedef Pred key_equal;
+// typedef Alloc allocator_type;
+// typedef pair<const key_type, mapped_type> value_type;
+// typedef value_type& reference;
+// typedef const value_type& const_reference;
+// typedef typename allocator_traits<allocator_type>::pointer pointer;
+// typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
+// typedef typename allocator_traits<allocator_type>::size_type size_type;
+// typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+#include <unordered_map>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<char, short> C;
+ static_assert((std::is_same<C::key_type, char>::value), "");
+ static_assert((std::is_same<C::mapped_type, short>::value), "");
+ static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+ static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+ static_assert((std::is_same<C::allocator_type, std::allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::value_type, std::pair<const C::key_type, C::mapped_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, C::value_type*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const C::value_type*>::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::unordered_map<char, short, std::hash<char>, std::equal_to<char>,
+ min_allocator<std::pair<const char, short>>> C;
+ static_assert((std::is_same<C::key_type, char>::value), "");
+ static_assert((std::is_same<C::mapped_type, short>::value), "");
+ static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+ static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::value_type, std::pair<const C::key_type, C::mapped_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<C::value_type>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const C::value_type>>::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/unord/unord.map/unord.map.cnstr/allocator.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp
new file mode 100644
index 00000000000..0fc76db0fb2
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// explicit unordered_map(const allocator_type& __a);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(test_allocator<std::pair<const NotConstructible, NotConstructible> >(10));
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(min_allocator<std::pair<const NotConstructible, NotConstructible> >{});
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef NotConstructible T;
+ typedef test_allocator<std::pair<const T, T>> A;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef std::unordered_map<T, T, HF, Comp, A> C;
+
+ A a(10);
+ C c(2, a);
+ assert(c.bucket_count() == 2);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef NotConstructible T;
+ typedef test_allocator<std::pair<const T, T>> A;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef std::unordered_map<T, T, HF, Comp, A> C;
+
+ A a(10);
+ HF hf(12);
+ C c(2, hf, a);
+ assert(c.bucket_count() == 2);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp
new file mode 100644
index 00000000000..fa0105604f1
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp
@@ -0,0 +1,185 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map& operator=(const unordered_map& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(4));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<const int, std::string> P;
+ const P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C *p = &c;
+ c = *p;
+ assert(c.size() == 4);
+ assert(std::is_permutation(c.begin(), c.end(), a));
+ }
+ {
+ typedef other_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = c0;
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A()
+ );
+ c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp
new file mode 100644
index 00000000000..3a854e10654
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map& operator=(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp
new file mode 100644
index 00000000000..dd57c58214f
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp
@@ -0,0 +1,229 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map& operator=(unordered_map&& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef test_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(4));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef test_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(10)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c0.size() == 0);
+ }
+ {
+ typedef other_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c0.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A()
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c0.size() == 0);
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::unordered_map<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}};
+ std::unordered_map<int, int>::iterator i = s1.begin();
+ std::pair<const int, int> k = *i;
+ std::unordered_map<int, int> s2;
+ s2 = std::move(s1);
+ assert(*i == k);
+ s2.erase(i);
+ assert(s2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp
new file mode 100644
index 00000000000..227343e6d5b
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp
@@ -0,0 +1,151 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(const unordered_map& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(10)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ other_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ other_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (other_allocator<std::pair<const int, std::string> >(-2)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp
new file mode 100644
index 00000000000..d1757d8a3c1
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(const unordered_map& u, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c(c0, test_allocator<std::pair<const int, std::string> >(5));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(5)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c(c0, min_allocator<std::pair<const int, std::string> >());
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp
new file mode 100644
index 00000000000..a0825db1ecd
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map();
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c;
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c;
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ std::unordered_map<int, int> c = {};
+ assert(c.bucket_count() == 0);
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp
new file mode 100644
index 00000000000..df8c7b57c93
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_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 <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "../../../test_hash.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp();
+ some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp
new file mode 100644
index 00000000000..1fc37f7594d
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// ~unordered_map() // implied noexcept;
+
+#include <unordered_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);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+ ~some_hash() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp
new file mode 100644
index 00000000000..dbc48f816c8
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp
@@ -0,0 +1,162 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_map<int, std::string, HF, Comp, A> C;
+
+ A a(42);
+ C c ( {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ }, 12, a);
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == a);
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_map<int, std::string, HF, Comp, A> C;
+
+ HF hf(42);
+ A a(43);
+ C c ( {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ }, 12, hf, a);
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == test_hash<std::hash<int> >()));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == a);
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp
new file mode 100644
index 00000000000..ac09053b1eb
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/init_size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il, size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp
new file mode 100644
index 00000000000..7a4130bde8f
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp
new file mode 100644
index 00000000000..036008c0b86
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il, size_type n,
+// const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 00000000000..7c83192b664
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(initializer_list<value_type> il, size_type n,
+// const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(10)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp
new file mode 100644
index 00000000000..18e6683011c
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move.pass.cpp
@@ -0,0 +1,199 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(unordered_map&& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 0);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(10)));
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(10)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 0);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::unordered_map<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}};
+ std::unordered_map<int, int>::iterator i = s1.begin();
+ std::pair<const int, int> k = *i;
+ std::unordered_map<int, int> s2 = std::move(s1);
+ assert(*i == k);
+ s2.erase(i);
+ assert(s2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp
new file mode 100644
index 00000000000..091a72f0d16
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(unordered_map&& u, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(std::move(c0), A(12));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(12));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(std::move(c0), A(10));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<int, std::string> P;
+ typedef min_allocator<std::pair<const int, std::string>> A;
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(std::move(c0), A());
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp
new file mode 100644
index 00000000000..f7fde37869a
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_map& operator=(unordered_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 <unordered_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&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+ some_hash& operator=(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp
new file mode 100644
index 00000000000..1c86dd3902a
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_map(unordered_map&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+// is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_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&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp
new file mode 100644
index 00000000000..c1784d63b29
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp
@@ -0,0 +1,170 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+// unordered_map(InputIterator first, InputIterator last);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_map<int, std::string, HF, Comp, A> C;
+
+ P arr[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(arr), input_iterator<P*>(arr + sizeof(arr)/sizeof(arr[0])), 14);
+ assert(c.bucket_count() >= 14);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_map<int, std::string, HF, Comp, A> C;
+
+ P arr[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ HF hf(42);
+ A a(43);
+ C c(input_iterator<P*>(arr), input_iterator<P*>(arr + sizeof(arr)/sizeof(arr[0])), 14, hf, a);
+ assert(c.bucket_count() >= 14);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp
new file mode 100644
index 00000000000..f914b306071
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/range_size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+// unordered_map(InputIterator first, InputIterator last, size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 10
+ );
+ assert(c.bucket_count() == 11);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 10
+ );
+ assert(c.bucket_count() == 11);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp
new file mode 100644
index 00000000000..7a0dbceb17c
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+// unordered_map(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp
new file mode 100644
index 00000000000..61eef5bc40a
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp
@@ -0,0 +1,110 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+// unordered_map(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 00000000000..99493fad32c
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,113 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+// unordered_map(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf, const key_equal& eql,
+// const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(10)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp
new file mode 100644
index 00000000000..0a3ae3a117f
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/size.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c = 7;
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c = 7;
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp
new file mode 100644
index 00000000000..708dc236273
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7);
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7);
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp
new file mode 100644
index 00000000000..6c975ec7203
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n, const hasher& hf);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp
new file mode 100644
index 00000000000..8b2bb317987
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n, const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp
new file mode 100644
index 00000000000..bcf7b91503a
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// unordered_map(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9),
+ test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9),
+ min_allocator<std::pair<const NotConstructible, NotConstructible> >()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp
new file mode 100644
index 00000000000..c4d7128698e
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// mapped_type& at(const key_type& k);
+// const mapped_type& at(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ c.at(1) = "ONE";
+ assert(c.at(1) == "ONE");
+ try
+ {
+ c.at(11) = "eleven";
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ assert(c.size() == 4);
+ }
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ try
+ {
+ c.at(11);
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ assert(c.size() == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ c.at(1) = "ONE";
+ assert(c.at(1) == "ONE");
+ try
+ {
+ c.at(11) = "eleven";
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ assert(c.size() == 4);
+ }
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ try
+ {
+ c.at(11);
+ assert(false);
+ }
+ catch (std::out_of_range&)
+ {
+ }
+ assert(c.size() == 4);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.elem/index.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.elem/index.pass.cpp
new file mode 100644
index 00000000000..7f4e067c515
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.elem/index.pass.cpp
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// mapped_type& operator[](const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ c[1] = "ONE";
+ assert(c.at(1) == "ONE");
+ c[11] = "eleven";
+ assert(c.size() == 5);
+ assert(c.at(11) == "eleven");
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<MoveOnly, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ c[1] = "ONE";
+ assert(c.at(1) == "ONE");
+ c[11] = "eleven";
+ assert(c.size() == 5);
+ assert(c.at(11) == "eleven");
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ c[1] = "ONE";
+ assert(c.at(1) == "ONE");
+ c[11] = "eleven";
+ assert(c.size() == 5);
+ assert(c.at(11) == "eleven");
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<MoveOnly, std::string, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
+ min_allocator<std::pair<const MoveOnly, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.size() == 4);
+ c[1] = "ONE";
+ assert(c.at(1) == "ONE");
+ c[11] = "eleven";
+ assert(c.size() == 5);
+ assert(c.at(11) == "eleven");
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp
new file mode 100644
index 00000000000..c319b5c30b2
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// mapped_type& operator[](const key_type& k);
+
+// http://llvm.org/bugs/show_bug.cgi?id=16542
+
+#include <unordered_map>
+
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+
+#include <tuple>
+
+using namespace std;
+
+struct my_hash
+{
+ size_t operator()(const tuple<int,int>&) const {return 0;}
+};
+
+#endif
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_VARIADICS
+ unordered_map<tuple<int,int>, size_t, my_hash> m;
+ m[make_tuple(2,3)]=7;
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp
new file mode 100644
index 00000000000..6ab9c923da3
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.swap/db_swap_1.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class Value, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, Value>>>
+// class unordered_map
+
+// void swap(unordered_map& x, unordered_map& y);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(3, 3), P(7, 7), P(9, 9), P(10, 10)};
+ P a2[] = {P(0, 0), P(2, 2), P(4, 4), P(5, 5), P(6, 6), P(8, 8), P(11, 11)};
+ std::unordered_map<int, int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::unordered_map<int, int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::unordered_map<int, int>::iterator i1 = c1.begin();
+ std::unordered_map<int, int>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ c2.erase(i1);
+ std::unordered_map<int, int>::iterator j = i1;
+ c1.erase(i1);
+ assert(false);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp
new file mode 100644
index 00000000000..49ac757eefb
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// void swap(unordered_map& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <unordered_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&) {}
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash() {}
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp
new file mode 100644
index 00000000000..7e04b8db117
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unord.map.swap/swap_non_member.pass.cpp
@@ -0,0 +1,572 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void swap(unordered_map& __u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_map<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.at(10) == "ten");
+ assert(c1.at(20) == "twenty");
+ assert(c1.at(30) == "thirty");
+ assert(c1.at(40) == "forty");
+ assert(c1.at(50) == "fifty");
+ assert(c1.at(60) == "sixty");
+ assert(c1.at(70) == "seventy");
+ assert(c1.at(80) == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.at(1) == "one");
+ assert(c2.at(2) == "two");
+ assert(c2.at(3) == "three");
+ assert(c2.at(4) == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/clear.pass.cpp
new file mode 100644
index 00000000000..9f320e94947
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/clear.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void clear()
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ c.clear();
+ assert(c.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ c.clear();
+ assert(c.size() == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp
new file mode 100644
index 00000000000..5de74d2e6c9
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class... Args>
+// pair<iterator, bool> emplace(Args&&... args);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<int, Emplaceable> C;
+ typedef std::pair<C::iterator, bool> R;
+ C c;
+ R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3);
+ assert(r.first->second == Emplaceable());
+
+ r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4);
+ assert(r.first->second == Emplaceable(5, 6));
+
+ r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5),
+ std::forward_as_tuple(6, 7));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5);
+ assert(r.first->second == Emplaceable(6, 7));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, Emplaceable, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, Emplaceable>>> C;
+ typedef std::pair<C::iterator, bool> R;
+ C c;
+ R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3);
+ assert(r.first->second == Emplaceable());
+
+ r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4);
+ assert(r.first->second == Emplaceable(5, 6));
+
+ r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5),
+ std::forward_as_tuple(6, 7));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5);
+ assert(r.first->second == Emplaceable(6, 7));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.pass.cpp
new file mode 100644
index 00000000000..21a4689658a
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/emplace_hint.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class... Args>
+// iterator emplace_hint(const_iterator p, Args&&... args);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<int, Emplaceable> C;
+ typedef C::iterator R;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+
+ r = c.emplace_hint(c.end(), std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+ assert(c.size() == 2);
+ assert(r->first == 4);
+ assert(r->second == Emplaceable(5, 6));
+
+ r = c.emplace_hint(c.end(), std::piecewise_construct, std::forward_as_tuple(5),
+ std::forward_as_tuple(6, 7));
+ assert(c.size() == 3);
+ assert(r->first == 5);
+ assert(r->second == Emplaceable(6, 7));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, Emplaceable, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, Emplaceable>>> C;
+ typedef C::iterator R;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+
+ r = c.emplace_hint(c.end(), std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+ assert(c.size() == 2);
+ assert(r->first == 4);
+ assert(r->second == Emplaceable(5, 6));
+
+ r = c.emplace_hint(c.end(), std::piecewise_construct, std::forward_as_tuple(5),
+ std::forward_as_tuple(6, 7));
+ assert(c.size() == 3);
+ assert(r->first == 5);
+ assert(r->second == Emplaceable(6, 7));
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_map<int, Emplaceable> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ R r = c.emplace_hint(c2.end(), std::piecewise_construct,
+ std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(false);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.pass.cpp
new file mode 100644
index 00000000000..422dbe45b43
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_const_iter.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator erase(const_iterator p)
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::iterator j = c.erase(i);
+ assert(c.size() == 3);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::iterator j = c.erase(i);
+ assert(c.size() == 3);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp
new file mode 100644
index 00000000000..60b093553f1
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db1.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_map<int, int> l1(a1, a1+3);
+ std::unordered_map<int, int>::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.pass.cpp
new file mode 100644
index 00000000000..05046f5dedc
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_db2.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_map<int, int> l1(a1, a1+3);
+ std::unordered_map<int, int> l2(a1, a1+3);
+ std::unordered_map<int, int>::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.pass.cpp
new file mode 100644
index 00000000000..81a8d3de157
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db1.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_map<int, int> l1(a1, a1+3);
+ std::unordered_map<int, int> l2(a1, a1+3);
+ std::unordered_map<int, int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.pass.cpp
new file mode 100644
index 00000000000..4b103a0ad75
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db2.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_map<int, int> l1(a1, a1+3);
+ std::unordered_map<int, int> l2(a1, a1+3);
+ std::unordered_map<int, int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.pass.cpp
new file mode 100644
index 00000000000..6ef1e07add1
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db3.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_map<int, int> l1(a1, a1+3);
+ std::unordered_map<int, int> l2(a1, a1+3);
+ std::unordered_map<int, int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.pass.cpp
new file mode 100644
index 00000000000..1185ddf8fd4
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_iter_iter_db4.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_map<int, int> l1(a1, a1+3);
+ std::unordered_map<int, int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_key.pass.cpp
new file mode 100644
index 00000000000..0e8ef8b895a
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_key.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// size_type erase(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+#if __cplusplus >= 201103L
+template <typename Unordered>
+bool only_deletions ( const Unordered &whole, const Unordered &part ) {
+ typename Unordered::const_iterator w = whole.begin();
+ typename Unordered::const_iterator p = part.begin();
+
+ while ( w != whole.end () && p != part.end()) {
+ if ( *w == *p )
+ p++;
+ w++;
+ }
+
+ return p == part.end();
+}
+#endif
+
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.erase(5) == 0);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ assert(c.erase(2) == 1);
+ assert(c.size() == 3);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ assert(c.erase(2) == 0);
+ assert(c.size() == 3);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ assert(c.erase(4) == 1);
+ assert(c.size() == 2);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+
+ assert(c.erase(4) == 0);
+ assert(c.size() == 2);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+
+ assert(c.erase(1) == 1);
+ assert(c.size() == 1);
+ assert(c.at(3) == "three");
+
+ assert(c.erase(1) == 0);
+ assert(c.size() == 1);
+ assert(c.at(3) == "three");
+
+ assert(c.erase(3) == 1);
+ assert(c.size() == 0);
+
+ assert(c.erase(3) == 0);
+ assert(c.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.erase(5) == 0);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ assert(c.erase(2) == 1);
+ assert(c.size() == 3);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ assert(c.erase(2) == 0);
+ assert(c.size() == 3);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ assert(c.erase(4) == 1);
+ assert(c.size() == 2);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+
+ assert(c.erase(4) == 0);
+ assert(c.size() == 2);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+
+ assert(c.erase(1) == 1);
+ assert(c.size() == 1);
+ assert(c.at(3) == "three");
+
+ assert(c.erase(1) == 0);
+ assert(c.size() == 1);
+ assert(c.at(3) == "three");
+
+ assert(c.erase(3) == 1);
+ assert(c.size() == 0);
+
+ assert(c.erase(3) == 0);
+ assert(c.size() == 0);
+ }
+ {
+ typedef std::unordered_map<int, int> C;
+ C m, m2;
+ for ( int i = 0; i < 10; ++i ) {
+ m[i] = i;
+ m2[i] = i;
+ }
+
+ C::iterator i = m2.begin();
+ int ctr = 0;
+ while (i != m2.end()) {
+ if (ctr++ % 2 == 0)
+ m2.erase(i++);
+ else
+ ++i;
+ }
+
+ assert (only_deletions (m, m2));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp
new file mode 100644
index 00000000000..f0664c3c3ff
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/erase_range.pass.cpp
@@ -0,0 +1,99 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator erase(const_iterator first, const_iterator last)
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::const_iterator j = next(i, 1);
+ C::iterator k = c.erase(i, i);
+ assert(k == i);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ k = c.erase(i, j);
+ assert(c.size() == 3);
+ assert(k == j);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ k = c.erase(c.cbegin(), c.cend());
+ assert(k == c.cend());
+ assert(c.size() == 0);
+ assert(k == c.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::const_iterator j = next(i, 1);
+ C::iterator k = c.erase(i, i);
+ assert(k == i);
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ k = c.erase(i, j);
+ assert(c.size() == 3);
+ assert(k == j);
+ assert(c.at(1) == "one");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+
+ k = c.erase(c.cbegin(), c.cend());
+ assert(k == c.cend());
+ assert(c.size() == 0);
+ assert(k == c.end());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.pass.cpp
new file mode 100644
index 00000000000..a16f097b4c0
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_const_lvalue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// pair<iterator, bool> insert(const value_type& x);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<double, int> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef C::value_type P;
+ C c;
+ R r = c.insert(P(3.5, 3));
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(3.5, 4));
+ assert(!r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(4.5, 4));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4.5);
+ assert(r.first->second == 4);
+
+ r = c.insert(P(5.5, 4));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5.5);
+ assert(r.first->second == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
+ min_allocator<std::pair<const double, int>>> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef C::value_type P;
+ C c;
+ R r = c.insert(P(3.5, 3));
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(3.5, 4));
+ assert(!r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(4.5, 4));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4.5);
+ assert(r.first->second == 4);
+
+ r = c.insert(P(5.5, 4));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5.5);
+ assert(r.first->second == 4);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp
new file mode 100644
index 00000000000..981b8fb18a0
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_const_lvalue.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// iterator insert(const_iterator p, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<double, int> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(3.5, 4));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(4.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
+ min_allocator<std::pair<const double, int>>> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(3.5, 4));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(4.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_map<double, int> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ P v(3.5, 3);
+ R r = c.insert(e, v);
+ assert(false);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp
new file mode 100644
index 00000000000..92f6c40e4de
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_hint_rvalue.pass.cpp
@@ -0,0 +1,156 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class P,
+// class = typename enable_if<is_convertible<P, value_type>::value>::type>
+// iterator insert(const_iterator p, P&& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<double, int> C;
+ typedef C::iterator R;
+ typedef std::pair<double, short> P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(3.5, 4));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(4.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly> C;
+ typedef C::iterator R;
+ typedef std::pair<MoveOnly, MoveOnly> P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(3, 4));
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(4, 4));
+ assert(c.size() == 2);
+ assert(r->first == 4);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 5);
+ assert(r->second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
+ min_allocator<std::pair<const double, int>>> C;
+ typedef C::iterator R;
+ typedef std::pair<double, short> P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(3.5, 4));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(4.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
+ min_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ typedef C::iterator R;
+ typedef std::pair<MoveOnly, MoveOnly> P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(3, 4));
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(4, 4));
+ assert(c.size() == 2);
+ assert(r->first == 4);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 5);
+ assert(r->second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_map<double, int> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp
new file mode 100644
index 00000000000..81e8a468d83
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_init.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// void insert(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ C c;
+ c.insert(
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ }
+ );
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ C c;
+ c.insert(
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ }
+ );
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_range.pass.cpp
new file mode 100644
index 00000000000..fc44e7828ff
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_range.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class InputIterator>
+// void insert(InputIterator first, InputIterator last);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c;
+ c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c;
+ c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.size() == 4);
+ assert(c.at(1) == "one");
+ assert(c.at(2) == "two");
+ assert(c.at(3) == "three");
+ assert(c.at(4) == "four");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp
new file mode 100644
index 00000000000..6c5e8c8ee84
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.map/unorder.map.modifiers/insert_rvalue.pass.cpp
@@ -0,0 +1,152 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_map
+
+// template <class P,
+// class = typename enable_if<is_convertible<P, value_type>::value>::type>
+// pair<iterator, bool> insert(P&& x);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_map<double, int> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef std::pair<double, short> P;
+ C c;
+ R r = c.insert(P(3.5, 3));
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(3.5, 4));
+ assert(!r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(4.5, 4));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4.5);
+ assert(r.first->second == 4);
+
+ r = c.insert(P(5.5, 4));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5.5);
+ assert(r.first->second == 4);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef std::pair<MoveOnly, MoveOnly> P;
+ C c;
+ R r = c.insert(P(3, 3));
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(3, 4));
+ assert(!r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(4, 4));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4);
+ assert(r.first->second == 4);
+
+ r = c.insert(P(5, 4));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5);
+ assert(r.first->second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>,
+ min_allocator<std::pair<const double, int>>> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef std::pair<double, short> P;
+ C c;
+ R r = c.insert(P(3.5, 3));
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(3.5, 4));
+ assert(!r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3.5);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(4.5, 4));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4.5);
+ assert(r.first->second == 4);
+
+ r = c.insert(P(5.5, 4));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5.5);
+ assert(r.first->second == 4);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
+ min_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef std::pair<MoveOnly, MoveOnly> P;
+ C c;
+ R r = c.insert(P(3, 3));
+ assert(r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(3, 4));
+ assert(!r.second);
+ assert(c.size() == 1);
+ assert(r.first->first == 3);
+ assert(r.first->second == 3);
+
+ r = c.insert(P(4, 4));
+ assert(r.second);
+ assert(c.size() == 2);
+ assert(r.first->first == 4);
+ assert(r.first->second == 4);
+
+ r = c.insert(P(5, 4));
+ assert(r.second);
+ assert(c.size() == 3);
+ assert(r.first->first == 5);
+ assert(r.first->second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.map/version.pass.cpp b/libcxx/test/std/containers/unord/unord.map/version.pass.cpp
new file mode 100644
index 00000000000..fc47a326c57
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+#include <unordered_map>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/bucket.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/bucket.pass.cpp
new file mode 100644
index 00000000000..be5acc19630
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/bucket.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type bucket(const key_type& __k) const;
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ size_t bc = c.bucket_count();
+ assert(bc >= 7);
+ for (size_t i = 0; i < 13; ++i)
+ assert(c.bucket(i) == i % bc);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ size_t bc = c.bucket_count();
+ assert(bc >= 7);
+ for (size_t i = 0; i < 13; ++i)
+ assert(c.bucket(i) == i % bc);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c;
+ C::size_type i = c.bucket(3);
+ assert(false);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp
new file mode 100644
index 00000000000..d44412fedf6
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/bucket_count.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type bucket_count() const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.bucket_count() == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 11);
+ }
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/bucket_size.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/bucket_size.pass.cpp
new file mode 100644
index 00000000000..a02f72efc6c
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/bucket_size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type bucket_size(size_type n) const
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 7);
+ assert(c.bucket_size(0) == 0);
+ assert(c.bucket_size(1) == 2);
+ assert(c.bucket_size(2) == 2);
+ assert(c.bucket_size(3) == 1);
+ assert(c.bucket_size(4) == 1);
+ assert(c.bucket_size(5) == 0);
+ assert(c.bucket_size(6) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 7);
+ assert(c.bucket_size(0) == 0);
+ assert(c.bucket_size(1) == 2);
+ assert(c.bucket_size(2) == 2);
+ assert(c.bucket_size(3) == 1);
+ assert(c.bucket_size(4) == 1);
+ assert(c.bucket_size(5) == 0);
+ assert(c.bucket_size(6) == 0);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c;
+ C::size_type i = c.bucket_size(3);
+ assert(false);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/count.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/count.pass.cpp
new file mode 100644
index 00000000000..efaf02e3a57
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/count.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type count(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fiftyA"),
+ P(50, "fiftyB"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.count(30) == 1);
+ assert(c.count(50) == 3);
+ assert(c.count(5) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fiftyA"),
+ P(50, "fiftyB"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.count(30) == 1);
+ assert(c.count(50) == 3);
+ assert(c.count(5) == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/db_iterators_7.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/db_iterators_7.pass.cpp
new file mode 100644
index 00000000000..b6ba8d6194a
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/db_iterators_7.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.multimap/db_iterators_8.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/db_iterators_8.pass.cpp
new file mode 100644
index 00000000000..f5ea5089349
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/db_iterators_8.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.end();
+ C::value_type j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c;
+ c.insert(std::make_pair(1, "one"));
+ C::iterator i = c.end();
+ C::value_type j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp
new file mode 100644
index 00000000000..93cbd5433f4
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/db_local_iterators_7.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Increment local_iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c(1);
+ C::local_iterator i = c.begin(0);
+ ++i;
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c(1);
+ C::local_iterator i = c.begin(0);
+ ++i;
+ ++i;
+ assert(false);
+ }
+#endif
+
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp
new file mode 100644
index 00000000000..159ae496353
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c(1);
+ C::local_iterator i = c.end(0);
+ C::value_type j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ C c(1);
+ C::local_iterator i = c.end(0);
+ C::value_type j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.multimap/eq.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/eq.pass.cpp
new file mode 100644
index 00000000000..3604e7792c1
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/eq.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash, class Pred, class Alloc>
+// bool
+// operator==(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
+// const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
+//
+// template <class Key, class T, class Hash, class Pred, class Alloc>
+// bool
+// operator!=(const unordered_multimap<Key, T, Hash, Pred, Alloc>& x,
+// const unordered_multimap<Key, T, Hash, Pred, Alloc>& y);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(20, "twenty 2"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fifty 2"),
+ P(50, "fifty 3"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2;
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(20, "twenty 2"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fifty 2"),
+ P(50, "fifty 3"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2 = c1;
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(20, "twenty 2"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fifty 2"),
+ P(50, "fifty 3"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a), std::end(a));
+ C c2 = c1;
+ c2.rehash(30);
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ c2.insert(P(90, "ninety"));
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ c1.insert(P(90, "ninety"));
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(20, "twenty 2"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fifty 2"),
+ P(50, "fifty 3"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2;
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(20, "twenty 2"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fifty 2"),
+ P(50, "fifty 3"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2 = c1;
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(20, "twenty 2"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fifty 2"),
+ P(50, "fifty 3"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a), std::end(a));
+ C c2 = c1;
+ c2.rehash(30);
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ c2.insert(P(90, "ninety"));
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ c1.insert(P(90, "ninety"));
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/equal_range_const.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/equal_range_const.pass.cpp
new file mode 100644
index 00000000000..67613b094bf
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/equal_range_const.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fiftyA"),
+ P(50, "fiftyB"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(r.first->first == 50);
+ assert(r.first->second == "fifty");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyA");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyB");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fiftyA"),
+ P(50, "fiftyB"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(r.first->first == 50);
+ assert(r.first->second == "fifty");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyA");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyB");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp
new file mode 100644
index 00000000000..eb4c019af95
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// pair<iterator, iterator> equal_range(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef C::iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fiftyA"),
+ P(50, "fiftyB"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(r.first->first == 50);
+ assert(r.first->second == "fifty");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyA");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyB");
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::iterator I;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(50, "fiftyA"),
+ P(50, "fiftyB"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(r.first->first == 30);
+ assert(r.first->second == "thirty");
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(r.first->first == 50);
+ assert(r.first->second == "fifty");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyA");
+ ++r.first;
+ assert(r.first->first == 50);
+ assert(r.first->second == "fiftyB");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/find_const.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/find_const.pass.cpp
new file mode 100644
index 00000000000..bc2650d111f
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/find_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// const_iterator find(const key_type& k) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ C::const_iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ C::const_iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/find_non_const.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/find_non_const.pass.cpp
new file mode 100644
index 00000000000..5a128c0f37e
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/find_non_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator find(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ C::iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c(std::begin(a), std::end(a));
+ C::iterator i = c.find(30);
+ assert(i->first == 30);
+ assert(i->second == "thirty");
+ i = c.find(5);
+ assert(i == c.end());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/iterators.fail.cpp b/libcxx/test/std/containers/unord/unord.multimap/iterators.fail.cpp
new file mode 100644
index 00000000000..d0adb2c25d5
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/iterators.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator begin() {return __table_.begin();}
+// iterator end() {return __table_.end();}
+// const_iterator begin() const {return __table_.begin();}
+// const_iterator end() const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend() const {return __table_.end();}
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i = c.begin();
+ i->second = "ONE";
+ assert(i->second == "ONE");
+ i->first = 2;
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/iterators.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/iterators.pass.cpp
new file mode 100644
index 00000000000..1831cf1149b
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/iterators.pass.cpp
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator begin() {return __table_.begin();}
+// iterator end() {return __table_.end();}
+// const_iterator begin() const {return __table_.begin();}
+// const_iterator end() const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend() const {return __table_.end();}
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i;
+ i = c.begin();
+ i->second = "ONE";
+ assert(i->second == "ONE");
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::const_iterator i;
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i;
+ i = c.begin();
+ i->second = "ONE";
+ assert(i->second == "ONE");
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::const_iterator i;
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::unordered_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/unord/unord.multimap/load_factor.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/load_factor.pass.cpp
new file mode 100644
index 00000000000..f407097dc0c
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/load_factor.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// float load_factor() const
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.load_factor() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.load_factor() == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/local_iterators.fail.cpp b/libcxx/test/std/containers/unord/unord.multimap/local_iterators.fail.cpp
new file mode 100644
index 00000000000..5f66cfe287e
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/local_iterators.fail.cpp
@@ -0,0 +1,286 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// local_iterator begin (size_type n);
+// local_iterator end (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend (size_type n) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ i->first = 2;
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/local_iterators.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/local_iterators.pass.cpp
new file mode 100644
index 00000000000..35e4c772fd3
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/local_iterators.pass.cpp
@@ -0,0 +1,549 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// local_iterator begin (size_type n);
+// local_iterator end (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend (size_type n) const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 3);
+ assert(i->second == "three");
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(i->first == 4);
+ assert(i->second == "four");
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp
new file mode 100644
index 00000000000..23b90579ec4
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/max_bucket_count.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type max_bucket_count() const;
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_bucket_count() > 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef C::const_iterator I;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_bucket_count() > 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp
new file mode 100644
index 00000000000..39b7feeba4e
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/max_load_factor.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// float max_load_factor() const;
+// void max_load_factor(float mlf);
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ C c;
+ assert(c.max_load_factor() == 1);
+ c.max_load_factor(2.5);
+ assert(c.max_load_factor() == 2.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ const C c;
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ C c;
+ assert(c.max_load_factor() == 1);
+ c.max_load_factor(2.5);
+ assert(c.max_load_factor() == 2.5);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ C c;
+ c.max_load_factor(0);
+ assert(false);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/max_size.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/max_size.pass.cpp
new file mode 100644
index 00000000000..caba5932b23
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/max_size.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type max_size() const;
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::unordered_multimap<int, int> u;
+ assert(u.max_size() > 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::unordered_multimap<int, int, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, int>>> u;
+ assert(u.max_size() > 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/rehash.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/rehash.pass.cpp
new file mode 100644
index 00000000000..1d99208596c
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/rehash.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void rehash(size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+ assert(c.size() == 6);
+ typedef std::pair<typename C::const_iterator, typename C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ typename C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+}
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 7);
+ c.rehash(3);
+ assert(c.bucket_count() == 7);
+ test(c);
+ c.max_load_factor(2);
+ c.rehash(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.rehash(31);
+ assert(c.bucket_count() == 31);
+ test(c);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 7);
+ c.rehash(3);
+ assert(c.bucket_count() == 7);
+ test(c);
+ c.max_load_factor(2);
+ c.rehash(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.rehash(31);
+ assert(c.bucket_count() == 31);
+ test(c);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/reserve.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/reserve.pass.cpp
new file mode 100644
index 00000000000..801c74457d7
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/reserve.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void rehash(size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+ assert(c.size() == 6);
+ assert(c.find(1)->second == "one");
+ assert(next(c.find(1))->second == "four");
+ assert(c.find(2)->second == "two");
+ assert(next(c.find(2))->second == "four");
+ assert(c.find(3)->second == "three");
+ assert(c.find(4)->second == "four");
+}
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 7);
+ c.reserve(3);
+ assert(c.bucket_count() == 7);
+ test(c);
+ c.max_load_factor(2);
+ c.reserve(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.reserve(31);
+ assert(c.bucket_count() >= 16);
+ test(c);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 7);
+ c.reserve(3);
+ assert(c.bucket_count() == 7);
+ test(c);
+ c.max_load_factor(2);
+ c.reserve(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.reserve(31);
+ assert(c.bucket_count() >= 16);
+ test(c);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/scary.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/scary.pass.cpp
new file mode 100644
index 00000000000..e619a7a5429
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// class unordered_map class unordered_multimap
+
+// Extension: SCARY/N2913 iterator compatibility between unordered_map and unordered_multimap
+
+#include <unordered_map>
+
+int main()
+{
+ typedef std::unordered_map<int, int> M1;
+ typedef std::unordered_multimap<int, int> M2;
+ M2::iterator i;
+ M1::iterator j = i;
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/swap_member.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/swap_member.pass.cpp
new file mode 100644
index 00000000000..225eccd4793
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/swap_member.pass.cpp
@@ -0,0 +1,585 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void swap(unordered_multimap& __u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../test_compare.h"
+#include "../../test_hash.h"
+#include "test_allocator.h"
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/types.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/types.pass.cpp
new file mode 100644
index 00000000000..55ae749746c
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/types.pass.cpp
@@ -0,0 +1,72 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+// {
+// public:
+// // types
+// typedef Key key_type;
+// typedef T mapped_type;
+// typedef Hash hasher;
+// typedef Pred key_equal;
+// typedef Alloc allocator_type;
+// typedef pair<const key_type, mapped_type> value_type;
+// typedef value_type& reference;
+// typedef const value_type& const_reference;
+// typedef typename allocator_traits<allocator_type>::pointer pointer;
+// typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
+// typedef typename allocator_traits<allocator_type>::size_type size_type;
+// typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+#include <unordered_map>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<char, short> C;
+ static_assert((std::is_same<C::key_type, char>::value), "");
+ static_assert((std::is_same<C::mapped_type, short>::value), "");
+ static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+ static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+ static_assert((std::is_same<C::allocator_type, std::allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::value_type, std::pair<const C::key_type, C::mapped_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, C::value_type*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const C::value_type*>::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::unordered_multimap<char, short, std::hash<char>, std::equal_to<char>,
+ min_allocator<std::pair<const char, short>>> C;
+ static_assert((std::is_same<C::key_type, char>::value), "");
+ static_assert((std::is_same<C::mapped_type, short>::value), "");
+ static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+ static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::value_type, std::pair<const C::key_type, C::mapped_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<C::value_type>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const C::value_type>>::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/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp
new file mode 100644
index 00000000000..dc41fad29af
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// explicit unordered_multimap(const allocator_type& __a);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(test_allocator<std::pair<const NotConstructible, NotConstructible> >(10));
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(min_allocator<std::pair<const NotConstructible, NotConstructible> >{});
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef NotConstructible T;
+ typedef test_allocator<std::pair<const T, T>> A;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef std::unordered_multimap<T, T, HF, Comp, A> C;
+
+ A a(10);
+ C c(2, a);
+ assert(c.bucket_count() == 2);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef NotConstructible T;
+ typedef test_allocator<std::pair<const T, T>> A;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef std::unordered_multimap<T, T, HF, Comp, A> C;
+
+ A a(10);
+ HF hf(12);
+ C c(2, hf, a);
+ assert(c.bucket_count() == 2);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp
new file mode 100644
index 00000000000..df566b396f9
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap& operator=(const unordered_multimap& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(4));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<const int, std::string> P;
+ const P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a+sizeof(a)/sizeof(a[0]));
+ C *p = &c;
+ c = *p;
+ assert(c.size() == 6);
+ assert(std::is_permutation(c.begin(), c.end(), a));
+ }
+ {
+ typedef other_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = c0;
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A()
+ );
+ c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp
new file mode 100644
index 00000000000..2d3c1434d69
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap& operator=(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef test_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp
new file mode 100644
index 00000000000..0c43fa8f06e
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap& operator=(unordered_multimap&& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef test_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef test_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(10)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef other_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<std::pair<const int, std::string> > A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A()
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::unordered_multimap<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}};
+ std::unordered_multimap<int, int>::iterator i = s1.begin();
+ std::pair<const int, int> k = *i;
+ std::unordered_multimap<int, int> s2;
+ s2 = std::move(s1);
+ assert(*i == k);
+ s2.erase(i);
+ assert(s2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp
new file mode 100644
index 00000000000..d71838f1dfb
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp
@@ -0,0 +1,193 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(const unordered_multimap& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(10)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ other_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ other_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (other_allocator<std::pair<const int, std::string> >(-2)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp
new file mode 100644
index 00000000000..2a064c5b5f6
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(const unordered_multimap& u, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c(c0, test_allocator<std::pair<const int, std::string> >(5));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(5)));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c(c0, min_allocator<std::pair<const int, std::string> >());
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+ ++i;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ ++i;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp
new file mode 100644
index 00000000000..1884065ce0c
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap();
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c;
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c;
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ std::unordered_multimap<int, int> c = {};
+ assert(c.bucket_count() == 0);
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp
new file mode 100644
index 00000000000..9812a45203b
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_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 <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "../../../test_hash.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp();
+ some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp
new file mode 100644
index 00000000000..ae2a96e2ac4
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// ~unordered_multimap() // implied noexcept;
+
+#include <unordered_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);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+ ~some_hash() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp
new file mode 100644
index 00000000000..cc5532adbe0
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp
@@ -0,0 +1,254 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c = {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_multimap<int, std::string, HF, Comp, A> C;
+
+ A a(42);
+ C c ({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ }, 12, a );
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ }
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_multimap<int, std::string, HF, Comp, A> C;
+
+ HF hf(42);
+ A a(43);
+ C c ({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ }, 12, hf, a );
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ }
+#endif
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp
new file mode 100644
index 00000000000..48239db1fa2
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp
@@ -0,0 +1,144 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il, size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp
new file mode 100644
index 00000000000..ff005467705
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp
@@ -0,0 +1,146 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp
new file mode 100644
index 00000000000..095e9c327f0
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp
@@ -0,0 +1,149 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il, size_type n,
+// const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 00000000000..d2f698ac2bc
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp
@@ -0,0 +1,151 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(initializer_list<value_type> il, size_type n,
+// const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ C c({
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp
new file mode 100644
index 00000000000..fd70ff10a70
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp
@@ -0,0 +1,243 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(unordered_multimap&& u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 0);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const int, std::string> >(10)));
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
+
+ assert(c0.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 0);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const int, std::string> >()));
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+
+ assert(c0.empty());
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::unordered_multimap<int, int> s1 = {{1, 1}, {2, 2}, {3, 3}};
+ std::unordered_multimap<int, int>::iterator i = s1.begin();
+ std::pair<const int, int> k = *i;
+ std::unordered_multimap<int, int> s2 = std::move(s1);
+ assert(*i == k);
+ s2.erase(i);
+ assert(s2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp
new file mode 100644
index 00000000000..d958e23ddd0
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp
@@ -0,0 +1,228 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(unordered_multimap&& u, const allocator_type& a);
+
+#include <iostream>
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(std::move(c0), A(12));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(12)));
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(std::move(c0), A(10));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
+
+ assert(c0.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::pair<int, std::string> P;
+ typedef min_allocator<std::pair<const int, std::string>> A;
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(std::move(c0), A());
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+
+ assert(c0.empty());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp
new file mode 100644
index 00000000000..078693d52b2
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_multimap& operator=(unordered_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 <unordered_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&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+ some_hash& operator=(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp
new file mode 100644
index 00000000000..44565d11503
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// unordered_multimap(unordered_multimap&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+// is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_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&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp
new file mode 100644
index 00000000000..bb700ec565d
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+// unordered_multimap(InputIterator first, InputIterator last);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_multimap<int, std::string, HF, Comp, A> C;
+
+ P arr[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ A a(42);
+ C c(input_iterator<P*>(arr), input_iterator<P*>(arr + sizeof(arr)/sizeof(arr[0])), 14, a);
+ assert(c.bucket_count() >= 14);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ }
+ {
+ typedef std::pair<int, std::string> P;
+ typedef test_allocator<std::pair<const int, std::string>> A;
+ typedef test_hash<std::hash<int>> HF;
+ typedef test_compare<std::equal_to<int>> Comp;
+ typedef std::unordered_multimap<int, std::string, HF, Comp, A> C;
+
+ P arr[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ A a(42);
+ HF hf (43);
+ C c(input_iterator<P*>(arr), input_iterator<P*>(arr + sizeof(arr)/sizeof(arr[0])), 12, hf, a );
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp
new file mode 100644
index 00000000000..a3fd4d14573
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp
@@ -0,0 +1,149 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+// unordered_multimap(InputIterator first, InputIterator last, size_type n);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 10
+ );
+ assert(c.bucket_count() == 11);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 10
+ );
+ assert(c.bucket_count() == 11);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp
new file mode 100644
index 00000000000..4e7b1ac17a2
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp
@@ -0,0 +1,152 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+// unordered_multimap(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp
new file mode 100644
index 00000000000..879e6811f2d
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+// unordered_multimap(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >()));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 00000000000..8e42ca7245e
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+// unordered_multimap(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf, const key_equal& eql,
+// const allocator_type& a);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<std::pair<const int, std::string> >(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10)));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<std::pair<const int, std::string> >
+ > C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<std::pair<const int, std::string> >()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator i = eq.first;
+ assert(i->first == 1);
+ assert(i->second == "one");
+ ++i;
+ assert(i->first == 1);
+ assert(i->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ i = eq.first;
+ assert(i->first == 2);
+ assert(i->second == "two");
+ ++i;
+ assert(i->first == 2);
+ assert(i->second == "four");
+
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 3);
+ assert(i->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ i = eq.first;
+ assert(i->first == 4);
+ assert(i->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert((c.get_allocator() == min_allocator<std::pair<const int, std::string> >()));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp
new file mode 100644
index 00000000000..44cf84ff323
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c = 7;
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c = 7;
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp
new file mode 100644
index 00000000000..bd56a41fd71
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7);
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7);
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp
new file mode 100644
index 00000000000..33460612ce3
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n, const hasher& hf);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp
new file mode 100644
index 00000000000..c2420ce9e6f
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n, const hasher& hf, const key_equal& eql);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp
new file mode 100644
index 00000000000..33886670b3b
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// unordered_multimap(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9),
+ test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<NotConstructible, NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<std::pair<const NotConstructible,
+ NotConstructible> >
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9),
+ min_allocator<std::pair<const NotConstructible, NotConstructible> >()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() ==
+ (min_allocator<std::pair<const NotConstructible, NotConstructible> >()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp
new file mode 100644
index 00000000000..4efcfaa6ce5
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/clear.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void clear()
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ c.clear();
+ assert(c.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ c.clear();
+ assert(c.size() == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp
new file mode 100644
index 00000000000..4f2e8ef061f
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class... Args>
+// iterator emplace(Args&&... args);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multimap<int, Emplaceable> C;
+ typedef C::iterator R;
+ C c;
+ R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+
+ r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+ assert(c.size() == 2);
+ assert(r->first == 4);
+ assert(r->second == Emplaceable(5, 6));
+
+ r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5),
+ std::forward_as_tuple(6, 7));
+ assert(c.size() == 3);
+ assert(r->first == 5);
+ assert(r->second == Emplaceable(6, 7));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, Emplaceable, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, Emplaceable>>> C;
+ typedef C::iterator R;
+ C c;
+ R r = c.emplace(std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+
+ r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
+ assert(c.size() == 2);
+ assert(r->first == 4);
+ assert(r->second == Emplaceable(5, 6));
+
+ r = c.emplace(std::piecewise_construct, std::forward_as_tuple(5),
+ std::forward_as_tuple(6, 7));
+ assert(c.size() == 3);
+ assert(r->first == 5);
+ assert(r->second == Emplaceable(6, 7));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp
new file mode 100644
index 00000000000..4d141ad137c
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class... Args>
+// iterator emplace_hint(const_iterator p, Args&&... args);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multimap<int, Emplaceable> C;
+ typedef C::iterator R;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+
+ r = c.emplace_hint(c.end(), std::pair<const int, Emplaceable>(3, Emplaceable(5, 6)));
+ assert(c.size() == 2);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable(5, 6));
+ assert(r == next(c.begin()));
+
+ r = c.emplace_hint(r, std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple(6, 7));
+ assert(c.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable(6, 7));
+ assert(r == next(c.begin()));
+ r = c.begin();
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+ r = next(r, 2);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable(5, 6));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, Emplaceable, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, Emplaceable>>> C;
+ typedef C::iterator R;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.emplace_hint(e, std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+
+ r = c.emplace_hint(c.end(), std::pair<const int, Emplaceable>(3, Emplaceable(5, 6)));
+ assert(c.size() == 2);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable(5, 6));
+ assert(r == next(c.begin()));
+
+ r = c.emplace_hint(r, std::piecewise_construct, std::forward_as_tuple(3),
+ std::forward_as_tuple(6, 7));
+ assert(c.size() == 3);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable(6, 7));
+ assert(r == next(c.begin()));
+ r = c.begin();
+ assert(r->first == 3);
+ assert(r->second == Emplaceable());
+ r = next(r, 2);
+ assert(r->first == 3);
+ assert(r->second == Emplaceable(5, 6));
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_multimap<int, Emplaceable> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ R r = c.emplace_hint(c2.end(), std::piecewise_construct,
+ std::forward_as_tuple(3),
+ std::forward_as_tuple());
+ assert(false);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp
new file mode 100644
index 00000000000..25d6a7a010d
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator erase(const_iterator p)
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::iterator j = c.erase(i);
+
+ assert(c.size() == 5);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::iterator j = c.erase(i);
+
+ assert(c.size() == 5);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp
new file mode 100644
index 00000000000..83ccf3b7396
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db1.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_multimap<int, int> l1(a1, a1+3);
+ std::unordered_multimap<int, int>::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.pass.cpp
new file mode 100644
index 00000000000..fffcfa69142
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_db2.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_multimap<int, int> l1(a1, a1+3);
+ std::unordered_multimap<int, int> l2(a1, a1+3);
+ std::unordered_multimap<int, int>::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.pass.cpp
new file mode 100644
index 00000000000..be6caba5902
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db1.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_multimap<int, int> l1(a1, a1+3);
+ std::unordered_multimap<int, int> l2(a1, a1+3);
+ std::unordered_multimap<int, int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.pass.cpp
new file mode 100644
index 00000000000..a6d54084e72
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db2.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_multimap<int, int> l1(a1, a1+3);
+ std::unordered_multimap<int, int> l2(a1, a1+3);
+ std::unordered_multimap<int, int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.pass.cpp
new file mode 100644
index 00000000000..301cfb4402d
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db3.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_multimap<int, int> l1(a1, a1+3);
+ std::unordered_multimap<int, int> l2(a1, a1+3);
+ std::unordered_multimap<int, int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.pass.cpp
new file mode 100644
index 00000000000..b53b486a56a
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_iter_iter_db4.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_map>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(2, 2), P(3, 3)};
+ std::unordered_multimap<int, int> l1(a1, a1+3);
+ std::unordered_multimap<int, int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp
new file mode 100644
index 00000000000..892f8a24750
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp
@@ -0,0 +1,388 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// size_type erase(const key_type& k);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+#if __cplusplus >= 201103L
+template <typename Unordered>
+bool only_deletions ( const Unordered &whole, const Unordered &part ) {
+ typename Unordered::const_iterator w = whole.begin();
+ typename Unordered::const_iterator p = part.begin();
+
+ while ( w != whole.end () && p != part.end()) {
+ if ( *w == *p )
+ p++;
+ w++;
+ }
+
+ return p == part.end();
+}
+#endif
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.erase(5) == 0);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "two");
+ ++k;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(2) == 2);
+ assert(c.size() == 4);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(2) == 0);
+ assert(c.size() == 4);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(4) == 1);
+ assert(c.size() == 3);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(4) == 0);
+ assert(c.size() == 3);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(1) == 2);
+ assert(c.size() == 1);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(1) == 0);
+ assert(c.size() == 1);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(3) == 1);
+ assert(c.size() == 0);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 0);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(3) == 0);
+ assert(c.size() == 0);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 0);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.erase(5) == 0);
+ assert(c.size() == 6);
+ typedef std::pair<C::const_iterator, C::const_iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::const_iterator k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "two");
+ ++k;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(2) == 2);
+ assert(c.size() == 4);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(2) == 0);
+ assert(c.size() == 4);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(4) == 1);
+ assert(c.size() == 3);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(4) == 0);
+ assert(c.size() == 3);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(1) == 2);
+ assert(c.size() == 1);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(1) == 0);
+ assert(c.size() == 1);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(3) == 1);
+ assert(c.size() == 0);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 0);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ assert(c.erase(3) == 0);
+ assert(c.size() == 0);
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 0);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+ {
+ typedef std::unordered_multimap<int, int> C;
+ C m, m2;
+ for ( int i = 0; i < 10; ++i ) {
+ for (int j = 0; j < 2; ++j ) {
+ m.insert (std::make_pair(i,j));
+ m2.insert(std::make_pair(i,j));
+ }
+ }
+
+ C::iterator i = m2.begin();
+ int ctr = 0;
+ while (i != m2.end()) {
+ if (ctr++ % 2 == 0)
+ m2.erase(i++);
+ else
+ ++i;
+ }
+
+ assert (only_deletions (m, m2));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp
new file mode 100644
index 00000000000..f60ec071ff7
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp
@@ -0,0 +1,179 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator erase(const_iterator first, const_iterator last)
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::const_iterator j = next(i, 2);
+ C::iterator k = c.erase(i, i);
+ assert(k == i);
+ assert(c.size() == 6);
+ typedef std::pair<C::iterator, C::iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "two");
+ ++k;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ k = c.erase(i, j);
+ assert(c.size() == 4);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ k = c.erase(c.cbegin(), c.cend());
+ assert(c.size() == 0);
+ assert(k == c.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::const_iterator j = next(i, 2);
+ C::iterator k = c.erase(i, i);
+ assert(k == i);
+ assert(c.size() == 6);
+ typedef std::pair<C::iterator, C::iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "two");
+ ++k;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ k = c.erase(i, j);
+ assert(c.size() == 4);
+ eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+
+ k = c.erase(c.cbegin(), c.cend());
+ assert(c.size() == 0);
+ assert(k == c.end());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp
new file mode 100644
index 00000000000..e7e7cb03b6d
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator insert(const value_type& x);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<double, int> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ R r = c.insert(P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(P(3.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3.5);
+ assert(r->second == 4);
+
+ r = c.insert(P(4.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(P(5.5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<double, int, std::hash<double>, std::equal_to<double>,
+ min_allocator<std::pair<const double, int>>> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ R r = c.insert(P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(P(3.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3.5);
+ assert(r->second == 4);
+
+ r = c.insert(P(4.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(P(5.5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp
new file mode 100644
index 00000000000..c7cb1f4c014
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// iterator insert(const_iterator p, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<double, int> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(3.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(4.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5.5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<double, int, std::hash<double>, std::equal_to<double>,
+ min_allocator<std::pair<const double, int>>> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(c.end(), P(3.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(4.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5.5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_multimap<double, int> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ P v(3.5, 3);
+ R r = c.insert(e, v);
+ assert(false);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp
new file mode 100644
index 00000000000..bb89c3f1bca
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp
@@ -0,0 +1,156 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class P,
+// class = typename enable_if<is_convertible<P, value_type>::value>::type>
+// iterator insert(const_iterator p, P&& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<double, int> C;
+ typedef C::iterator R;
+ typedef std::pair<double, short> P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(r, P(3.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(4.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5.5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+ typedef C::iterator R;
+ typedef std::pair<MoveOnly, MoveOnly> P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = c.insert(r, P(3, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(4, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5);
+ assert(r->second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<double, int, std::hash<double>, std::equal_to<double>,
+ min_allocator<std::pair<const double, int>>> C;
+ typedef C::iterator R;
+ typedef std::pair<double, short> P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(r, P(3.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(4.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5.5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
+ min_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ typedef C::iterator R;
+ typedef std::pair<MoveOnly, MoveOnly> P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = c.insert(r, P(3, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(4, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4);
+ assert(r->second == 4);
+
+ r = c.insert(c.end(), P(5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5);
+ assert(r->second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_multimap<double, int> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ R r = c.insert(e, P(3.5, 3));
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp
new file mode 100644
index 00000000000..23dbe84a3c5
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp
@@ -0,0 +1,122 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void insert(initializer_list<value_type> il);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ C c;
+ c.insert(
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ }
+ );
+ assert(c.size() == 6);
+ typedef std::pair<C::iterator, C::iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::iterator k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "two");
+ ++k;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ C c;
+ c.insert(
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ }
+ );
+ assert(c.size() == 6);
+ typedef std::pair<C::iterator, C::iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::iterator k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "two");
+ ++k;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp
new file mode 100644
index 00000000000..2820639b4ea
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp
@@ -0,0 +1,121 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class InputIterator>
+// void insert(InputIterator first, InputIterator last);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<int, std::string> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c;
+ c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.size() == 6);
+ typedef std::pair<C::iterator, C::iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::iterator k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "two");
+ ++k;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>,
+ min_allocator<std::pair<const int, std::string>>> C;
+ typedef std::pair<int, std::string> P;
+ P a[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c;
+ c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.size() == 6);
+ typedef std::pair<C::iterator, C::iterator> Eq;
+ Eq eq = c.equal_range(1);
+ assert(std::distance(eq.first, eq.second) == 2);
+ C::iterator k = eq.first;
+ assert(k->first == 1);
+ assert(k->second == "one");
+ ++k;
+ assert(k->first == 1);
+ assert(k->second == "four");
+ eq = c.equal_range(2);
+ assert(std::distance(eq.first, eq.second) == 2);
+ k = eq.first;
+ assert(k->first == 2);
+ assert(k->second == "two");
+ ++k;
+ assert(k->first == 2);
+ assert(k->second == "four");
+ eq = c.equal_range(3);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 3);
+ assert(k->second == "three");
+ eq = c.equal_range(4);
+ assert(std::distance(eq.first, eq.second) == 1);
+ k = eq.first;
+ assert(k->first == 4);
+ assert(k->second == "four");
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp
new file mode 100644
index 00000000000..f3637587efe
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp
@@ -0,0 +1,136 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// template <class P,
+// class = typename enable_if<is_convertible<P, value_type>::value>::type>
+// iterator insert(P&& x);
+
+#include <unordered_map>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multimap<double, int> C;
+ typedef C::iterator R;
+ typedef std::pair<double, short> P;
+ C c;
+ R r = c.insert(P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(P(3.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3.5);
+ assert(r->second == 4);
+
+ r = c.insert(P(4.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(P(5.5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+ typedef C::iterator R;
+ typedef std::pair<MoveOnly, MoveOnly> P;
+ C c;
+ R r = c.insert(P(3, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = c.insert(P(3, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3);
+ assert(r->second == 4);
+
+ r = c.insert(P(4, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4);
+ assert(r->second == 4);
+
+ r = c.insert(P(5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5);
+ assert(r->second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multimap<double, int, std::hash<double>, std::equal_to<double>,
+ min_allocator<std::pair<const double, int>>> C;
+ typedef C::iterator R;
+ typedef std::pair<double, short> P;
+ C c;
+ R r = c.insert(P(3.5, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3.5);
+ assert(r->second == 3);
+
+ r = c.insert(P(3.5, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3.5);
+ assert(r->second == 4);
+
+ r = c.insert(P(4.5, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4.5);
+ assert(r->second == 4);
+
+ r = c.insert(P(5.5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5.5);
+ assert(r->second == 4);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>,
+ min_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ typedef C::iterator R;
+ typedef std::pair<MoveOnly, MoveOnly> P;
+ C c;
+ R r = c.insert(P(3, 3));
+ assert(c.size() == 1);
+ assert(r->first == 3);
+ assert(r->second == 3);
+
+ r = c.insert(P(3, 4));
+ assert(c.size() == 2);
+ assert(r->first == 3);
+ assert(r->second == 4);
+
+ r = c.insert(P(4, 4));
+ assert(c.size() == 3);
+ assert(r->first == 4);
+ assert(r->second == 4);
+
+ r = c.insert(P(5, 4));
+ assert(c.size() == 4);
+ assert(r->first == 5);
+ assert(r->second == 4);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.swap/db_swap_1.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.swap/db_swap_1.pass.cpp
new file mode 100644
index 00000000000..a332b6fa418
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.swap/db_swap_1.pass.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class Value, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, Value>>>
+// class unordered_multimap
+
+// void swap(unordered_multimap& x, unordered_multimap& y);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_map>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::pair<int, int> P;
+ P a1[] = {P(1, 1), P(3, 3), P(7, 7), P(9, 9), P(10, 10)};
+ P a2[] = {P(0, 0), P(2, 2), P(4, 4), P(5, 5), P(6, 6), P(8, 8), P(11, 11)};
+ std::unordered_multimap<int, int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::unordered_multimap<int, int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::unordered_multimap<int, int>::iterator i1 = c1.begin();
+ std::unordered_multimap<int, int>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ c2.erase(i1);
+ std::unordered_multimap<int, int>::iterator j = i1;
+ c1.erase(i1);
+ assert(false);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp
new file mode 100644
index 00000000000..a7700b4de69
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// void swap(unordered_multimap& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <unordered_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&) {}
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash() {}
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<std::pair<const MoveOnly, MoveOnly>>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, some_hash<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp
new file mode 100644
index 00000000000..0f579e09168
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp
@@ -0,0 +1,584 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_map>
+
+// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
+// class Alloc = allocator<pair<const Key, T>>>
+// class unordered_multimap
+
+// void swap(unordered_multimap& __u);
+
+#include <unordered_map>
+#include <string>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<std::pair<const int, std::string> > Alloc;
+ typedef std::unordered_multimap<int, std::string, Hash, Compare, Alloc> C;
+ typedef std::pair<int, std::string> P;
+ P a1[] =
+ {
+ P(1, "one"),
+ P(2, "two"),
+ P(3, "three"),
+ P(4, "four"),
+ P(1, "four"),
+ P(2, "four"),
+ };
+ P a2[] =
+ {
+ P(10, "ten"),
+ P(20, "twenty"),
+ P(30, "thirty"),
+ P(40, "forty"),
+ P(50, "fifty"),
+ P(60, "sixty"),
+ P(70, "seventy"),
+ P(80, "eighty"),
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(c1.find(10)->second == "ten");
+ assert(c1.find(20)->second == "twenty");
+ assert(c1.find(30)->second == "thirty");
+ assert(c1.find(40)->second == "forty");
+ assert(c1.find(50)->second == "fifty");
+ assert(c1.find(60)->second == "sixty");
+ assert(c1.find(70)->second == "seventy");
+ assert(c1.find(80)->second == "eighty");
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.find(1)->second == "one");
+ assert(next(c2.find(1))->second == "four");
+ assert(c2.find(2)->second == "two");
+ assert(next(c2.find(2))->second == "four");
+ assert(c2.find(3)->second == "three");
+ assert(c2.find(4)->second == "four");
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/bucket.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/bucket.pass.cpp
new file mode 100644
index 00000000000..0293133d494
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/bucket.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type bucket(const key_type& __k) const;
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(std::begin(a), std::end(a));
+ size_t bc = c.bucket_count();
+ assert(bc >= 7);
+ for (size_t i = 0; i < 13; ++i)
+ assert(c.bucket(i) == i % bc);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(std::begin(a), std::end(a));
+ size_t bc = c.bucket_count();
+ assert(bc >= 7);
+ for (size_t i = 0; i < 13; ++i)
+ assert(c.bucket(i) == i % bc);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_multiset<int> C;
+ C c;
+ C::size_type i = c.bucket(3);
+ assert(false);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp
new file mode 100644
index 00000000000..c7842e5c197
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type bucket_count() const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ const C c;
+ assert(c.bucket_count() == 0);
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 11);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ const C c;
+ assert(c.bucket_count() == 0);
+ }
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 11);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/bucket_size.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/bucket_size.pass.cpp
new file mode 100644
index 00000000000..639d7ac3796
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/bucket_size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type bucket_size(size_type n) const
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 7);
+ assert(c.bucket_size(0) == 0);
+ assert(c.bucket_size(1) == 2);
+ assert(c.bucket_size(2) == 2);
+ assert(c.bucket_size(3) == 1);
+ assert(c.bucket_size(4) == 1);
+ assert(c.bucket_size(5) == 0);
+ assert(c.bucket_size(6) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 7);
+ assert(c.bucket_size(0) == 0);
+ assert(c.bucket_size(1) == 2);
+ assert(c.bucket_size(2) == 2);
+ assert(c.bucket_size(3) == 1);
+ assert(c.bucket_size(4) == 1);
+ assert(c.bucket_size(5) == 0);
+ assert(c.bucket_size(6) == 0);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_multiset<int> C;
+ C c;
+ C::size_type i = c.bucket_size(3);
+ assert(false);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/clear.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/clear.pass.cpp
new file mode 100644
index 00000000000..61ca847e7c4
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/clear.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void clear()
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ c.clear();
+ assert(c.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ c.clear();
+ assert(c.size() == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/count.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/count.pass.cpp
new file mode 100644
index 00000000000..e548324d954
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/count.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type count(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.count(30) == 1);
+ assert(c.count(50) == 3);
+ assert(c.count(5) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.count(30) == 1);
+ assert(c.count(50) == 3);
+ assert(c.count(5) == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/db_iterators_7.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/db_iterators_7.pass.cpp
new file mode 100644
index 00000000000..c8ef2fbca16
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/db_iterators_7.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::unordered_multiset<T> C;
+ C c(1);
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::unordered_multiset<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.multiset/db_iterators_8.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/db_iterators_8.pass.cpp
new file mode 100644
index 00000000000..eef79978794
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/db_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::unordered_multiset<T> C;
+ C c(1);
+ C::iterator i = c.end();
+ T j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::unordered_multiset<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.end();
+ T j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp
new file mode 100644
index 00000000000..c1de95cace7
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/db_local_iterators_7.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Increment local_iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::unordered_multiset<T> C;
+ C c(1);
+ C::local_iterator i = c.begin(0);
+ ++i;
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::unordered_multiset<T, min_allocator<T>> C;
+ C c(1);
+ C::local_iterator i = c.begin(0);
+ ++i;
+ ++i;
+ assert(false);
+ }
+#endif
+
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp
new file mode 100644
index 00000000000..962b85298ae
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::unordered_multiset<T> C;
+ C c(1);
+ C::local_iterator i = c.end(0);
+ T j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::unordered_multiset<T, min_allocator<T>> C;
+ C c(1);
+ C::local_iterator i = c.end(0);
+ T j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.multiset/emplace.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/emplace.pass.cpp
new file mode 100644
index 00000000000..13787d9b403
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/emplace.pass.cpp
@@ -0,0 +1,64 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class... Args>
+// iterator emplace(Args&&... args);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multiset<Emplaceable> C;
+ typedef C::iterator R;
+ C c;
+ R r = c.emplace();
+ assert(c.size() == 1);
+ assert(*r == Emplaceable());
+
+ r = c.emplace(Emplaceable(5, 6));
+ assert(c.size() == 2);
+ assert(*r == Emplaceable(5, 6));
+
+ r = c.emplace(5, 6);
+ assert(c.size() == 3);
+ assert(*r == Emplaceable(5, 6));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<Emplaceable, std::hash<Emplaceable>,
+ std::equal_to<Emplaceable>, min_allocator<Emplaceable>> C;
+ typedef C::iterator R;
+ C c;
+ R r = c.emplace();
+ assert(c.size() == 1);
+ assert(*r == Emplaceable());
+
+ r = c.emplace(Emplaceable(5, 6));
+ assert(c.size() == 2);
+ assert(*r == Emplaceable(5, 6));
+
+ r = c.emplace(5, 6);
+ assert(c.size() == 3);
+ assert(*r == Emplaceable(5, 6));
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/emplace_hint.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/emplace_hint.pass.cpp
new file mode 100644
index 00000000000..8885cc03cf0
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/emplace_hint.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class... Args>
+// iterator emplace_hint(const_iterator p, Args&&... args);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multiset<Emplaceable> C;
+ typedef C::iterator R;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.emplace_hint(e);
+ assert(c.size() == 1);
+ assert(*r == Emplaceable());
+
+ r = c.emplace_hint(c.end(), Emplaceable(5, 6));
+ assert(c.size() == 2);
+ assert(*r == Emplaceable(5, 6));
+
+ r = c.emplace_hint(r, 5, 6);
+ assert(c.size() == 3);
+ assert(*r == Emplaceable(5, 6));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<Emplaceable, std::hash<Emplaceable>,
+ std::equal_to<Emplaceable>, min_allocator<Emplaceable>> C;
+ typedef C::iterator R;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.emplace_hint(e);
+ assert(c.size() == 1);
+ assert(*r == Emplaceable());
+
+ r = c.emplace_hint(c.end(), Emplaceable(5, 6));
+ assert(c.size() == 2);
+ assert(*r == Emplaceable(5, 6));
+
+ r = c.emplace_hint(r, 5, 6);
+ assert(c.size() == 3);
+ assert(*r == Emplaceable(5, 6));
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_multiset<Emplaceable> C;
+ typedef C::iterator R;
+ C c1;
+ C c2;
+ R r = c1.emplace_hint(c2.begin(), 5, 6);
+ assert(false);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/eq.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/eq.pass.cpp
new file mode 100644
index 00000000000..bbedbc905a4
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/eq.pass.cpp
@@ -0,0 +1,180 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Key, class Hash, class Pred, class Alloc>
+// bool
+// operator==(const unordered_multiset<Key, Hash, Pred, Alloc>& x,
+// const unordered_multiset<Key, Hash, Pred, Alloc>& y);
+//
+// template <class Key, class Hash, class Pred, class Alloc>
+// bool
+// operator!=(const unordered_multiset<Key, Hash, Pred, Alloc>& x,
+// const unordered_multiset<Key, Hash, Pred, Alloc>& y);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2;
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2 = c1;
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a), std::end(a));
+ C c2 = c1;
+ c2.rehash(30);
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ c2.insert(P(90));
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ c1.insert(P(90));
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2;
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ }
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2 = c1;
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a), std::end(a));
+ C c2 = c1;
+ c2.rehash(30);
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ c2.insert(P(90));
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ c1.insert(P(90));
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/equal_range_const.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/equal_range_const.pass.cpp
new file mode 100644
index 00000000000..a0aaac2bd86
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/equal_range_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 30);
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(std::distance(r.first, r.second) == 3);
+ assert(*r.first == 50);
+ ++r.first;
+ assert(*r.first == 50);
+ ++r.first;
+ assert(*r.first == 50);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 30);
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(std::distance(r.first, r.second) == 3);
+ assert(*r.first == 50);
+ ++r.first;
+ assert(*r.first == 50);
+ ++r.first;
+ assert(*r.first == 50);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/equal_range_non_const.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/equal_range_non_const.pass.cpp
new file mode 100644
index 00000000000..73d44f7a56b
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/equal_range_non_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// pair<iterator, iterator> equal_range(const key_type& k);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef C::iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 30);
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(std::distance(r.first, r.second) == 3);
+ assert(*r.first == 50);
+ ++r.first;
+ assert(*r.first == 50);
+ ++r.first;
+ assert(*r.first == 50);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef C::iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 30);
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(std::distance(r.first, r.second) == 3);
+ assert(*r.first == 50);
+ ++r.first;
+ assert(*r.first == 50);
+ ++r.first;
+ assert(*r.first == 50);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/erase_const_iter.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/erase_const_iter.pass.cpp
new file mode 100644
index 00000000000..6a005d3e3ba
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/erase_const_iter.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator erase(const_iterator p)
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::iterator j = c.erase(i);
+ assert(c.size() == 5);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::iterator j = c.erase(i);
+ assert(c.size() == 5);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/erase_iter_db1.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/erase_iter_db1.pass.cpp
new file mode 100644
index 00000000000..baad3858bd4
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/erase_iter_db1.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_multiset<int> l1(a1, a1+3);
+ std::unordered_multiset<int>::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.multiset/erase_iter_db2.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/erase_iter_db2.pass.cpp
new file mode 100644
index 00000000000..a21f29ef7b4
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/erase_iter_db2.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_multiset<int> l1(a1, a1+3);
+ std::unordered_multiset<int> l2(a1, a1+3);
+ std::unordered_multiset<int>::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.multiset/erase_iter_iter_db1.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/erase_iter_iter_db1.pass.cpp
new file mode 100644
index 00000000000..03c9ec5d048
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/erase_iter_iter_db1.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_multiset<int> l1(a1, a1+3);
+ std::unordered_multiset<int> l2(a1, a1+3);
+ std::unordered_multiset<int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.multiset/erase_iter_iter_db2.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/erase_iter_iter_db2.pass.cpp
new file mode 100644
index 00000000000..4c6f209f1a4
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/erase_iter_iter_db2.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_multiset<int> l1(a1, a1+3);
+ std::unordered_multiset<int> l2(a1, a1+3);
+ std::unordered_multiset<int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.multiset/erase_iter_iter_db3.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/erase_iter_iter_db3.pass.cpp
new file mode 100644
index 00000000000..5ce378974c9
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/erase_iter_iter_db3.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_multiset<int> l1(a1, a1+3);
+ std::unordered_multiset<int> l2(a1, a1+3);
+ std::unordered_multiset<int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.multiset/erase_iter_iter_db4.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/erase_iter_iter_db4.pass.cpp
new file mode 100644
index 00000000000..7c362a2a2b1
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/erase_iter_iter_db4.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_multiset<int> l1(a1, a1+3);
+ std::unordered_multiset<int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.multiset/erase_key.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/erase_key.pass.cpp
new file mode 100644
index 00000000000..7c243973f16
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/erase_key.pass.cpp
@@ -0,0 +1,176 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type erase(const key_type& k);
+
+#include <unordered_set>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+#if __cplusplus >= 201103L
+template <typename Unordered>
+bool only_deletions ( const Unordered &whole, const Unordered &part ) {
+ typename Unordered::const_iterator w = whole.begin();
+ typename Unordered::const_iterator p = part.begin();
+
+ while ( w != whole.end () && p != part.end()) {
+ if ( *w == *p )
+ p++;
+ w++;
+ }
+
+ return p == part.end();
+}
+#endif
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.erase(5) == 0);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(2) == 2);
+ assert(c.size() == 4);
+ assert(c.count(1) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(2) == 0);
+ assert(c.size() == 4);
+ assert(c.count(1) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(4) == 1);
+ assert(c.size() == 3);
+ assert(c.count(1) == 2);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(4) == 0);
+ assert(c.size() == 3);
+ assert(c.count(1) == 2);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(1) == 2);
+ assert(c.size() == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(1) == 0);
+ assert(c.size() == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(3) == 1);
+ assert(c.size() == 0);
+
+ assert(c.erase(3) == 0);
+ assert(c.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.erase(5) == 0);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(2) == 2);
+ assert(c.size() == 4);
+ assert(c.count(1) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(2) == 0);
+ assert(c.size() == 4);
+ assert(c.count(1) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(4) == 1);
+ assert(c.size() == 3);
+ assert(c.count(1) == 2);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(4) == 0);
+ assert(c.size() == 3);
+ assert(c.count(1) == 2);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(1) == 2);
+ assert(c.size() == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(1) == 0);
+ assert(c.size() == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(3) == 1);
+ assert(c.size() == 0);
+
+ assert(c.erase(3) == 0);
+ assert(c.size() == 0);
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ C m, m2;
+ for ( int i = 0; i < 10; ++i ) {
+ m.insert(i); m.insert(i);
+ m2.insert(i); m2.insert(i);
+ }
+
+ C::iterator i = m2.begin();
+ int ctr = 0;
+ while (i != m2.end()) {
+ if (ctr++ % 2 == 0)
+ m2.erase(i++);
+ else
+ ++i;
+ }
+
+ assert (only_deletions (m, m2));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/erase_range.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/erase_range.pass.cpp
new file mode 100644
index 00000000000..baac08eddc1
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/erase_range.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator erase(const_iterator first, const_iterator last)
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::const_iterator j = next(i, 2);
+ C::iterator k = c.erase(i, i);
+ assert(k == i);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ k = c.erase(i, j);
+ assert(c.size() == 4);
+ assert(c.count(1) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ k = c.erase(c.cbegin(), c.cend());
+ assert(c.size() == 0);
+ assert(k == c.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::const_iterator j = next(i, 2);
+ C::iterator k = c.erase(i, i);
+ assert(k == i);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ k = c.erase(i, j);
+ assert(c.size() == 4);
+ assert(c.count(1) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ k = c.erase(c.cbegin(), c.cend());
+ assert(c.size() == 0);
+ assert(k == c.end());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/find_const.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/find_const.pass.cpp
new file mode 100644
index 00000000000..5caaf207aaf
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/find_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// const_iterator find(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ C::const_iterator i = c.find(30);
+ assert(*i == 30);
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ C::const_iterator i = c.find(30);
+ assert(*i == 30);
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/find_non_const.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/find_non_const.pass.cpp
new file mode 100644
index 00000000000..030487863f9
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/find_non_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator find(const key_type& k);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c(std::begin(a), std::end(a));
+ C::iterator i = c.find(30);
+ assert(*i == 30);
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c(std::begin(a), std::end(a));
+ C::iterator i = c.find(30);
+ assert(*i == 30);
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp
new file mode 100644
index 00000000000..0051e497fd7
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/insert_const_lvalue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator insert(const value_type& x);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<double> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ R r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(P(3.5));
+ assert(c.size() == 2);
+ assert(*r == 3.5);
+
+ r = c.insert(P(4.5));
+ assert(c.size() == 3);
+ assert(*r == 4.5);
+
+ r = c.insert(P(5.5));
+ assert(c.size() == 4);
+ assert(*r == 5.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<double, std::hash<double>,
+ std::equal_to<double>, min_allocator<double>> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ R r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(P(3.5));
+ assert(c.size() == 2);
+ assert(*r == 3.5);
+
+ r = c.insert(P(4.5));
+ assert(c.size() == 3);
+ assert(*r == 4.5);
+
+ r = c.insert(P(5.5));
+ assert(c.size() == 4);
+ assert(*r == 5.5);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp
new file mode 100644
index 00000000000..25b4bc1aa04
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator insert(const_iterator p, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<double> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(c.end(), P(3.5));
+ assert(c.size() == 2);
+ assert(*r == 3.5);
+
+ r = c.insert(c.end(), P(4.5));
+ assert(c.size() == 3);
+ assert(*r == 4.5);
+
+ r = c.insert(c.end(), P(5.5));
+ assert(c.size() == 4);
+ assert(*r == 5.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<double, std::hash<double>,
+ std::equal_to<double>, min_allocator<double>> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(c.end(), P(3.5));
+ assert(c.size() == 2);
+ assert(*r == 3.5);
+
+ r = c.insert(c.end(), P(4.5));
+ assert(c.size() == 3);
+ assert(*r == 4.5);
+
+ r = c.insert(c.end(), P(5.5));
+ assert(c.size() == 4);
+ assert(*r == 5.5);
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_multiset<double> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ P v(3.5);
+ R r = c.insert(e, v);
+ assert(false);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp
new file mode 100644
index 00000000000..634e4f4a176
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/insert_hint_rvalue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator insert(const_iterator p, value_type&& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<double> C;
+ typedef C::iterator R;
+ typedef double P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(r, P(3.5));
+ assert(c.size() == 2);
+ assert(*r == 3.5);
+
+ r = c.insert(c.end(), P(4.5));
+ assert(c.size() == 3);
+ assert(*r == 4.5);
+
+ r = c.insert(c.end(), P(5.5));
+ assert(c.size() == 4);
+ assert(*r == 5.5);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multiset<MoveOnly> C;
+ typedef C::iterator R;
+ typedef MoveOnly P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3));
+ assert(c.size() == 1);
+ assert(*r == 3);
+
+ r = c.insert(r, P(3));
+ assert(c.size() == 2);
+ assert(*r == 3);
+
+ r = c.insert(c.end(), P(4));
+ assert(c.size() == 3);
+ assert(*r == 4);
+
+ r = c.insert(c.end(), P(5));
+ assert(c.size() == 4);
+ assert(*r == 5);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<double, std::hash<double>,
+ std::equal_to<double>, min_allocator<double>> C;
+ typedef C::iterator R;
+ typedef double P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(r, P(3.5));
+ assert(c.size() == 2);
+ assert(*r == 3.5);
+
+ r = c.insert(c.end(), P(4.5));
+ assert(c.size() == 3);
+ assert(*r == 4.5);
+
+ r = c.insert(c.end(), P(5.5));
+ assert(c.size() == 4);
+ assert(*r == 5.5);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, min_allocator<MoveOnly>> C;
+ typedef C::iterator R;
+ typedef MoveOnly P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3));
+ assert(c.size() == 1);
+ assert(*r == 3);
+
+ r = c.insert(r, P(3));
+ assert(c.size() == 2);
+ assert(*r == 3);
+
+ r = c.insert(c.end(), P(4));
+ assert(c.size() == 3);
+ assert(*r == 4);
+
+ r = c.insert(c.end(), P(5));
+ assert(c.size() == 4);
+ assert(*r == 5);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_multiset<double> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ R r = c.insert(e, P(3.5));
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/insert_init.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/insert_init.pass.cpp
new file mode 100644
index 00000000000..6941d86f619
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/insert_init.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void insert(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ C c;
+ c.insert(
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ }
+ );
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ C c;
+ c.insert(
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ }
+ );
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/insert_range.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/insert_range.pass.cpp
new file mode 100644
index 00000000000..41c9d8136fe
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/insert_range.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+// void insert(InputIterator first, InputIterator last);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c;
+ c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c;
+ c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/insert_rvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/insert_rvalue.pass.cpp
new file mode 100644
index 00000000000..65a5bc2eb2a
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/insert_rvalue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator insert(value_type&& x);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<double> C;
+ typedef C::iterator R;
+ typedef double P;
+ C c;
+ R r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(P(3.5));
+ assert(c.size() == 2);
+ assert(*r == 3.5);
+
+ r = c.insert(P(4.5));
+ assert(c.size() == 3);
+ assert(*r == 4.5);
+
+ r = c.insert(P(5.5));
+ assert(c.size() == 4);
+ assert(*r == 5.5);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multiset<MoveOnly> C;
+ typedef C::iterator R;
+ typedef MoveOnly P;
+ C c;
+ R r = c.insert(P(3));
+ assert(c.size() == 1);
+ assert(*r == 3);
+
+ r = c.insert(P(3));
+ assert(c.size() == 2);
+ assert(*r == 3);
+
+ r = c.insert(P(4));
+ assert(c.size() == 3);
+ assert(*r == 4);
+
+ r = c.insert(P(5));
+ assert(c.size() == 4);
+ assert(*r == 5);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<double, std::hash<double>,
+ std::equal_to<double>, min_allocator<double>> C;
+ typedef C::iterator R;
+ typedef double P;
+ C c;
+ R r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(P(3.5));
+ assert(c.size() == 2);
+ assert(*r == 3.5);
+
+ r = c.insert(P(4.5));
+ assert(c.size() == 3);
+ assert(*r == 4.5);
+
+ r = c.insert(P(5.5));
+ assert(c.size() == 4);
+ assert(*r == 5.5);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, min_allocator<MoveOnly>> C;
+ typedef C::iterator R;
+ typedef MoveOnly P;
+ C c;
+ R r = c.insert(P(3));
+ assert(c.size() == 1);
+ assert(*r == 3);
+
+ r = c.insert(P(3));
+ assert(c.size() == 2);
+ assert(*r == 3);
+
+ r = c.insert(P(4));
+ assert(c.size() == 3);
+ assert(*r == 4);
+
+ r = c.insert(P(5));
+ assert(c.size() == 4);
+ assert(*r == 5);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/iterators.fail.cpp b/libcxx/test/std/containers/unord/unord.multiset/iterators.fail.cpp
new file mode 100644
index 00000000000..f78bccbd423
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/iterators.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator begin() {return __table_.begin();}
+// iterator end() {return __table_.end();}
+// const_iterator begin() const {return __table_.begin();}
+// const_iterator end() const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend() const {return __table_.end();}
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i = c.begin();
+ assert(*i == 1);
+ *i = 2;
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/iterators.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/iterators.pass.cpp
new file mode 100644
index 00000000000..be95b44517f
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/iterators.pass.cpp
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// iterator begin();
+// iterator end();
+// const_iterator begin() const;
+// const_iterator end() const;
+// const_iterator cbegin() const;
+// const_iterator cend() const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i;
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::const_iterator i;
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i;
+ }
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::const_iterator i;
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::unordered_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/unord/unord.multiset/load_factor.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/load_factor.pass.cpp
new file mode 100644
index 00000000000..07980c2afc8
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/load_factor.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// float load_factor() const
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ const C c;
+ assert(c.load_factor() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ }
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ const C c;
+ assert(c.load_factor() == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/local_iterators.fail.cpp b/libcxx/test/std/containers/unord/unord.multiset/local_iterators.fail.cpp
new file mode 100644
index 00000000000..4118987c2ae
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/local_iterators.fail.cpp
@@ -0,0 +1,261 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// local_iterator begin (size_type n);
+// local_iterator end (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend (size_type n) const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ *i = 2;
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() == 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/local_iterators.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/local_iterators.pass.cpp
new file mode 100644
index 00000000000..3471707e42a
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/local_iterators.pass.cpp
@@ -0,0 +1,500 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// local_iterator begin (size_type n);
+// local_iterator end (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend (size_type n) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 7);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/max_bucket_count.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/max_bucket_count.pass.cpp
new file mode 100644
index 00000000000..619a8cf1266
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/max_bucket_count.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type max_bucket_count() const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ const C c;
+ assert(c.max_bucket_count() > 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ const C c;
+ assert(c.max_bucket_count() > 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/max_load_factor.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/max_load_factor.pass.cpp
new file mode 100644
index 00000000000..08f52bb7084
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/max_load_factor.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// float max_load_factor() const;
+// void max_load_factor(float mlf);
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ const C c;
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ C c;
+ assert(c.max_load_factor() == 1);
+ c.max_load_factor(2.5);
+ assert(c.max_load_factor() == 2.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ const C c;
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ C c;
+ assert(c.max_load_factor() == 1);
+ c.max_load_factor(2.5);
+ assert(c.max_load_factor() == 2.5);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_multiset<int> C;
+ C c;
+ c.max_load_factor(0);
+ assert(false);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/max_size.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/max_size.pass.cpp
new file mode 100644
index 00000000000..a5d0b5538bc
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/max_size.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// size_type max_size() const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::unordered_multiset<int> u;
+ assert(u.max_size() > 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> u;
+ assert(u.max_size() > 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/rehash.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/rehash.pass.cpp
new file mode 100644
index 00000000000..bc8d461c60b
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/rehash.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void rehash(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+}
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 7);
+ c.rehash(3);
+ assert(c.bucket_count() == 7);
+ test(c);
+ c.max_load_factor(2);
+ c.rehash(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.rehash(31);
+ assert(c.bucket_count() == 31);
+ test(c);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 7);
+ c.rehash(3);
+ assert(c.bucket_count() == 7);
+ test(c);
+ c.max_load_factor(2);
+ c.rehash(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.rehash(31);
+ assert(c.bucket_count() == 31);
+ test(c);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/reserve.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/reserve.pass.cpp
new file mode 100644
index 00000000000..0c17583d371
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/reserve.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void reserve(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+}
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 7);
+ c.reserve(3);
+ assert(c.bucket_count() == 7);
+ test(c);
+ c.max_load_factor(2);
+ c.reserve(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.reserve(31);
+ assert(c.bucket_count() >= 16);
+ test(c);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 7);
+ c.reserve(3);
+ assert(c.bucket_count() == 7);
+ test(c);
+ c.max_load_factor(2);
+ c.reserve(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.reserve(31);
+ assert(c.bucket_count() >= 16);
+ test(c);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/scary.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/scary.pass.cpp
new file mode 100644
index 00000000000..dfd144bb317
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// class unordered_set class unordered_multiset
+
+// Extension: SCARY/N2913 iterator compatibility between unordered_set and unordered_multiset
+
+#include <unordered_set>
+
+int main()
+{
+ typedef std::unordered_set<int> M1;
+ typedef std::unordered_multiset<int> M2;
+ M2::iterator i;
+ M1::iterator j = i;
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/swap_member.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/swap_member.pass.cpp
new file mode 100644
index 00000000000..275ff4094e8
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/swap_member.pass.cpp
@@ -0,0 +1,571 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void swap(unordered_multiset& __u);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../test_compare.h"
+#include "../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/types.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/types.pass.cpp
new file mode 100644
index 00000000000..5222222d819
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+// {
+// public:
+// // types
+// typedef Value value_type;
+// typedef value_type key_type;
+// typedef Hash hasher;
+// typedef Pred key_equal;
+// typedef Alloc allocator_type;
+// typedef value_type& reference;
+// typedef const value_type& const_reference;
+// typedef typename allocator_traits<allocator_type>::pointer pointer;
+// typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
+// typedef typename allocator_traits<allocator_type>::size_type size_type;
+// typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+#include <unordered_set>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<short> C;
+ static_assert((std::is_same<C::value_type, short>::value), "");
+ static_assert((std::is_same<C::key_type, short>::value), "");
+ static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+ static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+ static_assert((std::is_same<C::allocator_type, std::allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, C::value_type*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const C::value_type*>::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::unordered_multiset<short, std::hash<short>,
+ std::equal_to<short>, min_allocator<short>> C;
+ static_assert((std::is_same<C::value_type, short>::value), "");
+ static_assert((std::is_same<C::key_type, short>::value), "");
+ static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+ static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<C::value_type>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const C::value_type>>::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/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp
new file mode 100644
index 00000000000..ccd21a58b22
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// explicit unordered_multiset(const allocator_type& __a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c(test_allocator<NotConstructible>(10));
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == test_allocator<NotConstructible>(10));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c(min_allocator<NotConstructible>{});
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == min_allocator<NotConstructible>());
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef NotConstructible T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_multiset<T, HF, Comp, A> C;
+
+ A a(43);
+ C c(3, a);
+ assert(c.bucket_count() == 3);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp ());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef NotConstructible T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_multiset<T, HF, Comp, A> C;
+
+ HF hf(42);
+ A a(43);
+ C c(4, hf, a);
+ assert(c.bucket_count() == 4);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp ());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp
new file mode 100644
index 00000000000..2042f69fd77
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset& operator=(const unordered_multiset& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(4));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_multiset<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C *p = &c;
+ c = *p;
+
+ assert(c.size() == 6);
+ assert(std::is_permutation(c.begin(), c.end(), a));
+ }
+ {
+ typedef other_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = c0;
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A()
+ );
+ c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp
new file mode 100644
index 00000000000..4eaf2c5779f
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset& operator=(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef test_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ C c = {
+ P(4),
+ P(1),
+ P(2)
+ };
+ c = {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ C c = {
+ P(4),
+ P(1),
+ P(2)
+ };
+ c = {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp
new file mode 100644
index 00000000000..4b0e52c5930
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp
@@ -0,0 +1,286 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset& operator=(unordered_multiset&& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef test_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(4));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef test_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(10)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef other_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A()
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef min_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A()
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::unordered_multiset<int> s1 = {1, 2, 3};
+ std::unordered_multiset<int>::iterator i = s1.begin();
+ int k = *i;
+ std::unordered_multiset<int> s2;
+ s2 = std::move(s1);
+ assert(*i == k);
+ s2.erase(i);
+ assert(s2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp
new file mode 100644
index 00000000000..94241830a06
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp
@@ -0,0 +1,171 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(const unordered_multiset& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ other_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ other_allocator<int>(10)
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == other_allocator<int>(-2));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp
new file mode 100644
index 00000000000..22e372bb3ad
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp
@@ -0,0 +1,123 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(const unordered_multiset& u, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ C c(c0, test_allocator<int>(5));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(5));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ C c(c0, min_allocator<int>());
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp
new file mode 100644
index 00000000000..737ae2dae79
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset();
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c;
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c;
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ std::unordered_multiset<int> c = {};
+ assert(c.bucket_count() == 0);
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp
new file mode 100644
index 00000000000..0effeed911b
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// unordered_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 <unordered_set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "../../../test_hash.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp();
+ some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multiset<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp
new file mode 100644
index 00000000000..c4c54a5a0dd
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// ~unordered_multiset() // implied noexcept;
+
+#include <unordered_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);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+ ~some_hash() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multiset<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp
new file mode 100644
index 00000000000..416c28cf83d
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp
@@ -0,0 +1,163 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ C c = {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ C c = {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_multiset<T, HF, Comp, A> C;
+
+ A a(42);
+ C c({
+ T(1),
+ T(2),
+ T(3),
+ T(4),
+ T(1),
+ T(2)
+ }, 12, a);
+
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef int T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_multiset<T, HF, Comp, A> C;
+
+ A a(42);
+ HF hf(43);
+ C c({
+ T(1),
+ T(2),
+ T(3),
+ T(4),
+ T(1),
+ T(2)
+ }, 12, hf, a);
+
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp
new file mode 100644
index 00000000000..a6543a0e6f4
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(initializer_list<value_type> il, size_type n);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp
new file mode 100644
index 00000000000..7d0f37163a1
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(initializer_list<value_type> il, size_type n,
+// const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp
new file mode 100644
index 00000000000..cd013f9554a
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(initializer_list<value_type> il, size_type n,
+// const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 00000000000..4621c7fbb3f
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(initializer_list<value_type> il, size_type n,
+// const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp
new file mode 100644
index 00000000000..a68cfe8cd3b
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp
@@ -0,0 +1,194 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(unordered_multiset&& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 0);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(10));
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 0);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::unordered_multiset<int> s1 = {1, 2, 3};
+ std::unordered_multiset<int>::iterator i = s1.begin();
+ int k = *i;
+ std::unordered_multiset<int> s2 = std::move(s1);
+ assert(*i == k);
+ s2.erase(i);
+ assert(s2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp
new file mode 100644
index 00000000000..9eee69a58e5
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp
@@ -0,0 +1,213 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(unordered_multiset&& u, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef int P;
+ typedef test_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(std::move(c0), A(12));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 4);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(12));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef int P;
+ typedef test_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(std::move(c0), A(10));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int P;
+ typedef min_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(std::move(c0), A());
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ C::const_iterator i = c.cbegin();
+ assert(*i == 4);
+ ++i;
+ assert(*i == 3);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+ ++i;
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef int P;
+ typedef min_allocator<int> A;
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(std::move(c0), A());
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp
new file mode 100644
index 00000000000..8a56d1a4859
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// unordered_multiset& operator=(unordered_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 <unordered_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&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+ some_hash& operator=(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multiset<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp
new file mode 100644
index 00000000000..aa7ad05afad
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// unordered_multiset(unordered_multiset&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+// is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_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&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multiset<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp
new file mode 100644
index 00000000000..cd2bb1e7bbc
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp
@@ -0,0 +1,167 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+// unordered_multiset(InputIterator first, InputIterator last);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.bucket_count() >= 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_multiset<T, HF, Comp, A> C;
+ T arr[] =
+ {
+ T(1),
+ T(2),
+ T(3),
+ T(4),
+ T(1),
+ T(2)
+ };
+ A a(42);
+ C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 12, a);
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef int T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_multiset<T, HF, Comp, A> C;
+ T arr[] =
+ {
+ T(1),
+ T(2),
+ T(3),
+ T(4),
+ T(1),
+ T(2)
+ };
+ HF hf(43);
+ A a(42);
+ C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 16, hf, a);
+ assert(c.bucket_count() >= 16);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp
new file mode 100644
index 00000000000..4f5e03e28f4
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+// unordered_multiset(InputIterator first, InputIterator last, size_type n);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp
new file mode 100644
index 00000000000..6b83bde9bc5
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+// unordered_multiset(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp
new file mode 100644
index 00000000000..89e7c7fa2e3
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp
@@ -0,0 +1,106 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+// unordered_multiset(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 00000000000..b712a96f05b
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// template <class InputIterator>
+// unordered_multiset(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf, const key_equal& eql,
+// const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 6);
+ assert(c.count(1) == 2);
+ assert(c.count(2) == 2);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp
new file mode 100644
index 00000000000..e55db7ca2aa
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// explicit unordered_multiset(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c = 7;
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c = 7;
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp
new file mode 100644
index 00000000000..35bfbe331b4
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// explicit unordered_multiset(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c(7);
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c(7);
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp
new file mode 100644
index 00000000000..0171ea64ebb
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(size_type n, const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.pass.cpp
new file mode 100644
index 00000000000..785cdf24636
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(size_type n, const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp
new file mode 100644
index 00000000000..50dd3c95ee5
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// unordered_multiset(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9),
+ test_allocator<std::pair<const NotConstructible, NotConstructible> >(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() == (test_allocator<NotConstructible>(10)));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_multiset<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9),
+ min_allocator<std::pair<const NotConstructible, NotConstructible> >()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.swap/db_swap_1.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.swap/db_swap_1.pass.cpp
new file mode 100644
index 00000000000..9470b1a6fa8
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.swap/db_swap_1.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void swap(unordered_multiset& x, unordered_multiset& y);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::unordered_multiset<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::unordered_multiset<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::unordered_multiset<int>::iterator i1 = c1.begin();
+ std::unordered_multiset<int>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ c2.erase(i1);
+ std::unordered_multiset<int>::iterator j = i1;
+ c1.erase(i1);
+ assert(false);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp
new file mode 100644
index 00000000000..40dac3cc070
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// void swap(unordered_multiset& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <unordered_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&) {}
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash() {}
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_multiset<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, some_hash<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp
new file mode 100644
index 00000000000..624b81c5eb3
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp
@@ -0,0 +1,571 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_multiset
+
+// void swap(unordered_multiset& x, unordered_multiset& y);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_multiset<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 7);
+ assert(c2.size() == 6);
+ assert(c2.count(1) == 2);
+ assert(c2.count(2) == 2);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/bucket.pass.cpp b/libcxx/test/std/containers/unord/unord.set/bucket.pass.cpp
new file mode 100644
index 00000000000..0dae664e0b2
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/bucket.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type bucket(const key_type& __k) const;
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(std::begin(a), std::end(a));
+ size_t bc = c.bucket_count();
+ assert(bc >= 5);
+ for (size_t i = 0; i < 13; ++i)
+ assert(c.bucket(i) == i % bc);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(std::begin(a), std::end(a));
+ size_t bc = c.bucket_count();
+ assert(bc >= 5);
+ for (size_t i = 0; i < 13; ++i)
+ assert(c.bucket(i) == i % bc);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_set<int> C;
+ C c;
+ C::size_type i = c.bucket(3);
+ assert(false);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/bucket_count.pass.cpp b/libcxx/test/std/containers/unord/unord.set/bucket_count.pass.cpp
new file mode 100644
index 00000000000..caaa5a6011a
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/bucket_count.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type bucket_count() const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ const C c;
+ assert(c.bucket_count() == 0);
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 11);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ const C c;
+ assert(c.bucket_count() == 0);
+ }
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 11);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/bucket_size.pass.cpp b/libcxx/test/std/containers/unord/unord.set/bucket_size.pass.cpp
new file mode 100644
index 00000000000..628d55737a8
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/bucket_size.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type bucket_size(size_type n) const
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 5);
+ assert(c.bucket_size(0) == 0);
+ assert(c.bucket_size(1) == 1);
+ assert(c.bucket_size(2) == 1);
+ assert(c.bucket_size(3) == 1);
+ assert(c.bucket_size(4) == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.bucket_count() >= 5);
+ assert(c.bucket_size(0) == 0);
+ assert(c.bucket_size(1) == 1);
+ assert(c.bucket_size(2) == 1);
+ assert(c.bucket_size(3) == 1);
+ assert(c.bucket_size(4) == 1);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_set<int> C;
+ C c;
+ C::size_type i = c.bucket_size(3);
+ assert(false);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/clear.pass.cpp b/libcxx/test/std/containers/unord/unord.set/clear.pass.cpp
new file mode 100644
index 00000000000..6da15308508
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/clear.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// void clear()
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ c.clear();
+ assert(c.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ c.clear();
+ assert(c.size() == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/count.pass.cpp b/libcxx/test/std/containers/unord/unord.set/count.pass.cpp
new file mode 100644
index 00000000000..83bb8aaa2be
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/count.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type count(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.count(30) == 1);
+ assert(c.count(50) == 1);
+ assert(c.count(5) == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(c.count(30) == 1);
+ assert(c.count(50) == 1);
+ assert(c.count(5) == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/db_iterators_7.pass.cpp b/libcxx/test/std/containers/unord/unord.set/db_iterators_7.pass.cpp
new file mode 100644
index 00000000000..80b1a49c575
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/db_iterators_7.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Increment iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::unordered_set<T> C;
+ C c(1);
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::unordered_set<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.begin();
+ ++i;
+ assert(i == c.end());
+ ++i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.set/db_iterators_8.pass.cpp b/libcxx/test/std/containers/unord/unord.set/db_iterators_8.pass.cpp
new file mode 100644
index 00000000000..8b266bbf664
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/db_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::unordered_set<T> C;
+ C c(1);
+ C::iterator i = c.end();
+ T j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::unordered_set<T, min_allocator<T>> C;
+ C c(1);
+ C::iterator i = c.end();
+ T j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.set/db_local_iterators_7.pass.cpp b/libcxx/test/std/containers/unord/unord.set/db_local_iterators_7.pass.cpp
new file mode 100644
index 00000000000..b9fcb8c4ae0
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/db_local_iterators_7.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Increment local_iterator past end.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::unordered_set<T> C;
+ C c(1);
+ C::local_iterator i = c.begin(0);
+ ++i;
+ ++i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::unordered_set<T, min_allocator<T>> C;
+ C c(1);
+ C::local_iterator i = c.begin(0);
+ ++i;
+ ++i;
+ assert(false);
+ }
+#endif
+
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.set/db_local_iterators_8.pass.cpp b/libcxx/test/std/containers/unord/unord.set/db_local_iterators_8.pass.cpp
new file mode 100644
index 00000000000..74d131b19ab
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/db_local_iterators_8.pass.cpp
@@ -0,0 +1,54 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Dereference non-dereferenceable iterator.
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <iterator>
+#include <exception>
+#include <cstdlib>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef int T;
+ typedef std::unordered_set<T> C;
+ C c(1);
+ C::local_iterator i = c.end(0);
+ T j = *i;
+ assert(false);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int T;
+ typedef std::unordered_set<T, min_allocator<T>> C;
+ C c(1);
+ C::local_iterator i = c.end(0);
+ T j = *i;
+ assert(false);
+ }
+#endif
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.set/emplace.pass.cpp b/libcxx/test/std/containers/unord/unord.set/emplace.pass.cpp
new file mode 100644
index 00000000000..d105e7ac0f4
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/emplace.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class... Args>
+// pair<iterator, bool> emplace(Args&&... args);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_set<Emplaceable> C;
+ typedef std::pair<C::iterator, bool> R;
+ C c;
+ R r = c.emplace();
+ assert(c.size() == 1);
+ assert(*r.first == Emplaceable());
+ assert(r.second);
+
+ r = c.emplace(Emplaceable(5, 6));
+ assert(c.size() == 2);
+ assert(*r.first == Emplaceable(5, 6));
+ assert(r.second);
+
+ r = c.emplace(5, 6);
+ assert(c.size() == 2);
+ assert(*r.first == Emplaceable(5, 6));
+ assert(!r.second);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<Emplaceable, std::hash<Emplaceable>,
+ std::equal_to<Emplaceable>, min_allocator<Emplaceable>> C;
+ typedef std::pair<C::iterator, bool> R;
+ C c;
+ R r = c.emplace();
+ assert(c.size() == 1);
+ assert(*r.first == Emplaceable());
+ assert(r.second);
+
+ r = c.emplace(Emplaceable(5, 6));
+ assert(c.size() == 2);
+ assert(*r.first == Emplaceable(5, 6));
+ assert(r.second);
+
+ r = c.emplace(5, 6);
+ assert(c.size() == 2);
+ assert(*r.first == Emplaceable(5, 6));
+ assert(!r.second);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/emplace_hint.pass.cpp b/libcxx/test/std/containers/unord/unord.set/emplace_hint.pass.cpp
new file mode 100644
index 00000000000..50b0035165d
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/emplace_hint.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class... Args>
+// iterator emplace_hint(const_iterator p, Args&&... args);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../Emplaceable.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_set<Emplaceable> C;
+ typedef C::iterator R;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.emplace_hint(e);
+ assert(c.size() == 1);
+ assert(*r == Emplaceable());
+
+ r = c.emplace_hint(e, Emplaceable(5, 6));
+ assert(c.size() == 2);
+ assert(*r == Emplaceable(5, 6));
+
+ r = c.emplace_hint(r, 5, 6);
+ assert(c.size() == 2);
+ assert(*r == Emplaceable(5, 6));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<Emplaceable, std::hash<Emplaceable>,
+ std::equal_to<Emplaceable>, min_allocator<Emplaceable>> C;
+ typedef C::iterator R;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.emplace_hint(e);
+ assert(c.size() == 1);
+ assert(*r == Emplaceable());
+
+ r = c.emplace_hint(e, Emplaceable(5, 6));
+ assert(c.size() == 2);
+ assert(*r == Emplaceable(5, 6));
+
+ r = c.emplace_hint(r, 5, 6);
+ assert(c.size() == 2);
+ assert(*r == Emplaceable(5, 6));
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_set<Emplaceable> C;
+ typedef C::iterator R;
+ C c1;
+ C c2;
+ R r = c1.emplace_hint(c2.begin(), 5, 6);
+ assert(false);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/eq.pass.cpp b/libcxx/test/std/containers/unord/unord.set/eq.pass.cpp
new file mode 100644
index 00000000000..54a9c2eced3
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/eq.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Key, class Hash, class Pred, class Alloc>
+// bool
+// operator==(const unordered_set<Key, Hash, Pred, Alloc>& x,
+// const unordered_set<Key, Hash, Pred, Alloc>& y);
+//
+// template <class Key, class Hash, class Pred, class Alloc>
+// bool
+// operator!=(const unordered_set<Key, Hash, Pred, Alloc>& x,
+// const unordered_set<Key, Hash, Pred, Alloc>& y);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2;
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2 = c1;
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a), std::end(a));
+ C c2 = c1;
+ c2.rehash(30);
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ c2.insert(P(90));
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ c1.insert(P(90));
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2;
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ }
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c1(std::begin(a), std::end(a));
+ const C c2 = c1;
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a), std::end(a));
+ C c2 = c1;
+ c2.rehash(30);
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ c2.insert(P(90));
+ assert(!(c1 == c2));
+ assert( (c1 != c2));
+ c1.insert(P(90));
+ assert( (c1 == c2));
+ assert(!(c1 != c2));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/equal_range_const.pass.cpp b/libcxx/test/std/containers/unord/unord.set/equal_range_const.pass.cpp
new file mode 100644
index 00000000000..4168903e020
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/equal_range_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// pair<const_iterator, const_iterator> equal_range(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 30);
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 50);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef C::const_iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 30);
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 50);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/equal_range_non_const.pass.cpp b/libcxx/test/std/containers/unord/unord.set/equal_range_non_const.pass.cpp
new file mode 100644
index 00000000000..5a55083ba8a
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/equal_range_non_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// pair<iterator, iterator> equal_range(const key_type& k);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef C::iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 30);
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 50);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef C::iterator I;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(50),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c(std::begin(a), std::end(a));
+ std::pair<I, I> r = c.equal_range(30);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 30);
+ r = c.equal_range(5);
+ assert(std::distance(r.first, r.second) == 0);
+ r = c.equal_range(50);
+ assert(std::distance(r.first, r.second) == 1);
+ assert(*r.first == 50);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/erase_const_iter.pass.cpp b/libcxx/test/std/containers/unord/unord.set/erase_const_iter.pass.cpp
new file mode 100644
index 00000000000..3a9cb5817df
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/erase_const_iter.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator erase(const_iterator p)
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::iterator j = c.erase(i);
+ assert(c.size() == 3);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::iterator j = c.erase(i);
+ assert(c.size() == 3);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/erase_iter_db1.pass.cpp b/libcxx/test/std/containers/unord/unord.set/erase_iter_db1.pass.cpp
new file mode 100644
index 00000000000..231152d14f4
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/erase_iter_db1.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator position) with end()
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_set<int> l1(a1, a1+3);
+ std::unordered_set<int>::const_iterator i = l1.end();
+ l1.erase(i);
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.set/erase_iter_db2.pass.cpp b/libcxx/test/std/containers/unord/unord.set/erase_iter_db2.pass.cpp
new file mode 100644
index 00000000000..06d61db017d
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/erase_iter_db2.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator position) with iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <cstdlib>
+#include <exception>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_set<int> l1(a1, a1+3);
+ std::unordered_set<int> l2(a1, a1+3);
+ std::unordered_set<int>::const_iterator i = l2.begin();
+ l1.erase(i);
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.set/erase_iter_iter_db1.pass.cpp b/libcxx/test/std/containers/unord/unord.set/erase_iter_iter_db1.pass.cpp
new file mode 100644
index 00000000000..92c77f5567d
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/erase_iter_iter_db1.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with first iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_set<int> l1(a1, a1+3);
+ std::unordered_set<int> l2(a1, a1+3);
+ std::unordered_set<int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.set/erase_iter_iter_db2.pass.cpp b/libcxx/test/std/containers/unord/unord.set/erase_iter_iter_db2.pass.cpp
new file mode 100644
index 00000000000..d6066589624
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/erase_iter_iter_db2.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with second iterator from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_set<int> l1(a1, a1+3);
+ std::unordered_set<int> l2(a1, a1+3);
+ std::unordered_set<int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.set/erase_iter_iter_db3.pass.cpp b/libcxx/test/std/containers/unord/unord.set/erase_iter_iter_db3.pass.cpp
new file mode 100644
index 00000000000..f7ff42621fe
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/erase_iter_iter_db3.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with both iterators from another container
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_set<int> l1(a1, a1+3);
+ std::unordered_set<int> l2(a1, a1+3);
+ std::unordered_set<int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin()));
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.set/erase_iter_iter_db4.pass.cpp b/libcxx/test/std/containers/unord/unord.set/erase_iter_iter_db4.pass.cpp
new file mode 100644
index 00000000000..6cde216f4a9
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/erase_iter_iter_db4.pass.cpp
@@ -0,0 +1,39 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// Call erase(const_iterator first, const_iterator last); with a bad range
+
+#if _LIBCPP_DEBUG >= 1
+
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+
+#include <unordered_set>
+#include <cassert>
+#include <exception>
+#include <cstdlib>
+
+int main()
+{
+ {
+ int a1[] = {1, 2, 3};
+ std::unordered_set<int> l1(a1, a1+3);
+ std::unordered_set<int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin());
+ assert(false);
+ }
+}
+
+#else
+
+int main()
+{
+}
+
+#endif
diff --git a/libcxx/test/std/containers/unord/unord.set/erase_key.pass.cpp b/libcxx/test/std/containers/unord/unord.set/erase_key.pass.cpp
new file mode 100644
index 00000000000..ca165083b02
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/erase_key.pass.cpp
@@ -0,0 +1,175 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type erase(const key_type& k);
+
+#include <unordered_set>
+#include <string>
+#include <cassert>
+
+#include "min_allocator.h"
+
+#if __cplusplus >= 201103L
+template <typename Unordered>
+bool only_deletions ( const Unordered &whole, const Unordered &part ) {
+ typename Unordered::const_iterator w = whole.begin();
+ typename Unordered::const_iterator p = part.begin();
+
+ while ( w != whole.end () && p != part.end()) {
+ if ( *w == *p )
+ p++;
+ w++;
+ }
+
+ return p == part.end();
+}
+#endif
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.erase(5) == 0);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(2) == 1);
+ assert(c.size() == 3);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(2) == 0);
+ assert(c.size() == 3);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(4) == 1);
+ assert(c.size() == 2);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(4) == 0);
+ assert(c.size() == 2);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(1) == 1);
+ assert(c.size() == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(1) == 0);
+ assert(c.size() == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(3) == 1);
+ assert(c.size() == 0);
+
+ assert(c.erase(3) == 0);
+ assert(c.size() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.erase(5) == 0);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(2) == 1);
+ assert(c.size() == 3);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(2) == 0);
+ assert(c.size() == 3);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ assert(c.erase(4) == 1);
+ assert(c.size() == 2);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(4) == 0);
+ assert(c.size() == 2);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(1) == 1);
+ assert(c.size() == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(1) == 0);
+ assert(c.size() == 1);
+ assert(c.count(3) == 1);
+
+ assert(c.erase(3) == 1);
+ assert(c.size() == 0);
+
+ assert(c.erase(3) == 0);
+ assert(c.size() == 0);
+ }
+ {
+ typedef std::unordered_set<int> C;
+ C m, m2;
+ for ( int i = 0; i < 10; ++i ) {
+ m.insert(i);
+ m2.insert(i);
+ }
+
+ C::iterator i = m2.begin();
+ int ctr = 0;
+ while (i != m2.end()) {
+ if (ctr++ % 2 == 0)
+ m2.erase(i++);
+ else
+ ++i;
+ }
+
+ assert (only_deletions (m, m2));
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/erase_range.pass.cpp b/libcxx/test/std/containers/unord/unord.set/erase_range.pass.cpp
new file mode 100644
index 00000000000..a8a900551c7
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/erase_range.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator erase(const_iterator first, const_iterator last)
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::const_iterator j = next(i);
+ C::iterator k = c.erase(i, i);
+ assert(k == i);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ k = c.erase(i, j);
+ assert(c.size() == 3);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ k = c.erase(c.cbegin(), c.cend());
+ assert(c.size() == 0);
+ assert(k == c.end());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C::const_iterator i = c.find(2);
+ C::const_iterator j = next(i);
+ C::iterator k = c.erase(i, i);
+ assert(k == i);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ k = c.erase(i, j);
+ assert(c.size() == 3);
+ assert(c.count(1) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+
+ k = c.erase(c.cbegin(), c.cend());
+ assert(c.size() == 0);
+ assert(k == c.end());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/find_const.pass.cpp b/libcxx/test/std/containers/unord/unord.set/find_const.pass.cpp
new file mode 100644
index 00000000000..e2238e5665f
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/find_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// const_iterator find(const key_type& k) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ C::const_iterator i = c.find(30);
+ assert(*i == 30);
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ C::const_iterator i = c.find(30);
+ assert(*i == 30);
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/find_non_const.pass.cpp b/libcxx/test/std/containers/unord/unord.set/find_non_const.pass.cpp
new file mode 100644
index 00000000000..8afe32abd72
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/find_non_const.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator find(const key_type& k);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c(std::begin(a), std::end(a));
+ C::iterator i = c.find(30);
+ assert(*i == 30);
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c(std::begin(a), std::end(a));
+ C::iterator i = c.find(30);
+ assert(*i == 30);
+ i = c.find(5);
+ assert(i == c.cend());
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp
new file mode 100644
index 00000000000..321e9054af6
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// pair<iterator, bool> insert(const value_type& x);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<double> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef C::value_type P;
+ C c;
+ R r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r.first == 3.5);
+ assert(r.second);
+
+ r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r.first == 3.5);
+ assert(!r.second);
+
+ r = c.insert(P(4.5));
+ assert(c.size() == 2);
+ assert(*r.first == 4.5);
+ assert(r.second);
+
+ r = c.insert(P(5.5));
+ assert(c.size() == 3);
+ assert(*r.first == 5.5);
+ assert(r.second);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<double, std::hash<double>,
+ std::equal_to<double>, min_allocator<double>> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef C::value_type P;
+ C c;
+ R r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r.first == 3.5);
+ assert(r.second);
+
+ r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r.first == 3.5);
+ assert(!r.second);
+
+ r = c.insert(P(4.5));
+ assert(c.size() == 2);
+ assert(*r.first == 4.5);
+ assert(r.second);
+
+ r = c.insert(P(5.5));
+ assert(c.size() == 3);
+ assert(*r.first == 5.5);
+ assert(r.second);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp
new file mode 100644
index 00000000000..1393f542011
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator insert(const_iterator p, const value_type& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<double> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(e, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(e, P(4.5));
+ assert(c.size() == 2);
+ assert(*r == 4.5);
+
+ r = c.insert(e, P(5.5));
+ assert(c.size() == 3);
+ assert(*r == 5.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<double, std::hash<double>,
+ std::equal_to<double>, min_allocator<double>> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(e, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(e, P(4.5));
+ assert(c.size() == 2);
+ assert(*r == 4.5);
+
+ r = c.insert(e, P(5.5));
+ assert(c.size() == 3);
+ assert(*r == 5.5);
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_set<double> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ P v(3.5);
+ R r = c.insert(e, v);
+ assert(false);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/insert_hint_rvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.set/insert_hint_rvalue.pass.cpp
new file mode 100644
index 00000000000..f612ec57249
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/insert_hint_rvalue.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator insert(const_iterator p, value_type&& x);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<double> C;
+ typedef C::iterator R;
+ typedef double P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(r, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(e, P(4.5));
+ assert(c.size() == 2);
+ assert(*r == 4.5);
+
+ r = c.insert(e, P(5.5));
+ assert(c.size() == 3);
+ assert(*r == 5.5);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_set<MoveOnly> C;
+ typedef C::iterator R;
+ typedef MoveOnly P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3));
+ assert(c.size() == 1);
+ assert(*r == 3);
+
+ r = c.insert(r, P(3));
+ assert(c.size() == 1);
+ assert(*r == 3);
+
+ r = c.insert(e, P(4));
+ assert(c.size() == 2);
+ assert(*r == 4);
+
+ r = c.insert(e, P(5));
+ assert(c.size() == 3);
+ assert(*r == 5);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<double, std::hash<double>,
+ std::equal_to<double>, min_allocator<double>> C;
+ typedef C::iterator R;
+ typedef double P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(r, P(3.5));
+ assert(c.size() == 1);
+ assert(*r == 3.5);
+
+ r = c.insert(e, P(4.5));
+ assert(c.size() == 2);
+ assert(*r == 4.5);
+
+ r = c.insert(e, P(5.5));
+ assert(c.size() == 3);
+ assert(*r == 5.5);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, min_allocator<MoveOnly>> C;
+ typedef C::iterator R;
+ typedef MoveOnly P;
+ C c;
+ C::const_iterator e = c.end();
+ R r = c.insert(e, P(3));
+ assert(c.size() == 1);
+ assert(*r == 3);
+
+ r = c.insert(r, P(3));
+ assert(c.size() == 1);
+ assert(*r == 3);
+
+ r = c.insert(e, P(4));
+ assert(c.size() == 2);
+ assert(*r == 4);
+
+ r = c.insert(e, P(5));
+ assert(c.size() == 3);
+ assert(*r == 5);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if _LIBCPP_DEBUG >= 1
+ {
+ typedef std::unordered_set<double> C;
+ typedef C::iterator R;
+ typedef C::value_type P;
+ C c;
+ C c2;
+ C::const_iterator e = c2.end();
+ R r = c.insert(e, P(3.5));
+ assert(false);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/insert_init.pass.cpp b/libcxx/test/std/containers/unord/unord.set/insert_init.pass.cpp
new file mode 100644
index 00000000000..2d8eafba489
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/insert_init.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// void insert(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ C c;
+ c.insert(
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ }
+ );
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ C c;
+ c.insert(
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ }
+ );
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/insert_range.pass.cpp b/libcxx/test/std/containers/unord/unord.set/insert_range.pass.cpp
new file mode 100644
index 00000000000..72a83abf74e
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/insert_range.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+// void insert(InputIterator first, InputIterator last);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "test_iterators.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c;
+ c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c;
+ c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/insert_rvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.set/insert_rvalue.pass.cpp
new file mode 100644
index 00000000000..d62308e7357
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/insert_rvalue.pass.cpp
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// pair<iterator, bool> insert(value_type&& x);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../MoveOnly.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<double> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef double P;
+ C c;
+ R r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r.first == 3.5);
+ assert(r.second);
+
+ r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r.first == 3.5);
+ assert(!r.second);
+
+ r = c.insert(P(4.5));
+ assert(c.size() == 2);
+ assert(*r.first == 4.5);
+ assert(r.second);
+
+ r = c.insert(P(5.5));
+ assert(c.size() == 3);
+ assert(*r.first == 5.5);
+ assert(r.second);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_set<MoveOnly> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef MoveOnly P;
+ C c;
+ R r = c.insert(P(3));
+ assert(c.size() == 1);
+ assert(*r.first == 3);
+ assert(r.second);
+
+ r = c.insert(P(3));
+ assert(c.size() == 1);
+ assert(*r.first == 3);
+ assert(!r.second);
+
+ r = c.insert(P(4));
+ assert(c.size() == 2);
+ assert(*r.first == 4);
+ assert(r.second);
+
+ r = c.insert(P(5));
+ assert(c.size() == 3);
+ assert(*r.first == 5);
+ assert(r.second);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<double, std::hash<double>,
+ std::equal_to<double>, min_allocator<double>> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef double P;
+ C c;
+ R r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r.first == 3.5);
+ assert(r.second);
+
+ r = c.insert(P(3.5));
+ assert(c.size() == 1);
+ assert(*r.first == 3.5);
+ assert(!r.second);
+
+ r = c.insert(P(4.5));
+ assert(c.size() == 2);
+ assert(*r.first == 4.5);
+ assert(r.second);
+
+ r = c.insert(P(5.5));
+ assert(c.size() == 3);
+ assert(*r.first == 5.5);
+ assert(r.second);
+ }
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, min_allocator<MoveOnly>> C;
+ typedef std::pair<C::iterator, bool> R;
+ typedef MoveOnly P;
+ C c;
+ R r = c.insert(P(3));
+ assert(c.size() == 1);
+ assert(*r.first == 3);
+ assert(r.second);
+
+ r = c.insert(P(3));
+ assert(c.size() == 1);
+ assert(*r.first == 3);
+ assert(!r.second);
+
+ r = c.insert(P(4));
+ assert(c.size() == 2);
+ assert(*r.first == 4);
+ assert(r.second);
+
+ r = c.insert(P(5));
+ assert(c.size() == 3);
+ assert(*r.first == 5);
+ assert(r.second);
+ }
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/iterators.fail.cpp b/libcxx/test/std/containers/unord/unord.set/iterators.fail.cpp
new file mode 100644
index 00000000000..2bb180b6e21
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/iterators.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator begin() {return __table_.begin();}
+// iterator end() {return __table_.end();}
+// const_iterator begin() const {return __table_.begin();}
+// const_iterator end() const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend() const {return __table_.end();}
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i = c.begin();
+ assert(*i == 1);
+ *i = 2;
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 6);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ }
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/iterators.pass.cpp b/libcxx/test/std/containers/unord/unord.set/iterators.pass.cpp
new file mode 100644
index 00000000000..d3a45801f16
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/iterators.pass.cpp
@@ -0,0 +1,127 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// iterator begin() {return __table_.begin();}
+// iterator end() {return __table_.end();}
+// const_iterator begin() const {return __table_.begin();}
+// const_iterator end() const {return __table_.end();}
+// const_iterator cbegin() const {return __table_.begin();}
+// const_iterator cend() const {return __table_.end();}
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i;
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::const_iterator i;
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::iterator i;
+ }
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ C::const_iterator i;
+ }
+#endif
+#if _LIBCPP_STD_VER > 11
+ { // N3644 testing
+ typedef std::unordered_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/unord/unord.set/load_factor.pass.cpp b/libcxx/test/std/containers/unord/unord.set/load_factor.pass.cpp
new file mode 100644
index 00000000000..e0ed1694b05
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/load_factor.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// float load_factor() const
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ const C c;
+ assert(c.load_factor() == 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ const C c(std::begin(a), std::end(a));
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ }
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ const C c;
+ assert(c.load_factor() == 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/local_iterators.fail.cpp b/libcxx/test/std/containers/unord/unord.set/local_iterators.fail.cpp
new file mode 100644
index 00000000000..eb671a442f1
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/local_iterators.fail.cpp
@@ -0,0 +1,261 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// local_iterator begin (size_type n);
+// local_iterator end (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend (size_type n) const;
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+ *i = 2;
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 1);
+ ++i;
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 2);
+ assert(*i == 2);
+ ++i;
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+
+ b = c.bucket(5);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(6);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+ }
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/local_iterators.pass.cpp b/libcxx/test/std/containers/unord/unord.set/local_iterators.pass.cpp
new file mode 100644
index 00000000000..2ffd93f30d1
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/local_iterators.pass.cpp
@@ -0,0 +1,388 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// local_iterator begin (size_type n);
+// local_iterator end (size_type n);
+// const_local_iterator begin (size_type n) const;
+// const_local_iterator end (size_type n) const;
+// const_local_iterator cbegin(size_type n) const;
+// const_local_iterator cend (size_type n) const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ typedef C::local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+ }
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.begin(b);
+ I j = c.end(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.begin(b);
+ j = c.end(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+ }
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+ }
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ typedef C::const_local_iterator I;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ const C c(a, a + sizeof(a)/sizeof(a[0]));
+ assert(c.bucket_count() >= 5);
+ C::size_type b = c.bucket(0);
+ I i = c.cbegin(b);
+ I j = c.cend(b);
+ assert(std::distance(i, j) == 0);
+
+ b = c.bucket(1);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 1);
+
+ b = c.bucket(2);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 2);
+
+ b = c.bucket(3);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 3);
+
+ b = c.bucket(4);
+ i = c.cbegin(b);
+ j = c.cend(b);
+ assert(std::distance(i, j) == 1);
+ assert(*i == 4);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/max_bucket_count.pass.cpp b/libcxx/test/std/containers/unord/unord.set/max_bucket_count.pass.cpp
new file mode 100644
index 00000000000..8b5e265de3f
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/max_bucket_count.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type max_bucket_count() const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ const C c;
+ assert(c.max_bucket_count() > 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ const C c;
+ assert(c.max_bucket_count() > 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/max_load_factor.pass.cpp b/libcxx/test/std/containers/unord/unord.set/max_load_factor.pass.cpp
new file mode 100644
index 00000000000..d326f4a2d7e
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/max_load_factor.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// float max_load_factor() const;
+// void max_load_factor(float mlf);
+
+#ifdef _LIBCPP_DEBUG
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ const C c;
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ C c;
+ assert(c.max_load_factor() == 1);
+ c.max_load_factor(2.5);
+ assert(c.max_load_factor() == 2.5);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ const C c;
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ C c;
+ assert(c.max_load_factor() == 1);
+ c.max_load_factor(2.5);
+ assert(c.max_load_factor() == 2.5);
+ }
+#endif
+#if _LIBCPP_DEBUG_LEVEL >= 1
+ {
+ typedef std::unordered_set<int> C;
+ C c;
+ c.max_load_factor(-0.5f);
+ assert(false);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/max_size.pass.cpp b/libcxx/test/std/containers/unord/unord.set/max_size.pass.cpp
new file mode 100644
index 00000000000..1c6e74125c7
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/max_size.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// size_type max_size() const;
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ std::unordered_set<int> u;
+ assert(u.max_size() > 0);
+ }
+#if __cplusplus >= 201103L
+ {
+ std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> u;
+ assert(u.max_size() > 0);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/rehash.pass.cpp b/libcxx/test/std/containers/unord/unord.set/rehash.pass.cpp
new file mode 100644
index 00000000000..30fffa561f7
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/rehash.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// void rehash(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+}
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 5);
+ c.rehash(3);
+ assert(c.bucket_count() == 5);
+ test(c);
+ c.max_load_factor(2);
+ c.rehash(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.rehash(31);
+ assert(c.bucket_count() == 31);
+ test(c);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 5);
+ c.rehash(3);
+ assert(c.bucket_count() == 5);
+ test(c);
+ c.max_load_factor(2);
+ c.rehash(3);
+ assert(c.bucket_count() == 3);
+ test(c);
+ c.rehash(31);
+ assert(c.bucket_count() == 31);
+ test(c);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/reserve.pass.cpp b/libcxx/test/std/containers/unord/unord.set/reserve.pass.cpp
new file mode 100644
index 00000000000..7d6656a1867
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/reserve.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// void reserve(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "min_allocator.h"
+
+template <class C>
+void test(const C& c)
+{
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+}
+
+int main()
+{
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 5);
+ c.reserve(3);
+ assert(c.bucket_count() == 5);
+ test(c);
+ c.max_load_factor(2);
+ c.reserve(3);
+ assert(c.bucket_count() >= 2);
+ test(c);
+ c.reserve(31);
+ assert(c.bucket_count() >= 16);
+ test(c);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int, std::hash<int>,
+ std::equal_to<int>, min_allocator<int>> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ test(c);
+ assert(c.bucket_count() >= 5);
+ c.reserve(3);
+ assert(c.bucket_count() == 5);
+ test(c);
+ c.max_load_factor(2);
+ c.reserve(3);
+ assert(c.bucket_count() >= 2);
+ test(c);
+ c.reserve(31);
+ assert(c.bucket_count() >= 16);
+ test(c);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/swap_member.pass.cpp b/libcxx/test/std/containers/unord/unord.set/swap_member.pass.cpp
new file mode 100644
index 00000000000..89ec986d08f
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/swap_member.pass.cpp
@@ -0,0 +1,571 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// void swap(unordered_set& u);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../test_compare.h"
+#include "../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ c1.swap(c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/types.pass.cpp b/libcxx/test/std/containers/unord/unord.set/types.pass.cpp
new file mode 100644
index 00000000000..7e752a434ec
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/types.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+// {
+// public:
+// // types
+// typedef Value value_type;
+// typedef value_type key_type;
+// typedef Hash hasher;
+// typedef Pred key_equal;
+// typedef Alloc allocator_type;
+// typedef value_type& reference;
+// typedef const value_type& const_reference;
+// typedef typename allocator_traits<allocator_type>::pointer pointer;
+// typedef typename allocator_traits<allocator_type>::const_pointer const_pointer;
+// typedef typename allocator_traits<allocator_type>::size_type size_type;
+// typedef typename allocator_traits<allocator_type>::difference_type difference_type;
+
+#include <unordered_set>
+#include <type_traits>
+
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<short> C;
+ static_assert((std::is_same<C::value_type, short>::value), "");
+ static_assert((std::is_same<C::key_type, short>::value), "");
+ static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+ static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+ static_assert((std::is_same<C::allocator_type, std::allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, C::value_type*>::value), "");
+ static_assert((std::is_same<C::const_pointer, const C::value_type*>::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::unordered_set<short, std::hash<short>,
+ std::equal_to<short>, min_allocator<short>> C;
+ static_assert((std::is_same<C::value_type, short>::value), "");
+ static_assert((std::is_same<C::key_type, short>::value), "");
+ static_assert((std::is_same<C::hasher, std::hash<C::key_type> >::value), "");
+ static_assert((std::is_same<C::key_equal, std::equal_to<C::key_type> >::value), "");
+ static_assert((std::is_same<C::allocator_type, min_allocator<C::value_type> >::value), "");
+ static_assert((std::is_same<C::reference, C::value_type&>::value), "");
+ static_assert((std::is_same<C::const_reference, const C::value_type&>::value), "");
+ static_assert((std::is_same<C::pointer, min_pointer<C::value_type>>::value), "");
+ static_assert((std::is_same<C::const_pointer, min_pointer<const C::value_type>>::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/unord/unord.set/unord.set.cnstr/allocator.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp
new file mode 100644
index 00000000000..30905aeb9fe
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/allocator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// explicit unordered_set(const allocator_type& __a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c(test_allocator<NotConstructible>(10));
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == test_allocator<NotConstructible>(10));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c(min_allocator<NotConstructible>{});
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == min_allocator<NotConstructible>());
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef NotConstructible T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_set<T, HF, Comp, A> C;
+
+ A a(43);
+ C c(3, a);
+ assert(c.bucket_count() == 3);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp ());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef NotConstructible T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_set<T, HF, Comp, A> C;
+
+ HF hf(42);
+ A a(43);
+ C c(4, hf, a);
+ assert(c.bucket_count() == 4);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp ());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp
new file mode 100644
index 00000000000..6925e304541
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp
@@ -0,0 +1,184 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set& operator=(const unordered_set& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(4));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef std::unordered_set<int> C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(a, a + sizeof(a)/sizeof(a[0]));
+ C *p = &c;
+ c = *p;
+ assert(c.size() == 4);
+ assert(std::is_permutation(c.begin(), c.end(), a));
+ }
+ {
+ typedef other_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = c0;
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A()
+ );
+ c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp
new file mode 100644
index 00000000000..69d19a4dac2
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set& operator=(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef test_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ C c = {
+ P(4),
+ P(1),
+ P(2)
+ };
+ c = {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ C c = {
+ P(4),
+ P(1),
+ P(2)
+ };
+ c = {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp
new file mode 100644
index 00000000000..e8712b7431c
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp
@@ -0,0 +1,225 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set& operator=(unordered_set&& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef test_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(4));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef test_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(10)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef other_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A(4)
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef min_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(a, a + 2,
+ 7,
+ test_hash<std::hash<int> >(2),
+ test_compare<std::equal_to<int> >(3),
+ A()
+ );
+ c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::unordered_set<int> s1 = {1, 2, 3};
+ std::unordered_set<int>::iterator i = s1.begin();
+ int k = *i;
+ std::unordered_set<int> s2;
+ s2 = std::move(s1);
+ assert(*i == k);
+ s2.erase(i);
+ assert(s2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp
new file mode 100644
index 00000000000..ee05acd6be9
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp
@@ -0,0 +1,147 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(const unordered_set& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ other_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ other_allocator<int>(10)
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == other_allocator<int>(-2));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ C c = c0;
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp
new file mode 100644
index 00000000000..8e1ecd8167f
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/copy_alloc.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(const unordered_set& u, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ C c(c0, test_allocator<int>(5));
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(5));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ C c(c0, min_allocator<int>());
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp
new file mode 100644
index 00000000000..6efa9ed8d1d
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp
@@ -0,0 +1,74 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set();
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c;
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c;
+ assert(c.bucket_count() == 0);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ std::unordered_set<int> c = {};
+ assert(c.bucket_count() == 0);
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp
new file mode 100644
index 00000000000..b3cd9c3f1ff
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// unordered_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 <unordered_set>
+#include <cassert>
+
+#include "../../../MoveOnly.h"
+#include "test_allocator.h"
+#include "../../../test_hash.h"
+
+template <class T>
+struct some_comp
+{
+ typedef T value_type;
+ some_comp();
+ some_comp(const some_comp&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_set<MoveOnly> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_default_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp
new file mode 100644
index 00000000000..68ef7f4f9ae
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// ~unordered_set() // implied noexcept;
+
+#include <unordered_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);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+ ~some_hash() noexcept(false);
+};
+
+#endif
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_set<MoveOnly> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_destructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp
new file mode 100644
index 00000000000..2c31d575b63
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp
@@ -0,0 +1,163 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(initializer_list<value_type> il);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ C c = {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ C c = {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_set<T, HF, Comp, A> C;
+
+ A a(42);
+ C c({
+ T(1),
+ T(2),
+ T(3),
+ T(4),
+ T(1),
+ T(2)
+ }, 12, a);
+
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef int T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_set<T, HF, Comp, A> C;
+
+ A a(42);
+ HF hf(43);
+ C c({
+ T(1),
+ T(2),
+ T(3),
+ T(4),
+ T(1),
+ T(2)
+ }, 12, hf, a);
+
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp
new file mode 100644
index 00000000000..36dab799c78
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp
@@ -0,0 +1,97 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(initializer_list<value_type> il, size_type n);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp
new file mode 100644
index 00000000000..81af2b41bae
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(initializer_list<value_type> il, size_type n,
+// const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp
new file mode 100644
index 00000000000..f35dd1afa87
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp
@@ -0,0 +1,102 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(initializer_list<value_type> il, size_type n,
+// const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 00000000000..34ff62ea77b
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(initializer_list<value_type> il, size_type n,
+// const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ C c({
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ },
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp
new file mode 100644
index 00000000000..6bda4afc99c
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp
@@ -0,0 +1,194 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(unordered_set&& u);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 0);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(10));
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 0);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ C c = std::move(c0);
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#endif
+#if _LIBCPP_DEBUG >= 1
+ {
+ std::unordered_set<int> s1 = {1, 2, 3};
+ std::unordered_set<int>::iterator i = s1.begin();
+ int k = *i;
+ std::unordered_set<int> s2 = std::move(s1);
+ assert(*i == k);
+ s2.erase(i);
+ assert(s2.size() == 2);
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp
new file mode 100644
index 00000000000..229e79925f2
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp
@@ -0,0 +1,156 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(unordered_set&& u, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+ {
+ typedef int P;
+ typedef test_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(std::move(c0), A(12));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(12));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+ {
+ typedef int P;
+ typedef test_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A(10)
+ );
+ C c(std::move(c0), A(10));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef int P;
+ typedef min_allocator<int> A;
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ A
+ > C;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c0(a, a + sizeof(a)/sizeof(a[0]),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ A()
+ );
+ C c(std::move(c0), A());
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == A());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+
+ assert(c0.empty());
+ }
+#endif
+#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp
new file mode 100644
index 00000000000..c3c94fd1a04
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// unordered_set& operator=(unordered_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 <unordered_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&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+ some_hash& operator=(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_set<MoveOnly> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_assignable<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp
new file mode 100644
index 00000000000..791a67d2119
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp
@@ -0,0 +1,66 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// unordered_set(unordered_set&&)
+// noexcept(is_nothrow_move_constructible<allocator_type>::value &&
+// is_nothrow_move_constructible<key_compare>::value);
+
+// This tests a conforming extension
+
+#include <unordered_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&);
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash();
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_set<MoveOnly> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+ static_assert(std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ static_assert(!std::is_nothrow_move_constructible<C>::value, "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp
new file mode 100644
index 00000000000..40f3f4f4d7f
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/range.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+// unordered_set(InputIterator first, InputIterator last);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
+ assert(c.bucket_count() >= 5);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if _LIBCPP_STD_VER > 11
+ {
+ typedef int T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_set<T, HF, Comp, A> C;
+ T arr[] =
+ {
+ T(1),
+ T(2),
+ T(3),
+ T(4),
+ T(1),
+ T(2)
+ };
+ A a(42);
+ C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 12, a);
+ assert(c.bucket_count() >= 12);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == HF());
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+ {
+ typedef int T;
+ typedef test_hash<std::hash<T>> HF;
+ typedef test_compare<std::equal_to<T>> Comp;
+ typedef test_allocator<T> A;
+ typedef std::unordered_set<T, HF, Comp, A> C;
+ T arr[] =
+ {
+ T(1),
+ T(2),
+ T(3),
+ T(4),
+ T(1),
+ T(2)
+ };
+ HF hf(43);
+ A a(42);
+ C c(input_iterator<T*>(arr), input_iterator<T*>(arr + sizeof(arr)/sizeof(arr[0])), 16, hf, a);
+ assert(c.bucket_count() >= 16);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == hf);
+ assert(!(c.hash_function() == HF()));
+ assert(c.key_eq() == Comp());
+ assert(c.get_allocator() == a);
+ assert(!(c.get_allocator() == A()));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+
+#endif
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp
new file mode 100644
index 00000000000..179f73d7e18
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/range_size.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+// unordered_set(InputIterator first, InputIterator last, size_type n);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >());
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp
new file mode 100644
index 00000000000..60350de962c
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+// unordered_set(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >());
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp
new file mode 100644
index 00000000000..70e82d03464
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp
@@ -0,0 +1,106 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+// unordered_set(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp
new file mode 100644
index 00000000000..a6fb2e667ae
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// template <class InputIterator>
+// unordered_set(InputIterator first, InputIterator last, size_type n,
+// const hasher& hf, const key_equal& eql,
+// const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+#include <cfloat>
+
+#include "test_iterators.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ test_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ test_allocator<int>(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == test_allocator<int>(10));
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<int,
+ test_hash<std::hash<int> >,
+ test_compare<std::equal_to<int> >,
+ min_allocator<int>
+ > C;
+ typedef int P;
+ P a[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])),
+ 7,
+ test_hash<std::hash<int> >(8),
+ test_compare<std::equal_to<int> >(9),
+ min_allocator<int>()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.size() == 4);
+ assert(c.count(1) == 1);
+ assert(c.count(2) == 1);
+ assert(c.count(3) == 1);
+ assert(c.count(4) == 1);
+ assert(c.hash_function() == test_hash<std::hash<int> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<int> >(9));
+ assert(c.get_allocator() == min_allocator<int>());
+ assert(!c.empty());
+ assert(std::distance(c.begin(), c.end()) == c.size());
+ assert(std::distance(c.cbegin(), c.cend()) == c.size());
+ assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/size.fail.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/size.fail.cpp
new file mode 100644
index 00000000000..389c54c58cd
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/size.fail.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// explicit unordered_set(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c = 7;
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp
new file mode 100644
index 00000000000..8f6228ad8ec
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp
@@ -0,0 +1,65 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// explicit unordered_set(size_type n);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c(7);
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c(7);
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >());
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp
new file mode 100644
index 00000000000..4c2c18edd1c
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(size_type n, const hasher& hf);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >());
+ assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.pass.cpp
new file mode 100644
index 00000000000..e9368782ad9
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(size_type n, const hasher& hf, const key_equal& eql);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() == (test_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp
new file mode 100644
index 00000000000..96233e187af
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// unordered_set(size_type n, const hasher& hf, const key_equal& eql, const allocator_type& a);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../NotConstructible.h"
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ test_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9),
+ test_allocator<NotConstructible>(10)
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() == (test_allocator<NotConstructible>(10)));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef std::unordered_set<NotConstructible,
+ test_hash<std::hash<NotConstructible> >,
+ test_compare<std::equal_to<NotConstructible> >,
+ min_allocator<NotConstructible>
+ > C;
+ C c(7,
+ test_hash<std::hash<NotConstructible> >(8),
+ test_compare<std::equal_to<NotConstructible> >(9),
+ min_allocator<NotConstructible>()
+ );
+ assert(c.bucket_count() == 7);
+ assert(c.hash_function() == test_hash<std::hash<NotConstructible> >(8));
+ assert(c.key_eq() == test_compare<std::equal_to<NotConstructible> >(9));
+ assert(c.get_allocator() == (min_allocator<NotConstructible>()));
+ assert(c.size() == 0);
+ assert(c.empty());
+ assert(std::distance(c.begin(), c.end()) == 0);
+ assert(c.load_factor() == 0);
+ assert(c.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.swap/db_swap_1.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.swap/db_swap_1.pass.cpp
new file mode 100644
index 00000000000..2e8250ef783
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.swap/db_swap_1.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// void swap(unordered_set& x, unordered_set& y);
+
+#if _LIBCPP_DEBUG >= 1
+#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0))
+#endif
+
+#include <unordered_set>
+#include <cassert>
+
+int main()
+{
+#if _LIBCPP_DEBUG >= 1
+ {
+ int a1[] = {1, 3, 7, 9, 10};
+ int a2[] = {0, 2, 4, 5, 6, 8, 11};
+ std::unordered_set<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0]));
+ std::unordered_set<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0]));
+ std::unordered_set<int>::iterator i1 = c1.begin();
+ std::unordered_set<int>::iterator i2 = c2.begin();
+ swap(c1, c2);
+ c1.erase(i2);
+ c2.erase(i1);
+ std::unordered_set<int>::iterator j = i1;
+ c1.erase(i1);
+ assert(false);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp
new file mode 100644
index 00000000000..359e2968cc2
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// void swap(unordered_set& c)
+// noexcept(!allocator_type::propagate_on_container_swap::value ||
+// __is_nothrow_swappable<allocator_type>::value);
+
+// This tests a conforming extension
+
+#include <unordered_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&) {}
+};
+
+template <class T>
+struct some_hash
+{
+ typedef T value_type;
+ some_hash() {}
+ some_hash(const some_hash&);
+};
+
+int main()
+{
+#if __has_feature(cxx_noexcept)
+ {
+ typedef std::unordered_set<MoveOnly> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, test_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ std::equal_to<MoveOnly>, other_allocator<MoveOnly>> C;
+ C c1, c2;
+ static_assert(noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, some_hash<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+ {
+ typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>,
+ some_comp<MoveOnly>> C;
+ C c1, c2;
+ static_assert(!noexcept(swap(c1, c2)), "");
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp b/libcxx/test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp
new file mode 100644
index 00000000000..7415e297771
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp
@@ -0,0 +1,571 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
+// class Alloc = allocator<Value>>
+// class unordered_set
+
+// void swap(unordered_set& x, unordered_set& y);
+
+#include <unordered_set>
+#include <cassert>
+
+#include "../../../test_compare.h"
+#include "../../../test_hash.h"
+#include "test_allocator.h"
+#include "min_allocator.h"
+
+int main()
+{
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef test_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(1));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(2));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef other_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc(1));
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc(2));
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc(2));
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc(1));
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#if __cplusplus >= 201103L
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() == 0);
+ assert(c2.size() == 0);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() == 0);
+ assert(c1.size() == 0);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+ {
+ typedef test_hash<std::hash<int> > Hash;
+ typedef test_compare<std::equal_to<int> > Compare;
+ typedef min_allocator<int> Alloc;
+ typedef std::unordered_set<int, Hash, Compare, Alloc> C;
+ typedef int P;
+ P a1[] =
+ {
+ P(1),
+ P(2),
+ P(3),
+ P(4),
+ P(1),
+ P(2)
+ };
+ P a2[] =
+ {
+ P(10),
+ P(20),
+ P(30),
+ P(40),
+ P(50),
+ P(60),
+ P(70),
+ P(80)
+ };
+ C c1(std::begin(a1), std::end(a1), 0, Hash(1), Compare(1), Alloc());
+ C c2(std::begin(a2), std::end(a2), 0, Hash(2), Compare(2), Alloc());
+ c2.max_load_factor(2);
+ swap(c1, c2);
+
+ assert(c1.bucket_count() >= 11);
+ assert(c1.size() == 8);
+ assert(*c1.find(10) == 10);
+ assert(*c1.find(20) == 20);
+ assert(*c1.find(30) == 30);
+ assert(*c1.find(40) == 40);
+ assert(*c1.find(50) == 50);
+ assert(*c1.find(60) == 60);
+ assert(*c1.find(70) == 70);
+ assert(*c1.find(80) == 80);
+ assert(c1.hash_function() == Hash(2));
+ assert(c1.key_eq() == Compare(2));
+ assert(c1.get_allocator() == Alloc());
+ assert(std::distance(c1.begin(), c1.end()) == c1.size());
+ assert(std::distance(c1.cbegin(), c1.cend()) == c1.size());
+ assert(c1.max_load_factor() == 2);
+
+ assert(c2.bucket_count() >= 5);
+ assert(c2.size() == 4);
+ assert(c2.count(1) == 1);
+ assert(c2.count(2) == 1);
+ assert(c2.count(3) == 1);
+ assert(c2.count(4) == 1);
+ assert(c2.hash_function() == Hash(1));
+ assert(c2.key_eq() == Compare(1));
+ assert(c2.get_allocator() == Alloc());
+ assert(std::distance(c2.begin(), c2.end()) == c2.size());
+ assert(std::distance(c2.cbegin(), c2.cend()) == c2.size());
+ assert(c2.max_load_factor() == 1);
+ }
+#endif
+}
diff --git a/libcxx/test/std/containers/unord/unord.set/version.pass.cpp b/libcxx/test/std/containers/unord/unord.set/version.pass.cpp
new file mode 100644
index 00000000000..d651ebdfc45
--- /dev/null
+++ b/libcxx/test/std/containers/unord/unord.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.
+//
+//===----------------------------------------------------------------------===//
+
+// <unordered_set>
+
+#include <unordered_set>
+
+#ifndef _LIBCPP_VERSION
+#error _LIBCPP_VERSION not defined
+#endif
+
+int main()
+{
+}
OpenPOWER on IntegriCloud