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 // void insert(initializer_list<value_type> il);
     17 
     18 #include <unordered_set>
     19 #include <cassert>
     20 
     21 #include "test_iterators.h"
     22 #include "min_allocator.h"
     23 
     24 int main()
     25 {
     26 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
     27     {
     28         typedef std::unordered_set<int> C;
     29         typedef int P;
     30         C c;
     31         c.insert(
     32                     {
     33                         P(1),
     34                         P(2),
     35                         P(3),
     36                         P(4),
     37                         P(1),
     38                         P(2)
     39                     }
     40                 );
     41         assert(c.size() == 4);
     42         assert(c.count(1) == 1);
     43         assert(c.count(2) == 1);
     44         assert(c.count(3) == 1);
     45         assert(c.count(4) == 1);
     46     }
     47 #if __cplusplus >= 201103L
     48     {
     49         typedef std::unordered_set<int, std::hash<int>,
     50                                       std::equal_to<int>, min_allocator<int>> C;
     51         typedef int P;
     52         C c;
     53         c.insert(
     54                     {
     55                         P(1),
     56                         P(2),
     57                         P(3),
     58                         P(4),
     59                         P(1),
     60                         P(2)
     61                     }
     62                 );
     63         assert(c.size() == 4);
     64         assert(c.count(1) == 1);
     65         assert(c.count(2) == 1);
     66         assert(c.count(3) == 1);
     67         assert(c.count(4) == 1);
     68     }
     69 #endif
     70 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
     71 }
     72