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 // iterator insert(const_iterator p, const value_type& x);
     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<double> C;
     27         typedef C::iterator R;
     28         typedef C::value_type P;
     29         C c;
     30         C::const_iterator e = c.end();
     31         R r = c.insert(e, P(3.5));
     32         assert(c.size() == 1);
     33         assert(*r == 3.5);
     34 
     35         r = c.insert(e, P(3.5));
     36         assert(c.size() == 1);
     37         assert(*r == 3.5);
     38 
     39         r = c.insert(e, P(4.5));
     40         assert(c.size() == 2);
     41         assert(*r == 4.5);
     42 
     43         r = c.insert(e, P(5.5));
     44         assert(c.size() == 3);
     45         assert(*r == 5.5);
     46     }
     47 #if __cplusplus >= 201103L
     48     {
     49         typedef std::unordered_set<double, std::hash<double>,
     50                                 std::equal_to<double>, min_allocator<double>> C;
     51         typedef C::iterator R;
     52         typedef C::value_type P;
     53         C c;
     54         C::const_iterator e = c.end();
     55         R r = c.insert(e, P(3.5));
     56         assert(c.size() == 1);
     57         assert(*r == 3.5);
     58 
     59         r = c.insert(e, P(3.5));
     60         assert(c.size() == 1);
     61         assert(*r == 3.5);
     62 
     63         r = c.insert(e, P(4.5));
     64         assert(c.size() == 2);
     65         assert(*r == 4.5);
     66 
     67         r = c.insert(e, P(5.5));
     68         assert(c.size() == 3);
     69         assert(*r == 5.5);
     70     }
     71 #endif
     72 }
     73