| 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_trivially_copy_assignable |
| 12 | |
| 13 | #include <type_traits> |
| 14 | #include "test_macros.h" |
| 15 | |
| 16 | template <class T> |
| 17 | void test_has_trivially_copy_assignable() |
| 18 | { |
| 19 | static_assert( std::is_trivially_copy_assignable<T>::value, ""); |
| 20 | #if TEST_STD_VER > 14 |
| 21 | static_assert( std::is_trivially_copy_assignable_v<T>, ""); |
| 22 | #endif |
| 23 | } |
| 24 | |
| 25 | template <class T> |
| 26 | void test_has_not_trivially_copy_assignable() |
| 27 | { |
| 28 | static_assert(!std::is_trivially_copy_assignable<T>::value, ""); |
| 29 | #if TEST_STD_VER > 14 |
| 30 | static_assert(!std::is_trivially_copy_assignable_v<T>, ""); |
| 31 | #endif |
| 32 | } |
| 33 | |
| 34 | class Empty |
| 35 | { |
| 36 | }; |
| 37 | |
| 38 | class NotEmpty |
| 39 | { |
| 40 | virtual ~NotEmpty(); |
| 41 | }; |
| 42 | |
| 43 | union Union {}; |
| 44 | |
| 45 | struct bit_zero |
| 46 | { |
| 47 | int : 0; |
| 48 | }; |
| 49 | |
| 50 | class Abstract |
| 51 | { |
| 52 | virtual ~Abstract() = 0; |
| 53 | }; |
| 54 | |
| 55 | struct A |
| 56 | { |
| 57 | A& operator=(const A&); |
| 58 | }; |
| 59 | |
| 60 | int main(int, char**) |
| 61 | { |
| 62 | test_has_trivially_copy_assignable<int&>(); |
| 63 | test_has_trivially_copy_assignable<Union>(); |
| 64 | test_has_trivially_copy_assignable<Empty>(); |
| 65 | test_has_trivially_copy_assignable<int>(); |
| 66 | test_has_trivially_copy_assignable<double>(); |
| 67 | test_has_trivially_copy_assignable<int*>(); |
| 68 | test_has_trivially_copy_assignable<const int*>(); |
| 69 | test_has_trivially_copy_assignable<bit_zero>(); |
| 70 | |
| 71 | test_has_not_trivially_copy_assignable<void>(); |
| 72 | test_has_not_trivially_copy_assignable<A>(); |
| 73 | test_has_not_trivially_copy_assignable<NotEmpty>(); |
| 74 | test_has_not_trivially_copy_assignable<Abstract>(); |
| 75 | test_has_not_trivially_copy_assignable<const Empty>(); |
| 76 | |
| 77 | |
| 78 | return 0; |
| 79 | } |
| 80 |
