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_nothrow_copy_constructible 13 14 #include <type_traits> 15 16 template <class T> 17 void test_is_nothrow_copy_constructible() 18 { 19 static_assert( std::is_nothrow_copy_constructible<T>::value, ""); 20 static_assert( std::is_nothrow_copy_constructible<const T>::value, ""); 21 } 22 23 template <class T> 24 void test_has_not_nothrow_copy_constructor() 25 { 26 static_assert(!std::is_nothrow_copy_constructible<T>::value, ""); 27 static_assert(!std::is_nothrow_copy_constructible<const T>::value, ""); 28 static_assert(!std::is_nothrow_copy_constructible<volatile T>::value, ""); 29 static_assert(!std::is_nothrow_copy_constructible<const volatile T>::value, ""); 30 } 31 32 class Empty 33 { 34 }; 35 36 union Union {}; 37 38 struct bit_zero 39 { 40 int : 0; 41 }; 42 43 struct A 44 { 45 A(const A&); 46 }; 47 48 int main() 49 { 50 test_has_not_nothrow_copy_constructor<void>(); 51 test_has_not_nothrow_copy_constructor<A>(); 52 53 test_is_nothrow_copy_constructible<int&>(); 54 test_is_nothrow_copy_constructible<Union>(); 55 test_is_nothrow_copy_constructible<Empty>(); 56 test_is_nothrow_copy_constructible<int>(); 57 test_is_nothrow_copy_constructible<double>(); 58 test_is_nothrow_copy_constructible<int*>(); 59 test_is_nothrow_copy_constructible<const int*>(); 60 test_is_nothrow_copy_constructible<bit_zero>(); 61 } 62