1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <queue>
10 
11 // template <class Alloc>
12 //   queue(const queue& q, const Alloc& a);
13 
14 #include <queue>
15 #include <cassert>
16 
17 #include "test_macros.h"
18 #include "test_allocator.h"
19 
20 template <class C>
21 C
make(int n)22 make(int n)
23 {
24     C c;
25     for (int i = 0; i < n; ++i)
26         c.push_back(i);
27     return c;
28 }
29 
30 typedef std::deque<int, test_allocator<int> > C;
31 
32 template <class T>
33 struct test
34     : public std::queue<T, C>
35 {
36     typedef std::queue<T, C> base;
37     typedef test_allocator<int>      allocator_type;
38     typedef typename base::container_type container_type;
39 
testtest40     explicit test(const allocator_type& a) : base(a) {}
testtest41     test(const container_type& container, const allocator_type& a) : base(container, a) {}
testtest42     test(const test& q, const allocator_type& a) : base(q, a) {}
get_allocatortest43     allocator_type get_allocator() {return this->c.get_allocator();}
44 };
45 
main(int,char **)46 int main(int, char**)
47 {
48     test<int> q(make<C>(5), test_allocator<int>(4));
49     test<int> q2(q, test_allocator<int>(5));
50     assert(q2.get_allocator() == test_allocator<int>(5));
51     assert(q2.size() == 5);
52 
53   return 0;
54 }
55