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