ctor_alloc.pass.cpp revision 1b92188a82b01e76ac6e8ad5f997293c2a078adc
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//     explicit priority_queue(const Alloc& a);
14
15#include <queue>
16#include <cassert>
17
18#include "test_allocator.h"
19
20template <class T>
21struct test
22    : public std::priority_queue<T, std::vector<T, test_allocator<T> > >
23{
24    typedef std::priority_queue<T, std::vector<T, test_allocator<T> > > base;
25    typedef typename base::container_type container_type;
26    typedef typename base::value_compare value_compare;
27
28    explicit test(const test_allocator<int>& a) : base(a) {}
29    test(const value_compare& comp, const test_allocator<int>& a)
30        : base(comp, c, a) {}
31    test(const value_compare& comp, const container_type& c,
32        const test_allocator<int>& a) : base(comp, c, a) {}
33#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
34    test(const value_compare& comp, container_type&& c,
35         const test_allocator<int>& a) : base(comp, std::move(c), a) {}
36    test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {}
37#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
38    test_allocator<int> get_allocator() {return c.get_allocator();}
39
40    using base::c;
41};
42
43int main()
44{
45    test<int> q((test_allocator<int>(3)));
46    assert(q.c.get_allocator() == test_allocator<int>(3));
47    assert(q.c.size() == 0);
48}
49