| 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 | // type_traits |
| 10 | |
| 11 | // is_nothrow_copy_assignable |
| 12 | |
| 13 | #include <type_traits> |
| 14 | #include "test_macros.h" |
| 15 | |
| 16 | #include "common.h" |
| 17 | |
| 18 | template <class T> |
| 19 | void test_has_nothrow_assign() |
| 20 | { |
| 21 | static_assert( std::is_nothrow_copy_assignable<T>::value, ""); |
| 22 | #if TEST_STD_VER > 14 |
| 23 | static_assert( std::is_nothrow_copy_assignable_v<T>, ""); |
| 24 | #endif |
| 25 | } |
| 26 | |
| 27 | template <class T> |
| 28 | void test_has_not_nothrow_assign() |
| 29 | { |
| 30 | static_assert(!std::is_nothrow_copy_assignable<T>::value, ""); |
| 31 | #if TEST_STD_VER > 14 |
| 32 | static_assert(!std::is_nothrow_copy_assignable_v<T>, ""); |
| 33 | #endif |
| 34 | } |
| 35 | |
| 36 | int main(int, char**) |
| 37 | { |
| 38 | test_has_nothrow_assign<int&>(); |
| 39 | test_has_nothrow_assign<Union>(); |
| 40 | test_has_nothrow_assign<Empty>(); |
| 41 | test_has_nothrow_assign<int>(); |
| 42 | test_has_nothrow_assign<double>(); |
| 43 | test_has_nothrow_assign<int*>(); |
| 44 | test_has_nothrow_assign<const int*>(); |
| 45 | test_has_nothrow_assign<NotEmpty>(); |
| 46 | test_has_nothrow_assign<bit_zero>(); |
| 47 | |
| 48 | // TODO: enable the test for GCC once https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106611 is resolved |
| 49 | #if TEST_STD_VER >= 11 && !defined(TEST_COMPILER_GCC) |
| 50 | test_has_not_nothrow_assign<TrivialNotNoexcept>(); |
| 51 | #endif |
| 52 | test_has_not_nothrow_assign<const int>(); |
| 53 | test_has_not_nothrow_assign<void>(); |
| 54 | test_has_not_nothrow_assign<A>(); |
| 55 | |
| 56 | |
| 57 | return 0; |
| 58 | } |
| 59 |
