Index: libcxx/test/std/containers/associative/multiset/insert_cv.pass.cpp =================================================================== --- libcxx/test/std/containers/associative/multiset/insert_cv.pass.cpp +++ libcxx/test/std/containers/associative/multiset/insert_cv.pass.cpp @@ -18,56 +18,44 @@ #include "min_allocator.h" +template +void do_insert_cv_test() +{ + typedef Container M; + typedef typename M::iterator R; + typedef typename M::value_type VT; + M m; + const VT v1(2); + R r = m.insert(v1); + assert(r == m.begin()); + assert(m.size() == 1); + assert(*r == 2); + + const VT v2(1); + r = m.insert(v2); + assert(r == m.begin()); + assert(m.size() == 2); + assert(*r == 1); + + const VT v3(3); + r = m.insert(v3); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(*r == 3); + + r = m.insert(v3); + assert(r == prev(m.end())); + assert(m.size() == 4); + assert(*r == 3); +} + int main() { - { - typedef std::multiset 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); - } + do_insert_cv_test >(); #if TEST_STD_VER >= 11 { typedef std::multiset, min_allocator> 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); + do_insert_cv_test(); } #endif } Index: libcxx/test/std/containers/associative/set/insert_cv.pass.cpp =================================================================== --- libcxx/test/std/containers/associative/set/insert_cv.pass.cpp +++ libcxx/test/std/containers/associative/set/insert_cv.pass.cpp @@ -18,64 +18,49 @@ #include "min_allocator.h" +template +void do_insert_cv_test() +{ + typedef Container M; + typedef std::pair R; + typedef typename M::value_type VT; + M m; + + const VT v1(2); + R r = m.insert(v1); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 1); + assert(*r.first == 2); + + const VT v2(1); + r = m.insert(v2); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 2); + assert(*r.first == 1); + + const VT v3(3); + r = m.insert(v3); + assert(r.second); + assert(r.first == prev(m.end())); + assert(m.size() == 3); + assert(*r.first == 3); + + r = m.insert(v3); + assert(!r.second); + assert(r.first == prev(m.end())); + assert(m.size() == 3); + assert(*r.first == 3); +} + int main() { - { - typedef std::set M; - typedef std::pair 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); - } + do_insert_cv_test >(); #if TEST_STD_VER >= 11 { typedef std::set, min_allocator> M; - typedef std::pair 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); + do_insert_cv_test(); } #endif } Index: libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp =================================================================== --- libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp +++ libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp @@ -37,28 +37,29 @@ assert(r.first->first == 2.5); assert(r.first->second == 2); - r = m.insert(VT(2.5, 3)); // test rvalue insertion works in C++03 - assert(!r.second); - assert(m.size() == 1); - assert(r.first->first == 2.5); - assert(r.first->second == 2); - - const VT v2(1.5, 1); + const VT v2(2.5, 3); r = m.insert(v2); + assert(!r.second); + assert(m.size() == 1); + assert(r.first->first == 2.5); + assert(r.first->second == 2); + + const VT v3(1.5, 1); + r = m.insert(v3); assert(r.second); assert(m.size() == 2); assert(r.first->first == 1.5); assert(r.first->second == 1); - const VT v3(3.5, 3); - r = m.insert(v3); - assert(r.second); - assert(m.size() == 3); - assert(r.first->first == 3.5); - assert(r.first->second == 3); - - const VT v4(3.5, 4); + const VT v4(3.5, 3); r = m.insert(v4); + assert(r.second); + assert(m.size() == 3); + assert(r.first->first == 3.5); + assert(r.first->second == 3); + + const VT v5(3.5, 4); + r = m.insert(v5); assert(!r.second); assert(m.size() == 3); assert(r.first->first == 3.5); Index: libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp =================================================================== --- libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp +++ libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp @@ -24,61 +24,48 @@ #include "min_allocator.h" +template +void do_insert_hint_const_lvalue_test() +{ + typedef Container C; + typedef typename C::iterator R; + typedef typename C::value_type VT; + C c; + typename C::const_iterator e = c.end(); + const VT v1(3.5, 3); + R r = c.insert(e, v1); + assert(c.size() == 1); + assert(r->first == 3.5); + assert(r->second == 3); + + const VT v2(3.5, 4); + r = c.insert(c.end(), v2); + assert(c.size() == 1); + assert(r->first == 3.5); + assert(r->second == 3); + + const VT v3(4.5, 4); + r = c.insert(c.end(), v3); + assert(c.size() == 2); + assert(r->first == 4.5); + assert(r->second == 4); + + const VT v4(5.5, 4); + r = c.insert(c.end(), v4); + assert(c.size() == 3); + assert(r->first == 5.5); + assert(r->second == 4); +} + int main() { - { - typedef std::unordered_map 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); - } + do_insert_hint_const_lvalue_test >(); #if TEST_STD_VER >= 11 { typedef std::unordered_map, std::equal_to, min_allocator>> 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); + do_insert_hint_const_lvalue_test(); } #endif #if _LIBCPP_DEBUG >= 1 Index: libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp =================================================================== --- libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp +++ libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp @@ -20,59 +20,46 @@ #include "min_allocator.h" +template +void do_insert_const_lvalue_test() +{ + typedef Container C; + typedef typename C::iterator R; + typedef typename C::value_type VT; + C c; + const VT v1(3.5, 3); + R r = c.insert(v1); + assert(c.size() == 1); + assert(r->first == 3.5); + assert(r->second == 3); + + const VT v2(3.5, 4); + r = c.insert(v2); + assert(c.size() == 2); + assert(r->first == 3.5); + assert(r->second == 4); + + const VT v3(4.5, 4); + r = c.insert(v3); + assert(c.size() == 3); + assert(r->first == 4.5); + assert(r->second == 4); + + const VT v4(5.5, 4); + r = c.insert(v4); + assert(c.size() == 4); + assert(r->first == 5.5); + assert(r->second == 4); +} + int main() { - { - typedef std::unordered_multimap 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); - } + do_insert_const_lvalue_test >(); #if TEST_STD_VER >= 11 { typedef std::unordered_multimap, std::equal_to, min_allocator>> 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); + do_insert_const_lvalue_test(); } #endif } Index: libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp =================================================================== --- libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp +++ libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp @@ -24,61 +24,47 @@ #include "min_allocator.h" +template +void do_insert_const_lvalue_test() +{ + typedef Container C; + typedef typename C::iterator R; + typedef typename C::value_type VT; + C c; + typename C::const_iterator e = c.end(); + const VT v1(3.5, 3); + R r = c.insert(e, v1); + assert(c.size() == 1); + assert(r->first == 3.5); + assert(r->second == 3); + + const VT v2(3.5, 4); + r = c.insert(c.end(), v2); + assert(c.size() == 2); + assert(r->first == 3.5); + assert(r->second == 4); + + const VT v3(4.5, 4); + r = c.insert(c.end(), v3); + assert(c.size() == 3); + assert(r->first == 4.5); + assert(r->second == 4); + + const VT v4(5.5, 4); + r = c.insert(c.end(), v4); + assert(c.size() == 4); + assert(r->first == 5.5); + assert(r->second == 4); +} + int main() { - { - typedef std::unordered_multimap 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); - } + do_insert_const_lvalue_test >(); #if TEST_STD_VER >= 11 { typedef std::unordered_multimap, std::equal_to, min_allocator>> 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); + do_insert_const_lvalue_test(); } #endif #if _LIBCPP_DEBUG >= 1 Index: libcxx/test/std/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp =================================================================== --- libcxx/test/std/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp +++ libcxx/test/std/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp @@ -20,51 +20,41 @@ #include "min_allocator.h" +template +void do_insert_const_lvalue_test() +{ + typedef Container C; + typedef typename C::iterator R; + typedef typename C::value_type VT; + C c; + const VT v1(3.5); + R r = c.insert(v1); + assert(c.size() == 1); + assert(*r == 3.5); + + r = c.insert(v1); + assert(c.size() == 2); + assert(*r == 3.5); + + const VT v2(4.5); + r = c.insert(v2); + assert(c.size() == 3); + assert(*r == 4.5); + + const VT v3(5.5); + r = c.insert(v3); + assert(c.size() == 4); + assert(*r == 5.5); +} + int main() { - { - typedef std::unordered_multiset 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); - } + do_insert_const_lvalue_test >(); #if TEST_STD_VER >= 11 { typedef std::unordered_multiset, - std::equal_to, min_allocator> 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); + std::equal_to, min_allocator> C; + do_insert_const_lvalue_test(); } #endif } Index: libcxx/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp =================================================================== --- libcxx/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp +++ libcxx/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp @@ -24,53 +24,42 @@ #include "min_allocator.h" +template +void do_insert_hint_const_lvalue_test() +{ + typedef Container C; + typedef typename C::iterator R; + typedef typename C::value_type VT; + C c; + typename C::const_iterator e = c.end(); + const VT v1(3.5); + R r = c.insert(e, v1); + assert(c.size() == 1); + assert(*r == 3.5); + + r = c.insert(c.end(), v1); + assert(c.size() == 2); + assert(*r == 3.5); + + const VT v2(4.5); + r = c.insert(c.end(), v2); + assert(c.size() == 3); + assert(*r == 4.5); + + const VT v3(5.5); + r = c.insert(c.end(), v3); + assert(c.size() == 4); + assert(*r == 5.5); +} + int main() { - { - typedef std::unordered_multiset 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); - } + do_insert_hint_const_lvalue_test >(); #if TEST_STD_VER >= 11 { typedef std::unordered_multiset, - std::equal_to, min_allocator> 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); + std::equal_to, min_allocator> C; + do_insert_hint_const_lvalue_test(); } #endif #if _LIBCPP_DEBUG >= 1 Index: libcxx/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp =================================================================== --- libcxx/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp +++ libcxx/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp @@ -20,59 +20,45 @@ #include "min_allocator.h" +template +void do_insert_const_lvalue_test() +{ + typedef Container C; + typedef std::pair R; + typedef typename C::value_type VT; + C c; + const VT v1(3.5); + R r = c.insert(v1); + assert(c.size() == 1); + assert(*r.first == 3.5); + assert(r.second); + + r = c.insert(v1); + assert(c.size() == 1); + assert(*r.first == 3.5); + assert(!r.second); + + const VT v2(4.5); + r = c.insert(v2); + assert(c.size() == 2); + assert(*r.first == 4.5); + assert(r.second); + + const VT v3(5.5); + r = c.insert(v3); + assert(c.size() == 3); + assert(*r.first == 5.5); + assert(r.second); +} + int main() { - { - typedef std::unordered_set C; - typedef std::pair 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); - } + do_insert_const_lvalue_test >(); #if TEST_STD_VER >= 11 { typedef std::unordered_set, std::equal_to, min_allocator> C; - typedef std::pair 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); + do_insert_const_lvalue_test(); } #endif } Index: libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp =================================================================== --- libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp +++ libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp @@ -24,53 +24,42 @@ #include "min_allocator.h" +template +void do_insert_hint_const_lvalue_test() +{ + typedef Container C; + typedef typename C::iterator R; + typedef typename C::value_type VT; + C c; + typename C::const_iterator e = c.end(); + const VT v1(3.5); + R r = c.insert(e, v1); + assert(c.size() == 1); + assert(*r == 3.5); + + r = c.insert(e, v1); + assert(c.size() == 1); + assert(*r == 3.5); + + const VT v2(4.5); + r = c.insert(e, v2); + assert(c.size() == 2); + assert(*r == 4.5); + + const VT v3(5.5); + r = c.insert(e, v3); + assert(c.size() == 3); + assert(*r == 5.5); +} + int main() { - { - typedef std::unordered_set 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); - } + do_insert_hint_const_lvalue_test >(); #if TEST_STD_VER >= 11 { typedef std::unordered_set, std::equal_to, min_allocator> 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); + do_insert_hint_const_lvalue_test(); } #endif #if _LIBCPP_DEBUG >= 1