| 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 | // <list> |
| 10 | |
| 11 | // list& operator=(list&& c) |
| 12 | // noexcept( |
| 13 | // allocator_type::propagate_on_container_move_assignment::value && |
| 14 | // is_nothrow_move_assignable<allocator_type>::value); |
| 15 | |
| 16 | // This tests a conforming extension |
| 17 | |
| 18 | // UNSUPPORTED: c++03 |
| 19 | |
| 20 | #include <list> |
| 21 | |
| 22 | #include "test_macros.h" |
| 23 | #include "MoveOnly.h" |
| 24 | #include "test_allocator.h" |
| 25 | |
| 26 | template <class T> |
| 27 | struct always_equal_alloc { |
| 28 | using value_type = T; |
| 29 | always_equal_alloc(const always_equal_alloc&); |
| 30 | void allocate(std::size_t); |
| 31 | }; |
| 32 | |
| 33 | template <class T> |
| 34 | struct not_always_equal_alloc { |
| 35 | int i; |
| 36 | using value_type = T; |
| 37 | not_always_equal_alloc(const not_always_equal_alloc&); |
| 38 | void allocate(std::size_t); |
| 39 | }; |
| 40 | |
| 41 | static_assert(std::is_nothrow_move_assignable<std::list<MoveOnly>>::value, "" ); |
| 42 | static_assert(!std::is_nothrow_move_assignable<std::list<MoveOnly, test_allocator<MoveOnly>>>::value, "" ); |
| 43 | #if TEST_STD_VER >= 17 |
| 44 | static_assert(std::is_nothrow_move_assignable<std::list<MoveOnly, always_equal_alloc<MoveOnly>>>::value, "" ); |
| 45 | #endif |
| 46 | static_assert(!std::is_nothrow_move_assignable<std::list<MoveOnly, not_always_equal_alloc<MoveOnly>>>::value, "" ); |
| 47 | #if defined(_LIBCPP_VERSION) |
| 48 | static_assert(std::is_nothrow_move_assignable<std::list<MoveOnly, other_allocator<MoveOnly>>>::value, "" ); |
| 49 | #endif // _LIBCPP_VERSION |
| 50 | |