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 // <set> 11 12 // class set 13 14 // size_type count(const key_type& k) const; 15 16 #include <set> 17 #include <cassert> 18 19 #include "min_allocator.h" 20 21 int main() 22 { 23 { 24 typedef int V; 25 typedef std::set<int> M; 26 typedef M::size_type R; 27 V ar[] = 28 { 29 5, 30 6, 31 7, 32 8, 33 9, 34 10, 35 11, 36 12 37 }; 38 const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); 39 R r = m.count(5); 40 assert(r == 1); 41 r = m.count(6); 42 assert(r == 1); 43 r = m.count(7); 44 assert(r == 1); 45 r = m.count(8); 46 assert(r == 1); 47 r = m.count(9); 48 assert(r == 1); 49 r = m.count(10); 50 assert(r == 1); 51 r = m.count(11); 52 assert(r == 1); 53 r = m.count(12); 54 assert(r == 1); 55 r = m.count(4); 56 assert(r == 0); 57 } 58 #if __cplusplus >= 201103L 59 { 60 typedef int V; 61 typedef std::set<int, std::less<int>, min_allocator<int>> M; 62 typedef M::size_type R; 63 V ar[] = 64 { 65 5, 66 6, 67 7, 68 8, 69 9, 70 10, 71 11, 72 12 73 }; 74 const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); 75 R r = m.count(5); 76 assert(r == 1); 77 r = m.count(6); 78 assert(r == 1); 79 r = m.count(7); 80 assert(r == 1); 81 r = m.count(8); 82 assert(r == 1); 83 r = m.count(9); 84 assert(r == 1); 85 r = m.count(10); 86 assert(r == 1); 87 r = m.count(11); 88 assert(r == 1); 89 r = m.count(12); 90 assert(r == 1); 91 r = m.count(4); 92 assert(r == 0); 93 } 94 #endif 95 } 96