Index: test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -27,6 +28,25 @@ #include "../../../test_hash.h" #include "test_allocator.h" #include "min_allocator.h" + +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} int main(int, char**) { @@ -62,24 +82,17 @@ c = c0; LIBCPP_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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); + s.insert("three"); + CheckConsecutiveKeys(c, 3, s); + s.insert("four"); + CheckConsecutiveKeys(c, 4, s); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >(9)); assert(c.get_allocator() == A(4)); @@ -139,24 +152,17 @@ 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); + s.insert("three"); + CheckConsecutiveKeys(c, 3, s); + s.insert("four"); + CheckConsecutiveKeys(c, 4, s); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >(9)); assert(c.get_allocator() == A(10)); @@ -199,24 +205,17 @@ c = c0; LIBCPP_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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); + s.insert("three"); + CheckConsecutiveKeys(c, 3, s); + s.insert("four"); + CheckConsecutiveKeys(c, 4, s); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >(9)); assert(c.get_allocator() == A()); Index: test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -27,6 +28,25 @@ #include "../../../test_hash.h" #include "test_allocator.h" #include "min_allocator.h" + +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} int main(int, char**) { @@ -56,24 +76,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -112,24 +127,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); Index: test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -28,6 +29,25 @@ #include "../../../test_hash.h" #include "test_allocator.h" #include "min_allocator.h" + +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} int main(int, char**) { @@ -66,24 +86,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -131,24 +146,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -196,24 +206,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -261,24 +266,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); Index: test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -26,6 +27,25 @@ #include "../../../test_hash.h" #include "test_allocator.h" #include "min_allocator.h" + +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} int main(int, char**) { @@ -54,24 +74,17 @@ C c = c0; LIBCPP_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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); + s.insert("three"); + CheckConsecutiveKeys(c, 3, s); + s.insert("four"); + CheckConsecutiveKeys(c, 4, s); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >(9)); assert(c.get_allocator() == @@ -108,24 +121,17 @@ C c = c0; LIBCPP_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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); + s.insert("three"); + CheckConsecutiveKeys(c, 3, s); + s.insert("four"); + CheckConsecutiveKeys(c, 4, s); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >(9)); assert(c.get_allocator() == @@ -161,24 +167,17 @@ C c = c0; LIBCPP_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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); + s.insert("three"); + CheckConsecutiveKeys(c, 3, s); + s.insert("four"); + CheckConsecutiveKeys(c, 4, s); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >(9)); assert(c.get_allocator() == Index: test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -26,6 +27,25 @@ #include "../../../test_hash.h" #include "test_allocator.h" #include "min_allocator.h" + +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} int main(int, char**) { @@ -54,24 +74,17 @@ C c(c0, test_allocator >(5)); LIBCPP_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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); + s.insert("three"); + CheckConsecutiveKeys(c, 3, s); + s.insert("four"); + CheckConsecutiveKeys(c, 4, s); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >(9)); assert(c.get_allocator() == @@ -108,24 +121,17 @@ C c(c0, min_allocator >()); LIBCPP_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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); + s.insert("three"); + CheckConsecutiveKeys(c, 3, s); + s.insert("four"); + CheckConsecutiveKeys(c, 4, s); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >(9)); assert(c.get_allocator() == @@ -162,24 +168,17 @@ C c(c0, A{}); LIBCPP_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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); + s.insert("three"); + CheckConsecutiveKeys(c, 3, s); + s.insert("four"); + CheckConsecutiveKeys(c, 4, s); assert(c.hash_function() == test_hash >(8)); assert(c.key_eq() == test_compare >(9)); assert(c.get_allocator() == A{}); Index: test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -28,6 +29,25 @@ #include "../../../test_hash.h" #include "test_allocator.h" #include "min_allocator.h" + +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} int main(int, char**) { @@ -51,24 +71,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -104,24 +119,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -159,24 +169,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -215,24 +220,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); Index: test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -28,6 +29,25 @@ #include "../../../test_hash.h" #include "test_allocator.h" #include "min_allocator.h" + +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} int main(int, char**) { @@ -53,24 +73,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -108,24 +123,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); Index: test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -28,6 +29,25 @@ #include "../../../test_hash.h" #include "test_allocator.h" #include "min_allocator.h" + +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} int main(int, char**) { @@ -54,24 +74,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -110,24 +125,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); Index: test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -29,6 +30,25 @@ #include "../../../test_hash.h" #include "test_allocator.h" #include "min_allocator.h" + +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} int main(int, char**) { @@ -56,24 +76,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -113,24 +128,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); Index: test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -29,6 +30,25 @@ #include "../../../test_hash.h" #include "test_allocator.h" #include "min_allocator.h" + +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} int main(int, char**) { @@ -57,24 +77,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -115,24 +130,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -174,24 +184,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); Index: test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -28,6 +29,25 @@ #include "../../../test_hash.h" #include "test_allocator.h" #include "min_allocator.h" + +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} int main(int, char**) { @@ -86,24 +106,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -175,24 +190,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); Index: test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -30,6 +31,25 @@ #include "../../../test_hash.h" #include "test_allocator.h" #include "min_allocator.h" + +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} int main(int, char**) { @@ -62,24 +82,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -126,24 +141,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -190,24 +200,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -254,24 +259,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); Index: test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -29,6 +30,25 @@ #include "../../../test_hash.h" #include "test_allocator.h" #include "min_allocator.h" + +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} int main(int, char**) { @@ -54,24 +74,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -110,24 +125,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -167,24 +177,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -225,24 +230,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); Index: test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -29,6 +30,25 @@ #include "../../../test_hash.h" #include "test_allocator.h" #include "min_allocator.h" + +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} int main(int, char**) { @@ -56,24 +76,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -114,24 +129,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); Index: test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -30,6 +31,25 @@ #include "../../../test_hash.h" #include "test_allocator.h" #include "min_allocator.h" + +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} int main(int, char**) { @@ -58,24 +78,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -117,24 +132,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); Index: test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -30,6 +31,25 @@ #include "../../../test_hash.h" #include "test_allocator.h" #include "min_allocator.h" + +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} int main(int, char**) { @@ -59,24 +79,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -119,24 +134,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); Index: test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -31,6 +32,25 @@ #include "../../../test_hash.h" #include "test_allocator.h" #include "min_allocator.h" + +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} int main(int, char**) { @@ -61,24 +81,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -122,24 +137,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); @@ -183,24 +193,19 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - i = eq.first; + C::const_iterator i = eq.first; assert(i->first == 3); assert(i->second == "three"); eq = c.equal_range(4); Index: test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -29,6 +30,25 @@ bool operator==(const TemplateConstructor&, const TemplateConstructor&) { return false; } struct Hash { size_t operator() (const TemplateConstructor &) const { return 0; } }; + +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} int main(int, char**) { @@ -48,6 +68,7 @@ C::const_iterator i = c.find(2); C::const_iterator i_next = i; ++i_next; + std::string es = i->second; C::iterator j = c.erase(i); assert(j == i_next); @@ -55,17 +76,15 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); eq = c.equal_range(2); assert(std::distance(eq.first, eq.second) == 1); - k = eq.first; + C::const_iterator k = eq.first; assert(k->first == 2); - assert(k->second == "four"); + assert(k->second == (es == "two" ? "four" : "two")); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); k = eq.first; @@ -97,6 +116,7 @@ C::const_iterator i = c.find(2); C::const_iterator i_next = i; ++i_next; + std::string es = i->second; C::iterator j = c.erase(i); assert(j == i_next); @@ -104,17 +124,15 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); eq = c.equal_range(2); assert(std::distance(eq.first, eq.second) == 1); - k = eq.first; + C::const_iterator k = eq.first; assert(k->first == 2); - assert(k->second == "four"); + assert(k->second == (es == "two" ? "four" : "two")); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); k = eq.first; Index: test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -37,6 +38,25 @@ } #endif +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} + int main(int, char**) { { @@ -57,23 +77,18 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - k = eq.first; + C::const_iterator k = eq.first; assert(k->first == 3); assert(k->second == "three"); eq = c.equal_range(4); @@ -88,12 +103,9 @@ 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"); + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); k = eq.first; @@ -111,12 +123,9 @@ 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"); + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); k = eq.first; @@ -134,12 +143,9 @@ 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"); + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); k = eq.first; @@ -152,12 +158,9 @@ 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"); + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); k = eq.first; @@ -220,23 +223,18 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - k = eq.first; + C::const_iterator k = eq.first; assert(k->first == 3); assert(k->second == "three"); eq = c.equal_range(4); @@ -251,12 +249,9 @@ 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"); + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); k = eq.first; @@ -274,12 +269,9 @@ 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"); + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); k = eq.first; @@ -297,12 +289,9 @@ 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"); + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); k = eq.first; @@ -315,12 +304,9 @@ 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"); + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); k = eq.first; Index: test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp @@ -16,10 +16,30 @@ #include #include +#include #include #include #include "min_allocator.h" + +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} int main(int, char**) { @@ -44,20 +64,15 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); k = eq.first; @@ -75,12 +90,9 @@ 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"); + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); k = eq.first; @@ -121,20 +133,15 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); k = eq.first; @@ -152,12 +159,9 @@ 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"); + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); k = eq.first; Index: test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp @@ -18,11 +18,31 @@ #include #include +#include #include #include #include "test_iterators.h" #include "min_allocator.h" + +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} int main(int, char**) { @@ -44,23 +64,18 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - k = eq.first; + C::iterator k = eq.first; assert(k->first == 3); assert(k->second == "three"); eq = c.equal_range(4); @@ -90,23 +105,18 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - k = eq.first; + C::iterator k = eq.first; assert(k->first == 3); assert(k->second == "three"); eq = c.equal_range(4); Index: test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp @@ -17,11 +17,31 @@ #include #include +#include #include #include #include "test_iterators.h" #include "min_allocator.h" + +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} int main(int, char**) { @@ -43,23 +63,18 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - k = eq.first; + C::iterator k = eq.first; assert(k->first == 3); assert(k->second == "three"); eq = c.equal_range(4); @@ -90,23 +105,18 @@ typedef std::pair 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c, 1, s); 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"); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c, 2, s); eq = c.equal_range(3); assert(std::distance(eq.first, eq.second) == 1); - k = eq.first; + C::iterator k = eq.first; assert(k->first == 3); assert(k->second == "three"); eq = c.equal_range(4); Index: test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp =================================================================== --- test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp +++ test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -24,6 +25,25 @@ #include "../../../test_hash.h" #include "test_allocator.h" #include "min_allocator.h" + +template +void CheckConsecutiveKeys(C c, typename Iter::value_type::first_type key, std::set& values) +{ + Iter pos = c.find(key); + Iter end = c.end(); + typedef std::set Vtype; + typedef typename Vtype::size_type Vstype; + Vstype vsize = values.size(); + for ( Vstype i = 0; i < vsize; ++i ) + { + assert(pos != end); + assert(pos->first == key); + assert(values.find(pos->second) != values.end()); + values.erase(values.find(pos->second)); + ++pos; + } + assert(pos == end || pos->first != key); +} int main(int, char**) { @@ -134,10 +154,13 @@ assert(c2.bucket_count() >= 6); 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c2, 1, s); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c2, 2, s); assert(c2.find(3)->second == "three"); assert(c2.find(4)->second == "four"); assert(c2.hash_function() == Hash(1)); @@ -197,10 +220,13 @@ assert(c2.bucket_count() >= 6); 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c2, 1, s); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c2, 2, s); assert(c2.find(3)->second == "three"); assert(c2.find(4)->second == "four"); assert(c2.hash_function() == Hash(1)); @@ -318,10 +344,13 @@ assert(c2.bucket_count() >= 6); 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c2, 1, s); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c2, 2, s); assert(c2.find(3)->second == "three"); assert(c2.find(4)->second == "four"); assert(c2.hash_function() == Hash(1)); @@ -381,10 +410,13 @@ assert(c2.bucket_count() >= 6); 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c2, 1, s); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c2, 2, s); assert(c2.find(3)->second == "three"); assert(c2.find(4)->second == "four"); assert(c2.hash_function() == Hash(1)); @@ -502,10 +534,13 @@ assert(c2.bucket_count() >= 6); 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c2, 1, s); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c2, 2, s); assert(c2.find(3)->second == "three"); assert(c2.find(4)->second == "four"); assert(c2.hash_function() == Hash(1)); @@ -565,10 +600,13 @@ assert(c2.bucket_count() >= 6); 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"); + std::set s; + s.insert("one"); + s.insert("four"); + CheckConsecutiveKeys(c2, 1, s); + s.insert("two"); + s.insert("four"); + CheckConsecutiveKeys(c2, 2, s); assert(c2.find(3)->second == "three"); assert(c2.find(4)->second == "four"); assert(c2.hash_function() == Hash(1));