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 int main() 20 { 21 typedef int V; 22 typedef std::set<int> M; 23 { 24 typedef M::size_type R; 25 V ar[] = 26 { 27 5, 28 6, 29 7, 30 8, 31 9, 32 10, 33 11, 34 12 35 }; 36 const M m(ar, ar+sizeof(ar)/sizeof(ar[0])); 37 R r = m.count(5); 38 assert(r == 1); 39 r = m.count(6); 40 assert(r == 1); 41 r = m.count(7); 42 assert(r == 1); 43 r = m.count(8); 44 assert(r == 1); 45 r = m.count(9); 46 assert(r == 1); 47 r = m.count(10); 48 assert(r == 1); 49 r = m.count(11); 50 assert(r == 1); 51 r = m.count(12); 52 assert(r == 1); 53 r = m.count(4); 54 assert(r == 0); 55 } 56 } 57