Dan Albert | 287553d | 2017-02-16 10:47:51 -0800 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // type_traits |
| 11 | |
| 12 | // is_trivially_copy_assignable |
| 13 | |
| 14 | // XFAIL: gcc-4.9 |
| 15 | |
| 16 | #include <type_traits> |
| 17 | #include "test_macros.h" |
| 18 | |
| 19 | template <class T> |
| 20 | void test_has_trivially_copy_assignable() |
| 21 | { |
| 22 | static_assert( std::is_trivially_copy_assignable<T>::value, ""); |
| 23 | #if TEST_STD_VER > 14 |
| 24 | static_assert( std::is_trivially_copy_assignable_v<T>, ""); |
| 25 | #endif |
| 26 | } |
| 27 | |
| 28 | template <class T> |
| 29 | void test_has_not_trivially_copy_assignable() |
| 30 | { |
| 31 | static_assert(!std::is_trivially_copy_assignable<T>::value, ""); |
| 32 | #if TEST_STD_VER > 14 |
| 33 | static_assert(!std::is_trivially_copy_assignable_v<T>, ""); |
| 34 | #endif |
| 35 | } |
| 36 | |
| 37 | class Empty |
| 38 | { |
| 39 | }; |
| 40 | |
| 41 | class NotEmpty |
| 42 | { |
| 43 | virtual ~NotEmpty(); |
| 44 | }; |
| 45 | |
| 46 | union Union {}; |
| 47 | |
| 48 | struct bit_zero |
| 49 | { |
| 50 | int : 0; |
| 51 | }; |
| 52 | |
| 53 | class Abstract |
| 54 | { |
| 55 | virtual ~Abstract() = 0; |
| 56 | }; |
| 57 | |
| 58 | struct A |
| 59 | { |
| 60 | A& operator=(const A&); |
| 61 | }; |
| 62 | |
| 63 | int main() |
| 64 | { |
| 65 | test_has_trivially_copy_assignable<int&>(); |
| 66 | test_has_trivially_copy_assignable<Union>(); |
| 67 | test_has_trivially_copy_assignable<Empty>(); |
| 68 | test_has_trivially_copy_assignable<int>(); |
| 69 | test_has_trivially_copy_assignable<double>(); |
| 70 | test_has_trivially_copy_assignable<int*>(); |
| 71 | test_has_trivially_copy_assignable<const int*>(); |
| 72 | test_has_trivially_copy_assignable<bit_zero>(); |
| 73 | |
| 74 | test_has_not_trivially_copy_assignable<void>(); |
| 75 | test_has_not_trivially_copy_assignable<A>(); |
| 76 | test_has_not_trivially_copy_assignable<NotEmpty>(); |
| 77 | test_has_not_trivially_copy_assignable<Abstract>(); |
| 78 | test_has_not_trivially_copy_assignable<const Empty>(); |
| 79 | |
| 80 | } |