| 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& operator=(vector&& 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 <vector> |
| 21 |
#include <cassert> |
| 22 |
|
| 23 |
#include "test_macros.h" |
| 24 |
#include "test_allocator.h" |
| 25 |
|
| 26 |
template <class T> |
| 27 |
struct some_alloc |
| 28 |
{ |
| 29 |
typedef T value_type; |
| 30 |
some_alloc(const some_alloc&); |
| 31 |
}; |
| 32 |
|
| 33 |
template <class T> |
| 34 |
struct some_alloc2 |
| 35 |
{ |
| 36 |
typedef T value_type; |
| 37 |
|
| 38 |
some_alloc2() {} |
| 39 |
some_alloc2(const some_alloc2&); |
| 40 |
void deallocate(void*, unsigned) {} |
| 41 |
|
| 42 |
typedef std::false_type propagate_on_container_move_assignment; |
| 43 |
typedef std::true_type is_always_equal; |
| 44 |
}; |
| 45 |
|
| 46 |
template <class T> |
| 47 |
struct some_alloc3 |
| 48 |
{ |
| 49 |
typedef T value_type; |
| 50 |
|
| 51 |
some_alloc3() {} |
| 52 |
some_alloc3(const some_alloc3&); |
| 53 |
void deallocate(void*, unsigned) {} |
| 54 |
|
| 55 |
typedef std::false_type propagate_on_container_move_assignment; |
| 56 |
typedef std::false_type is_always_equal; |
| 57 |
}; |
| 58 |
|
| 59 |
int main(int, char**) |
| 60 |
{ |
| 61 |
#if defined(_LIBCPP_VERSION) |
| 62 |
{ |
| 63 |
typedef std::vector<bool> C; |
| 64 |
static_assert(std::is_nothrow_move_assignable<C>::value, ""); |
| 65 |
} |
| 66 |
#endif // _LIBCPP_VERSION |
| 67 |
{ |
| 68 |
typedef std::vector<bool, test_allocator<bool>> C; |
| 69 |
static_assert(!std::is_nothrow_move_assignable<C>::value, ""); |
| 70 |
} |
| 71 |
#if defined(_LIBCPP_VERSION) |
| 72 |
{ |
| 73 |
typedef std::vector<bool, other_allocator<bool>> C; |
| 74 |
static_assert(std::is_nothrow_move_assignable<C>::value, ""); |
| 75 |
} |
| 76 |
#endif // _LIBCPP_VERSION |
| 77 |
{ |
| 78 |
#if TEST_STD_VER > 14 |
| 79 |
#if defined(_LIBCPP_VERSION) |
| 80 |
typedef std::vector<bool, some_alloc<bool>> C; |
| 81 |
static_assert( std::is_nothrow_move_assignable<C>::value, ""); |
| 82 |
#endif // _LIBCPP_VERSION |
| 83 |
#else |
| 84 |
typedef std::vector<bool, some_alloc<bool>> C; |
| 85 |
static_assert(!std::is_nothrow_move_assignable<C>::value, ""); |
| 86 |
#endif |
| 87 |
} |
| 88 |
#if TEST_STD_VER > 14 |
| 89 |
#if defined(_LIBCPP_VERSION) |
| 90 |
{ // POCMA false, is_always_equal true |
| 91 |
typedef std::vector<bool, some_alloc2<bool>> C; |
| 92 |
static_assert( std::is_nothrow_move_assignable<C>::value, ""); |
| 93 |
} |
| 94 |
#endif // _LIBCPP_VERSION |
| 95 |
{ // POCMA false, is_always_equal false |
| 96 |
typedef std::vector<bool, some_alloc3<bool>> C; |
| 97 |
static_assert(!std::is_nothrow_move_assignable<C>::value, ""); |
| 98 |
} |
| 99 |
#endif |
| 100 |
|
| 101 |
return 0; |
| 102 |
} |