| 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 | // <queue> |
| 12 | |
| 13 | // explicit queue(Container&& c = Container()); // before C++20 |
| 14 | // queue() : queue(Container()) {} // C++20 |
| 15 | // explicit queue(Container&& c); // C++20 |
| 16 | |
| 17 | #include <queue> |
| 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 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 | |
| 34 | int main(int, char**) { |
| 35 | typedef std::deque<MoveOnly> Container; |
| 36 | typedef std::queue<MoveOnly> Q; |
| 37 | Q q(make<std::deque<MoveOnly> >(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 | |