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

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