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, c++11, c++14, c++17, c++20
10
11// <queue>
12
13// template <class InputIterator>
14// queue(InputIterator, InputIterator);
15
16#include <cassert>
17#include <queue>
18#include <type_traits>
19
20#include "test_allocator.h"
21
22static_assert(!std::is_constructible_v<std::queue<int>, int, int, std::allocator<int>>);
23static_assert(!std::is_constructible_v<std::queue<int>, int*, int*, int>);
24static_assert(
25 std::is_constructible_v<std::queue<int, std::deque<int, test_allocator<int>>>, int*, int*, test_allocator<int>>);
26static_assert(
27 !std::is_constructible_v<std::queue<int, std::deque<int, test_allocator<int>>>, int*, int*, std::allocator<int>>);
28
29template <class T>
30struct alloc : test_allocator<T> {
31 alloc(test_allocator_statistics* a);
32
33 template <class U>
34 struct rebind {
35 using other = alloc<U>;
36 };
37};
38static_assert(
39 std::is_constructible_v<std::queue<int, std::deque<int, alloc<int>>>, int*, int*, test_allocator_statistics*>);
40
41int main(int, char**) {
42 const int a[] = {4, 3, 2, 1};
43 std::queue<int> queue(a, a + 4);
44 assert(queue.front() == 4);
45 queue.pop();
46 assert(queue.front() == 3);
47 queue.pop();
48 assert(queue.front() == 2);
49 queue.pop();
50 assert(queue.front() == 1);
51 queue.pop();
52 assert(queue.empty());
53
54 return 0;
55}
56

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