Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / containers / container.adaptors / stack / stack.cons / ctor_container.pass.cpp
blobb77660d4c875096891e8dcf33a9d802dfa97e96d
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 //===----------------------------------------------------------------------===//
9 // <stack>
11 // explicit stack(const Container&);
13 #include <stack>
14 #include <cassert>
15 #include <cstddef>
17 #include "test_macros.h"
18 #if TEST_STD_VER >= 11
19 #include "test_convertible.h"
20 #endif
22 template <class C>
24 make(int n)
26 C c;
27 for (int i = 0; i < n; ++i)
28 c.push_back(i);
29 return c;
32 int main(int, char**)
34 typedef std::deque<int> Container;
35 typedef std::stack<int> Q;
36 Container d = make<Container>(5);
37 Q q(d);
38 assert(q.size() == 5);
39 for (std::size_t i = 0; i < d.size(); ++i)
41 assert(q.top() == d[d.size() - i - 1]);
42 q.pop();
45 #if TEST_STD_VER >= 11
46 static_assert(!test_convertible<Q, const Container&>(), "");
47 #endif
49 return 0;