| 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 make(int n) { |
| 24 | C c; |
| 25 | for (int i = 0; i < n; ++i) |
| 26 | c.push_back(i); |
| 27 | return c; |
| 28 | } |
| 29 | |
| 30 | int main(int, char**) { |
| 31 | typedef std::deque<int> Container; |
| 32 | typedef std::stack<int> Q; |
| 33 | Container d = make<Container>(n: 5); |
| 34 | Q q(d); |
| 35 | assert(q.size() == 5); |
| 36 | for (std::size_t i = 0; i < d.size(); ++i) { |
| 37 | assert(q.top() == d[d.size() - i - 1]); |
| 38 | q.pop(); |
| 39 | } |
| 40 | |
| 41 | #if TEST_STD_VER >= 11 |
| 42 | static_assert(!test_convertible<Q, const Container&>(), "" ); |
| 43 | #endif |
| 44 | |
| 45 | return 0; |
| 46 | } |
| 47 | |