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