Home | History | Annotate | Download | only in set.cons
      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 set
     13 
     14 // template <class InputIterator>
     15 //     set(InputIterator first, InputIterator last,
     16 //         const value_compare& comp, const allocator_type& a);
     17 
     18 #include <set>
     19 #include <cassert>
     20 
     21 #include "test_iterators.h"
     22 #include "../../../test_compare.h"
     23 #include "../../../test_allocator.h"
     24 
     25 int main()
     26 {
     27     typedef int V;
     28     V ar[] =
     29     {
     30         1,
     31         1,
     32         1,
     33         2,
     34         2,
     35         2,
     36         3,
     37         3,
     38         3
     39     };
     40     typedef test_compare<std::less<V> > C;
     41     typedef test_allocator<V> A;
     42     std::set<V, C, A> m(input_iterator<const V*>(ar),
     43                         input_iterator<const V*>(ar+sizeof(ar)/sizeof(ar[0])),
     44                         C(5), A(7));
     45     assert(m.value_comp() == C(5));
     46     assert(m.get_allocator() == A(7));
     47     assert(m.size() == 3);
     48     assert(distance(m.begin(), m.end()) == 3);
     49     assert(*m.begin() == 1);
     50     assert(*next(m.begin()) == 2);
     51     assert(*next(m.begin(), 2) == 3);
     52 }
     53