Differential D54838 Diff 175068 test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp
Changeset View
Changeset View
Standalone View
Standalone View
test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp
Show All 11 Lines | |||||
// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, | // template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, | ||||
// class Alloc = allocator<pair<const Key, T>>> | // class Alloc = allocator<pair<const Key, T>>> | ||||
// class unordered_multimap | // class unordered_multimap | ||||
// pair<iterator, iterator> equal_range(const key_type& k); | // pair<iterator, iterator> equal_range(const key_type& k); | ||||
#include <unordered_map> | #include <unordered_map> | ||||
#include <string> | #include <string> | ||||
#include <set> | |||||
#include <cassert> | #include <cassert> | ||||
#include "min_allocator.h" | #include "min_allocator.h" | ||||
int main() | int main() | ||||
{ | { | ||||
{ | { | ||||
typedef std::unordered_multimap<int, std::string> C; | typedef std::unordered_multimap<int, std::string> C; | ||||
Show All 15 Lines | int main() | ||||
C c(std::begin(a), std::end(a)); | C c(std::begin(a), std::end(a)); | ||||
std::pair<I, I> r = c.equal_range(30); | std::pair<I, I> r = c.equal_range(30); | ||||
assert(std::distance(r.first, r.second) == 1); | assert(std::distance(r.first, r.second) == 1); | ||||
assert(r.first->first == 30); | assert(r.first->first == 30); | ||||
assert(r.first->second == "thirty"); | assert(r.first->second == "thirty"); | ||||
r = c.equal_range(5); | r = c.equal_range(5); | ||||
assert(std::distance(r.first, r.second) == 0); | assert(std::distance(r.first, r.second) == 0); | ||||
r = c.equal_range(50); | r = c.equal_range(50); | ||||
std::set<std::string> s = {"fifty", "fiftyA", "fiftyB"}; | |||||
for ( int i = 0; i < 3; ++i ) | |||||
{ | |||||
assert(r.first->first == 50); | assert(r.first->first == 50); | ||||
assert(r.first->second == "fifty"); | assert(s.find(r.first->second) != s.end()); | ||||
++r.first; | s.erase(s.find(r.first->second)); | ||||
assert(r.first->first == 50); | |||||
assert(r.first->second == "fiftyA"); | |||||
++r.first; | ++r.first; | ||||
assert(r.first->first == 50); | } | ||||
assert(r.first->second == "fiftyB"); | |||||
} | } | ||||
#if TEST_STD_VER >= 11 | #if TEST_STD_VER >= 11 | ||||
{ | { | ||||
typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, | typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, | ||||
min_allocator<std::pair<const int, std::string>>> C; | min_allocator<std::pair<const int, std::string>>> C; | ||||
typedef C::iterator I; | typedef C::iterator I; | ||||
typedef std::pair<int, std::string> P; | typedef std::pair<int, std::string> P; | ||||
P a[] = | P a[] = | ||||
Show All 12 Lines | #if TEST_STD_VER >= 11 | ||||
C c(std::begin(a), std::end(a)); | C c(std::begin(a), std::end(a)); | ||||
std::pair<I, I> r = c.equal_range(30); | std::pair<I, I> r = c.equal_range(30); | ||||
assert(std::distance(r.first, r.second) == 1); | assert(std::distance(r.first, r.second) == 1); | ||||
assert(r.first->first == 30); | assert(r.first->first == 30); | ||||
assert(r.first->second == "thirty"); | assert(r.first->second == "thirty"); | ||||
r = c.equal_range(5); | r = c.equal_range(5); | ||||
assert(std::distance(r.first, r.second) == 0); | assert(std::distance(r.first, r.second) == 0); | ||||
r = c.equal_range(50); | r = c.equal_range(50); | ||||
std::set<std::string> s = {"fifty", "fiftyA", "fiftyB"}; | |||||
for ( int i = 0; i < 3; ++i ) | |||||
{ | |||||
assert(r.first->first == 50); | assert(r.first->first == 50); | ||||
assert(r.first->second == "fifty"); | assert(s.find(r.first->second) != s.end()); | ||||
++r.first; | s.erase(s.find(r.first->second)); | ||||
assert(r.first->first == 50); | |||||
assert(r.first->second == "fiftyA"); | |||||
++r.first; | ++r.first; | ||||
assert(r.first->first == 50); | } | ||||
assert(r.first->second == "fiftyB"); | |||||
} | } | ||||
#endif | #endif | ||||
} | } |