Home | History | Annotate | Download | only in priqueue.cons.alloc
      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 // <queue>
     11 
     12 // template <class Alloc>
     13 //     priority_queue(const priority_queue& q, const Alloc& a);
     14 
     15 #include <queue>
     16 #include <cassert>
     17 
     18 template <class C>
     19 C
     20 make(int n)
     21 {
     22     C c;
     23     for (int i = 0; i < n; ++i)
     24         c.push_back(i);
     25     return c;
     26 }
     27 
     28 #include "../../../test_allocator.h"
     29 
     30 template <class T>
     31 struct test
     32     : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
     33 {
     34     typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
     35     typedef typename base::container_type container_type;
     36     typedef typename base::value_compare value_compare;
     37 
     38     explicit test(const test_allocator<int>& a) : base(a) {}
     39     test(const value_compare& comp, const test_allocator<int>& a)
     40         : base(comp, c, a) {}
     41     test(const value_compare& comp, const container_type& c,
     42          const test_allocator<int>& a) : base(comp, c, a) {}
     43     test(const test& q, const test_allocator<int>& a) : base(q, a) {}
     44     test_allocator<int> get_allocator() {return c.get_allocator();}
     45 
     46     using base::c;
     47 };
     48 
     49 int main()
     50 {
     51     test<int> qo(std::less<int>(),
     52                       make<std::vector<int, test_allocator<int> > >(5),
     53                       test_allocator<int>(2));
     54     test<int> q(qo, test_allocator<int>(6));
     55     assert(q.size() == 5);
     56     assert(q.c.get_allocator() == test_allocator<int>(6));
     57     assert(q.top() == int(4));
     58 }
     59