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 // stack(InputIterator, InputIterator);
15
16 #include <cassert>
17 #include <stack>
18
19 #include "test_allocator.h"
20
21 static_assert(!std::is_constructible_v<std::stack<int>, int, int, std::allocator<int>>);
22 static_assert(!std::is_constructible_v<std::stack<int>, int*, int*, int>);
23 static_assert( std::is_constructible_v<std::stack<int, std::deque<int, test_allocator<int>>>, int*, int*, test_allocator<int>>);
24 static_assert(!std::is_constructible_v<std::stack<int, std::deque<int, test_allocator<int>>>, int*, int*, std::allocator<int>>);
25
26 struct alloc : test_allocator<int> {
27 alloc(test_allocator_statistics* a);
28 };
29 static_assert( std::is_constructible_v<std::stack<int, std::deque<int, alloc>>, int*, int*, test_allocator_statistics*>);
30
main(int,char **)31 int main(int, char**) {
32 const int a[] = {4, 3, 2, 1};
33 std::stack<int> stack(a, a + 4);
34 assert(stack.top() == 1);
35 stack.pop();
36 assert(stack.top() == 2);
37 stack.pop();
38 assert(stack.top() == 3);
39 stack.pop();
40 assert(stack.top() == 4);
41 stack.pop();
42 assert(stack.empty());
43
44 return 0;
45 }
46