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 | // <stack> |
10 | |
11 | // explicit stack(const Container&); |
12 | |
13 | #include <stack> |
14 | #include <cassert> |
15 | #include <cstddef> |
16 | |
17 | #include "test_macros.h" |
18 | #if TEST_STD_VER >= 11 |
19 | #include "test_convertible.h" |
20 | #endif |
21 | |
22 | template <class C> |
23 | C |
24 | make(int n) |
25 | { |
26 | C c; |
27 | for (int i = 0; i < n; ++i) |
28 | c.push_back(i); |
29 | return c; |
30 | } |
31 | |
32 | int main(int, char**) |
33 | { |
34 | typedef std::deque<int> Container; |
35 | typedef std::stack<int> Q; |
36 | Container d = make<Container>(n: 5); |
37 | Q q(d); |
38 | assert(q.size() == 5); |
39 | for (std::size_t i = 0; i < d.size(); ++i) |
40 | { |
41 | assert(q.top() == d[d.size() - i - 1]); |
42 | q.pop(); |
43 | } |
44 | |
45 | #if TEST_STD_VER >= 11 |
46 | static_assert(!test_convertible<Q, const Container&>(), "" ); |
47 | #endif |
48 | |
49 | return 0; |
50 | } |
51 | |