is_trivially_move_constructible.pass.cpp (2088B)
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_move_constructible 13 14 // XFAIL: gcc-4.9 15 16 #include <type_traits> 17 #include "test_macros.h" 18 19 template <class T> 20 void test_is_trivially_move_constructible() 21 { 22 static_assert( std::is_trivially_move_constructible<T>::value, ""); 23 #if TEST_STD_VER > 14 24 static_assert( std::is_trivially_move_constructible_v<T>, ""); 25 #endif 26 } 27 28 template <class T> 29 void test_has_not_trivial_move_constructor() 30 { 31 static_assert(!std::is_trivially_move_constructible<T>::value, ""); 32 #if TEST_STD_VER > 14 33 static_assert(!std::is_trivially_move_constructible_v<T>, ""); 34 #endif 35 } 36 37 class Empty 38 { 39 }; 40 41 class NotEmpty 42 { 43 public: 44 virtual ~NotEmpty(); 45 }; 46 47 union Union {}; 48 49 struct bit_zero 50 { 51 int : 0; 52 }; 53 54 class Abstract 55 { 56 public: 57 virtual ~Abstract() = 0; 58 }; 59 60 struct A 61 { 62 A(const A&); 63 }; 64 65 #if TEST_STD_VER >= 11 66 67 struct MoveOnly1 68 { 69 MoveOnly1(MoveOnly1&&); 70 }; 71 72 struct MoveOnly2 73 { 74 MoveOnly2(MoveOnly2&&) = default; 75 }; 76 77 #endif 78 79 int main() 80 { 81 test_has_not_trivial_move_constructor<void>(); 82 test_has_not_trivial_move_constructor<A>(); 83 test_has_not_trivial_move_constructor<Abstract>(); 84 test_has_not_trivial_move_constructor<NotEmpty>(); 85 86 test_is_trivially_move_constructible<Union>(); 87 test_is_trivially_move_constructible<Empty>(); 88 test_is_trivially_move_constructible<int>(); 89 test_is_trivially_move_constructible<double>(); 90 test_is_trivially_move_constructible<int*>(); 91 test_is_trivially_move_constructible<const int*>(); 92 test_is_trivially_move_constructible<bit_zero>(); 93 94 #if TEST_STD_VER >= 11 95 static_assert(!std::is_trivially_move_constructible<MoveOnly1>::value, ""); 96 static_assert( std::is_trivially_move_constructible<MoveOnly2>::value, ""); 97 #endif 98 }