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_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_copy_constructible() 21 { 22 static_assert( std::is_trivially_copy_constructible<T>::value, ""); 23 static_assert( std::is_trivially_copy_constructible<const T>::value, ""); 24 #if TEST_STD_VER > 14 25 static_assert( std::is_trivially_copy_constructible_v<T>, ""); 26 static_assert( std::is_trivially_copy_constructible_v<const T>, ""); 27 #endif 28 } 29 30 template <class T> 31 void test_has_not_trivial_copy_constructor() 32 { 33 static_assert(!std::is_trivially_copy_constructible<T>::value, ""); 34 static_assert(!std::is_trivially_copy_constructible<const T>::value, ""); 35 #if TEST_STD_VER > 14 36 static_assert(!std::is_trivially_copy_constructible_v<T>, ""); 37 static_assert(!std::is_trivially_copy_constructible_v<const T>, ""); 38 #endif 39 } 40 41 class Empty 42 { 43 }; 44 45 class NotEmpty 46 { 47 public: 48 virtual ~NotEmpty(); 49 }; 50 51 union Union {}; 52 53 struct bit_zero 54 { 55 int : 0; 56 }; 57 58 class Abstract 59 { 60 public: 61 virtual ~Abstract() = 0; 62 }; 63 64 struct A 65 { 66 A(const A&); 67 }; 68 69 int main() 70 { 71 test_has_not_trivial_copy_constructor<void>(); 72 test_has_not_trivial_copy_constructor<A>(); 73 test_has_not_trivial_copy_constructor<Abstract>(); 74 test_has_not_trivial_copy_constructor<NotEmpty>(); 75 76 test_is_trivially_copy_constructible<int&>(); 77 test_is_trivially_copy_constructible<Union>(); 78 test_is_trivially_copy_constructible<Empty>(); 79 test_is_trivially_copy_constructible<int>(); 80 test_is_trivially_copy_constructible<double>(); 81 test_is_trivially_copy_constructible<int*>(); 82 test_is_trivially_copy_constructible<const int*>(); 83 test_is_trivially_copy_constructible<bit_zero>(); 84 } 85