1 | //===----------------------------------------------------------------------===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | // UNSUPPORTED: c++03 |
10 | |
11 | // <type_traits> |
12 | |
13 | // __is_implicitly_default_constructible<Tp> |
14 | |
15 | #include <type_traits> |
16 | |
17 | |
18 | struct ExplicitlyDefaultConstructible1 { |
19 | explicit ExplicitlyDefaultConstructible1() = default; |
20 | }; |
21 | |
22 | struct ExplicitlyDefaultConstructible2 { |
23 | explicit ExplicitlyDefaultConstructible2() { } |
24 | }; |
25 | |
26 | struct ImplicitlyDefaultConstructible1 { |
27 | ImplicitlyDefaultConstructible1() { } |
28 | }; |
29 | |
30 | struct ImplicitlyDefaultConstructible2 { |
31 | ImplicitlyDefaultConstructible2() = default; |
32 | }; |
33 | |
34 | struct NonDefaultConstructible1 { |
35 | NonDefaultConstructible1() = delete; |
36 | }; |
37 | |
38 | struct NonDefaultConstructible2 { |
39 | explicit NonDefaultConstructible2() = delete; |
40 | }; |
41 | |
42 | struct NonDefaultConstructible3 { |
43 | NonDefaultConstructible3(NonDefaultConstructible3&&) { } |
44 | }; |
45 | |
46 | struct ProtectedDefaultConstructible { |
47 | protected: |
48 | ProtectedDefaultConstructible() = default; |
49 | }; |
50 | |
51 | struct PrivateDefaultConstructible { |
52 | private: |
53 | PrivateDefaultConstructible() = default; |
54 | }; |
55 | |
56 | struct Base { }; |
57 | |
58 | struct ProtectedDefaultConstructibleWithBase : Base { |
59 | protected: |
60 | ProtectedDefaultConstructibleWithBase() = default; |
61 | }; |
62 | |
63 | struct PrivateDefaultConstructibleWithBase : Base { |
64 | private: |
65 | PrivateDefaultConstructibleWithBase() = default; |
66 | }; |
67 | |
68 | static_assert(!std::__is_implicitly_default_constructible<ExplicitlyDefaultConstructible1>::value, "" ); |
69 | static_assert(!std::__is_implicitly_default_constructible<ExplicitlyDefaultConstructible2>::value, "" ); |
70 | static_assert(std::__is_implicitly_default_constructible<ImplicitlyDefaultConstructible1>::value, "" ); |
71 | static_assert(std::__is_implicitly_default_constructible<ImplicitlyDefaultConstructible2>::value, "" ); |
72 | static_assert(!std::__is_implicitly_default_constructible<NonDefaultConstructible1>::value, "" ); |
73 | static_assert(!std::__is_implicitly_default_constructible<NonDefaultConstructible2>::value, "" ); |
74 | static_assert(!std::__is_implicitly_default_constructible<NonDefaultConstructible3>::value, "" ); |
75 | static_assert(!std::__is_implicitly_default_constructible<ProtectedDefaultConstructible>::value, "" ); |
76 | static_assert(!std::__is_implicitly_default_constructible<PrivateDefaultConstructible>::value, "" ); |
77 | static_assert(!std::__is_implicitly_default_constructible<ProtectedDefaultConstructibleWithBase>::value, "" ); |
78 | static_assert(!std::__is_implicitly_default_constructible<PrivateDefaultConstructibleWithBase>::value, "" ); |
79 | |
80 | int main(int, char**) { |
81 | return 0; |
82 | } |
83 | |