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// UNSUPPORTED: c++03
10
11// <queue>
12
13// template <class Alloc>
14// queue(const container_type& c, const Alloc& a);
15
16#include <queue>
17#include <cassert>
18
19#include "test_macros.h"
20#include "test_allocator.h"
21#include "MoveOnly.h"
22
23template <class C>
24C make(int n) {
25 C c;
26 for (int i = 0; i < n; ++i)
27 c.push_back(MoveOnly(i));
28 return c;
29}
30
31typedef std::deque<MoveOnly, test_allocator<MoveOnly> > C;
32
33template <class T>
34struct test : public std::queue<T, C> {
35 typedef std::queue<T, C> base;
36 typedef test_allocator<MoveOnly> allocator_type;
37 typedef typename base::container_type container_type;
38
39 explicit test(const allocator_type& a) : base(a) {}
40 test(const container_type& container, const allocator_type& a) : base(container, a) {}
41 test(container_type&& container, const allocator_type& a) : base(std::move(container), a) {}
42 test(test&& q, const allocator_type& a) : base(std::move(q), a) {}
43 allocator_type get_allocator() { return this->c.get_allocator(); }
44};
45
46int main(int, char**) {
47 test<MoveOnly> q(make<C>(5), test_allocator<MoveOnly>(4));
48 assert(q.get_allocator() == test_allocator<MoveOnly>(4));
49 assert(q.size() == 5);
50
51 return 0;
52}
53

source code of libcxx/test/std/containers/container.adaptors/queue/queue.cons.alloc/ctor_rcontainer_alloc.pass.cpp