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 | |
22 | static_assert(!std::is_constructible_v<std::queue<int>, int, int, std::allocator<int>>); |
23 | static_assert(!std::is_constructible_v<std::queue<int>, int*, int*, int>); |
24 | static_assert( std::is_constructible_v<std::queue<int, std::deque<int, test_allocator<int>>>, int*, int*, test_allocator<int>>); |
25 | static_assert(!std::is_constructible_v<std::queue<int, std::deque<int, test_allocator<int>>>, int*, int*, std::allocator<int>>); |
26 | |
27 | template <class T> |
28 | struct alloc : test_allocator<T> { |
29 | alloc(test_allocator_statistics* a); |
30 | |
31 | template <class U> |
32 | struct rebind { |
33 | using other = alloc<U>; |
34 | }; |
35 | }; |
36 | static_assert( |
37 | std::is_constructible_v<std::queue<int, std::deque<int, alloc<int>>>, int*, int*, test_allocator_statistics*>); |
38 | |
39 | int main(int, char**) { |
40 | const int a[] = {4, 3, 2, 1}; |
41 | std::queue<int> queue(a, a + 4); |
42 | assert(queue.front() == 4); |
43 | queue.pop(); |
44 | assert(queue.front() == 3); |
45 | queue.pop(); |
46 | assert(queue.front() == 2); |
47 | queue.pop(); |
48 | assert(queue.front() == 1); |
49 | queue.pop(); |
50 | assert(queue.empty()); |
51 | |
52 | return 0; |
53 | } |
54 | |