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 | // <forward_list> |
10 | |
11 | // forward_list(forward_list&&) |
12 | // noexcept(is_nothrow_move_constructible<allocator_type>::value); |
13 | |
14 | // This tests a conforming extension |
15 | |
16 | // UNSUPPORTED: c++03 |
17 | |
18 | #include <forward_list> |
19 | #include <cassert> |
20 | |
21 | #include "test_macros.h" |
22 | #include "MoveOnly.h" |
23 | #include "test_allocator.h" |
24 | |
25 | template <class T> |
26 | struct some_alloc |
27 | { |
28 | typedef T value_type; |
29 | some_alloc(const some_alloc&); |
30 | void allocate(std::size_t); |
31 | }; |
32 | |
33 | int main(int, char**) |
34 | { |
35 | #if defined(_LIBCPP_VERSION) |
36 | { |
37 | typedef std::forward_list<MoveOnly> C; |
38 | static_assert(std::is_nothrow_move_constructible<C>::value, "" ); |
39 | } |
40 | { |
41 | typedef std::forward_list<MoveOnly, test_allocator<MoveOnly>> C; |
42 | static_assert(std::is_nothrow_move_constructible<C>::value, "" ); |
43 | } |
44 | { |
45 | typedef std::forward_list<MoveOnly, other_allocator<MoveOnly>> C; |
46 | static_assert(std::is_nothrow_move_constructible<C>::value, "" ); |
47 | } |
48 | { |
49 | typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C; |
50 | static_assert(!std::is_nothrow_move_constructible<C>::value, "" ); |
51 | } |
52 | #endif // _LIBCPP_VERSION |
53 | |
54 | return 0; |
55 | } |
56 | |