is_nothrow_copy_constructible.pass.cpp revision 1468b668aa964beb1220e9b36162b092fb54952b
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 16template <class T> 17void 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 static_assert( std::is_nothrow_copy_constructible<volatile T>::value, ""); 22 static_assert( std::is_nothrow_copy_constructible<const volatile T>::value, ""); 23} 24 25template <class T> 26void test_has_not_nothrow_copy_constructor() 27{ 28 static_assert(!std::is_nothrow_copy_constructible<T>::value, ""); 29 static_assert(!std::is_nothrow_copy_constructible<const T>::value, ""); 30 static_assert(!std::is_nothrow_copy_constructible<volatile T>::value, ""); 31 static_assert(!std::is_nothrow_copy_constructible<const volatile T>::value, ""); 32} 33 34class Empty 35{ 36}; 37 38class NotEmpty 39{ 40public: 41 virtual ~NotEmpty(); 42}; 43 44union Union {}; 45 46struct bit_zero 47{ 48 int : 0; 49}; 50 51struct A 52{ 53 A(const A&); 54}; 55 56int main() 57{ 58 test_has_not_nothrow_copy_constructor<void>(); 59 test_has_not_nothrow_copy_constructor<A>(); 60 61 test_is_nothrow_copy_constructible<int&>(); 62 test_is_nothrow_copy_constructible<Union>(); 63 test_is_nothrow_copy_constructible<Empty>(); 64 test_is_nothrow_copy_constructible<int>(); 65 test_is_nothrow_copy_constructible<double>(); 66 test_is_nothrow_copy_constructible<int*>(); 67 test_is_nothrow_copy_constructible<const int*>(); 68 test_is_nothrow_copy_constructible<NotEmpty>(); 69 test_is_nothrow_copy_constructible<bit_zero>(); 70} 71