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