blob: 2763129acc2ab90e1e8ad66da9105487f496bb17 [file] [log] [blame] 
 //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // class multimap // iterator begin(); // const_iterator begin() const; // iterator end(); // const_iterator end() const; // // reverse_iterator rbegin(); // const_reverse_iterator rbegin() const; // reverse_iterator rend(); // const_reverse_iterator rend() const; // // const_iterator cbegin() const; // const_iterator cend() const; // const_reverse_iterator crbegin() const; // const_reverse_iterator crend() const; #include #include #include "min_allocator.h" int main() { { typedef std::pair V; V ar[] = { V(1, 1), V(1, 1.5), V(1, 2), V(2, 1), V(2, 1.5), V(2, 2), V(3, 1), V(3, 1.5), V(3, 2), V(4, 1), V(4, 1.5), V(4, 2), V(5, 1), V(5, 1.5), V(5, 2), V(6, 1), V(6, 1.5), V(6, 2), V(7, 1), V(7, 1.5), V(7, 2), V(8, 1), V(8, 1.5), V(8, 2) }; std::multimap m(ar, ar+sizeof(ar)/sizeof(ar[0])); assert(std::distance(m.begin(), m.end()) == m.size()); assert(std::distance(m.rbegin(), m.rend()) == m.size()); std::multimap::iterator i; i = m.begin(); std::multimap::const_iterator k = i; assert(i == k); for (int j = 1; j <= 8; ++j) for (double d = 1; d <= 2; d += .5, ++i) { assert(i->first == j); assert(i->second == d); i->second = 2.5; assert(i->second == 2.5); } } { typedef std::pair V; V ar[] = { V(1, 1), V(1, 1.5), V(1, 2), V(2, 1), V(2, 1.5), V(2, 2), V(3, 1), V(3, 1.5), V(3, 2), V(4, 1), V(4, 1.5), V(4, 2), V(5, 1), V(5, 1.5), V(5, 2), V(6, 1), V(6, 1.5), V(6, 2), V(7, 1), V(7, 1.5), V(7, 2), V(8, 1), V(8, 1.5), V(8, 2) }; const std::multimap m(ar, ar+sizeof(ar)/sizeof(ar[0])); assert(std::distance(m.begin(), m.end()) == m.size()); assert(std::distance(m.cbegin(), m.cend()) == m.size()); assert(std::distance(m.rbegin(), m.rend()) == m.size()); assert(std::distance(m.crbegin(), m.crend()) == m.size()); std::multimap::const_iterator i; i = m.begin(); for (int j = 1; j <= 8; ++j) for (double d = 1; d <= 2; d += .5, ++i) { assert(i->first == j); assert(i->second == d); } } #if __cplusplus >= 201103L { typedef std::pair V; V ar[] = { V(1, 1), V(1, 1.5), V(1, 2), V(2, 1), V(2, 1.5), V(2, 2), V(3, 1), V(3, 1.5), V(3, 2), V(4, 1), V(4, 1.5), V(4, 2), V(5, 1), V(5, 1.5), V(5, 2), V(6, 1), V(6, 1.5), V(6, 2), V(7, 1), V(7, 1.5), V(7, 2), V(8, 1), V(8, 1.5), V(8, 2) }; std::multimap, min_allocator> m(ar, ar+sizeof(ar)/sizeof(ar[0])); assert(std::distance(m.begin(), m.end()) == m.size()); assert(std::distance(m.rbegin(), m.rend()) == m.size()); std::multimap, min_allocator>::iterator i; i = m.begin(); std::multimap, min_allocator>::const_iterator k = i; assert(i == k); for (int j = 1; j <= 8; ++j) for (double d = 1; d <= 2; d += .5, ++i) { assert(i->first == j); assert(i->second == d); i->second = 2.5; assert(i->second == 2.5); } } { typedef std::pair V; V ar[] = { V(1, 1), V(1, 1.5), V(1, 2), V(2, 1), V(2, 1.5), V(2, 2), V(3, 1), V(3, 1.5), V(3, 2), V(4, 1), V(4, 1.5), V(4, 2), V(5, 1), V(5, 1.5), V(5, 2), V(6, 1), V(6, 1.5), V(6, 2), V(7, 1), V(7, 1.5), V(7, 2), V(8, 1), V(8, 1.5), V(8, 2) }; const std::multimap, min_allocator> m(ar, ar+sizeof(ar)/sizeof(ar[0])); assert(std::distance(m.begin(), m.end()) == m.size()); assert(std::distance(m.cbegin(), m.cend()) == m.size()); assert(std::distance(m.rbegin(), m.rend()) == m.size()); assert(std::distance(m.crbegin(), m.crend()) == m.size()); std::multimap, min_allocator>::const_iterator i; i = m.begin(); for (int j = 1; j <= 8; ++j) for (double d = 1; d <= 2; d += .5, ++i) { assert(i->first == j); assert(i->second == d); } } #endif #if _LIBCPP_STD_VER > 11 { // N3644 testing typedef std::multimap C; C::iterator ii1{}, ii2{}; C::iterator ii4 = ii1; C::const_iterator cii{}; assert ( ii1 == ii2 ); assert ( ii1 == ii4 ); assert (!(ii1 != ii2 )); assert ( (ii1 == cii )); assert ( (cii == ii1 )); assert (!(ii1 != cii )); assert (!(cii != ii1 )); } #endif }