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 Key, class Hash, class Pred, class Alloc>
     13 // bool
     14 // operator==(const unordered_set<Key, Hash, Pred, Alloc>& x,
     15 //            const unordered_set<Key, Hash, Pred, Alloc>& y);
     16 //
     17 // template <class Key, class Hash, class Pred, class Alloc>
     18 // bool
     19 // operator!=(const unordered_set<Key, Hash, Pred, Alloc>& x,
     20 //            const unordered_set<Key, Hash, Pred, Alloc>& y);
     21 
     22 #include <unordered_set>
     23 #include <cassert>
     24 
     25 int main()
     26 {
     27     {
     28         typedef std::unordered_set<int> C;
     29         typedef int P;
     30         P a[] =
     31         {
     32             P(10),
     33             P(20),
     34             P(30),
     35             P(40),
     36             P(50),
     37             P(60),
     38             P(70),
     39             P(80)
     40         };
     41         const C c1(std::begin(a), std::end(a));
     42         const C c2;
     43         assert(!(c1 == c2));
     44         assert( (c1 != c2));
     45     }
     46     {
     47         typedef std::unordered_set<int> C;
     48         typedef int P;
     49         P a[] =
     50         {
     51             P(10),
     52             P(20),
     53             P(30),
     54             P(40),
     55             P(50),
     56             P(60),
     57             P(70),
     58             P(80)
     59         };
     60         const C c1(std::begin(a), std::end(a));
     61         const C c2 = c1;
     62         assert( (c1 == c2));
     63         assert(!(c1 != c2));
     64     }
     65     {
     66         typedef std::unordered_set<int> C;
     67         typedef int P;
     68         P a[] =
     69         {
     70             P(10),
     71             P(20),
     72             P(30),
     73             P(40),
     74             P(50),
     75             P(60),
     76             P(70),
     77             P(80)
     78         };
     79         C c1(std::begin(a), std::end(a));
     80         C c2 = c1;
     81         c2.rehash(30);
     82         assert( (c1 == c2));
     83         assert(!(c1 != c2));
     84         c2.insert(P(90));
     85         assert(!(c1 == c2));
     86         assert( (c1 != c2));
     87         c1.insert(P(90));
     88         assert( (c1 == c2));
     89         assert(!(c1 != c2));
     90     }
     91 }
     92