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

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