| 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 | // <vector> |
| 10 | |
| 11 | // vector(vector&&) |
| 12 | // noexcept(is_nothrow_move_constructible<allocator_type>::value); |
| 13 | |
| 14 | // This tests a conforming extension |
| 15 | |
| 16 | // UNSUPPORTED: c++03 |
| 17 | |
| 18 | #include <vector> |
| 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 | typedef T value_type; |
| 28 | some_alloc(const some_alloc&); |
| 29 | void allocate(std::size_t); |
| 30 | }; |
| 31 | |
| 32 | int main(int, char**) { |
| 33 | { |
| 34 | typedef std::vector<MoveOnly> C; |
| 35 | static_assert(std::is_nothrow_move_constructible<C>::value, "" ); |
| 36 | } |
| 37 | { |
| 38 | typedef std::vector<MoveOnly, test_allocator<MoveOnly>> C; |
| 39 | static_assert(std::is_nothrow_move_constructible<C>::value, "" ); |
| 40 | } |
| 41 | { |
| 42 | typedef std::vector<MoveOnly, other_allocator<MoveOnly>> C; |
| 43 | static_assert(std::is_nothrow_move_constructible<C>::value, "" ); |
| 44 | } |
| 45 | { |
| 46 | typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C; |
| 47 | // In C++17, move constructors for allocators are not allowed to throw |
| 48 | #if TEST_STD_VER > 14 |
| 49 | static_assert(std::is_nothrow_move_constructible<C>::value, "" ); |
| 50 | #else |
| 51 | static_assert(!std::is_nothrow_move_constructible<C>::value, "" ); |
| 52 | #endif |
| 53 | } |
| 54 | |
| 55 | return 0; |
| 56 | } |
| 57 | |