Home | History | Annotate | Download | only in unord.set
      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 // <unordered_set>
     11 
     12 // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>,
     13 //           class Alloc = allocator<Value>>
     14 // class unordered_set
     15 
     16 // size_type count(const key_type& k) const;
     17 
     18 #include <unordered_set>
     19 #include <cassert>
     20 
     21 #include "min_allocator.h"
     22 
     23 int main()
     24 {
     25     {
     26         typedef std::unordered_set<int> C;
     27         typedef int P;
     28         P a[] =
     29         {
     30             P(10),
     31             P(20),
     32             P(30),
     33             P(40),
     34             P(50),
     35             P(50),
     36             P(50),
     37             P(60),
     38             P(70),
     39             P(80)
     40         };
     41         const C c(std::begin(a), std::end(a));
     42         assert(c.count(30) == 1);
     43         assert(c.count(50) == 1);
     44         assert(c.count(5) == 0);
     45     }
     46 #if __cplusplus >= 201103L
     47     {
     48         typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C;
     49         typedef int P;
     50         P a[] =
     51         {
     52             P(10),
     53             P(20),
     54             P(30),
     55             P(40),
     56             P(50),
     57             P(50),
     58             P(50),
     59             P(60),
     60             P(70),
     61             P(80)
     62         };
     63         const C c(std::begin(a), std::end(a));
     64         assert(c.count(30) == 1);
     65         assert(c.count(50) == 1);
     66         assert(c.count(5) == 0);
     67     }
     68 #endif
     69 }
     70