1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <map> 11 12 // class multimap 13 14 // size_type count(const key_type& k) const; 15 16 #include <map> 17 #include <cassert> 18 19 #include "min_allocator.h" 20 21 int main() 22 { 23 typedef std::pair<const int, double> V; 24 { 25 typedef std::multimap<int, double> M; 26 { 27 typedef M::size_type R; 28 V ar[] = 29 { 30 V(5, 1), 31 V(5, 2), 32 V(5, 3), 33 V(7, 1), 34 V(7, 2), 35 V(7, 3), 36 V(9, 1), 37 V(9, 2), 38 V(9, 3) 39 }; 40 const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); 41 R r = m.count(4); 42 assert(r == 0); 43 r = m.count(5); 44 assert(r == 3); 45 r = m.count(6); 46 assert(r == 0); 47 r = m.count(7); 48 assert(r == 3); 49 r = m.count(8); 50 assert(r == 0); 51 r = m.count(9); 52 assert(r == 3); 53 r = m.count(10); 54 assert(r == 0); 55 } 56 } 57 #if __cplusplus >= 201103L 58 { 59 typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; 60 { 61 typedef M::size_type R; 62 V ar[] = 63 { 64 V(5, 1), 65 V(5, 2), 66 V(5, 3), 67 V(7, 1), 68 V(7, 2), 69 V(7, 3), 70 V(9, 1), 71 V(9, 2), 72 V(9, 3) 73 }; 74 const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); 75 R r = m.count(4); 76 assert(r == 0); 77 r = m.count(5); 78 assert(r == 3); 79 r = m.count(6); 80 assert(r == 0); 81 r = m.count(7); 82 assert(r == 3); 83 r = m.count(8); 84 assert(r == 0); 85 r = m.count(9); 86 assert(r == 3); 87 r = m.count(10); 88 assert(r == 0); 89 } 90 } 91 #endif 92 } 93