| 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 | C c; |
| 23 | for (int i = 0; i < n; ++i) |
| 24 | c.push_back(i); |
| 25 | return c; |
| 26 | } |
| 27 | |
| 28 | typedef std::deque<int, test_allocator<int> > C; |
| 29 | |
| 30 | template <class T> |
| 31 | struct test : public std::queue<T, C> { |
| 32 | typedef std::queue<T, C> base; |
| 33 | typedef test_allocator<int> allocator_type; |
| 34 | typedef typename base::container_type container_type; |
| 35 | |
| 36 | explicit test(const allocator_type& a) : base(a) {} |
| 37 | test(const container_type& container, const allocator_type& a) : base(container, a) {} |
| 38 | test(const test& q, const allocator_type& a) : base(q, a) {} |
| 39 | allocator_type get_allocator() { return this->c.get_allocator(); } |
| 40 | }; |
| 41 | |
| 42 | int main(int, char**) { |
| 43 | test<int> q(make<C>(5), test_allocator<int>(4)); |
| 44 | test<int> q2(q, test_allocator<int>(5)); |
| 45 | assert(q2.get_allocator() == test_allocator<int>(5)); |
| 46 | assert(q2.size() == 5); |
| 47 | |
| 48 | return 0; |
| 49 | } |
| 50 | |