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
18struct ExplicitlyDefaultConstructible1 {
19 explicit ExplicitlyDefaultConstructible1() = default;
20};
21
22struct ExplicitlyDefaultConstructible2 {
23 explicit ExplicitlyDefaultConstructible2() { }
24};
25
26struct ImplicitlyDefaultConstructible1 {
27 ImplicitlyDefaultConstructible1() { }
28};
29
30struct ImplicitlyDefaultConstructible2 {
31 ImplicitlyDefaultConstructible2() = default;
32};
33
34struct NonDefaultConstructible1 {
35 NonDefaultConstructible1() = delete;
36};
37
38struct NonDefaultConstructible2 {
39 explicit NonDefaultConstructible2() = delete;
40};
41
42struct NonDefaultConstructible3 {
43 NonDefaultConstructible3(NonDefaultConstructible3&&) { }
44};
45
46struct ProtectedDefaultConstructible {
47protected:
48 ProtectedDefaultConstructible() = default;
49};
50
51struct PrivateDefaultConstructible {
52private:
53 PrivateDefaultConstructible() = default;
54};
55
56struct Base { };
57
58struct ProtectedDefaultConstructibleWithBase : Base {
59protected:
60 ProtectedDefaultConstructibleWithBase() = default;
61};
62
63struct PrivateDefaultConstructibleWithBase : Base {
64private:
65 PrivateDefaultConstructibleWithBase() = default;
66};
67
68static_assert(!std::__is_implicitly_default_constructible<ExplicitlyDefaultConstructible1>::value, "");
69static_assert(!std::__is_implicitly_default_constructible<ExplicitlyDefaultConstructible2>::value, "");
70static_assert(std::__is_implicitly_default_constructible<ImplicitlyDefaultConstructible1>::value, "");
71static_assert(std::__is_implicitly_default_constructible<ImplicitlyDefaultConstructible2>::value, "");
72static_assert(!std::__is_implicitly_default_constructible<NonDefaultConstructible1>::value, "");
73static_assert(!std::__is_implicitly_default_constructible<NonDefaultConstructible2>::value, "");
74static_assert(!std::__is_implicitly_default_constructible<NonDefaultConstructible3>::value, "");
75static_assert(!std::__is_implicitly_default_constructible<ProtectedDefaultConstructible>::value, "");
76static_assert(!std::__is_implicitly_default_constructible<PrivateDefaultConstructible>::value, "");
77static_assert(!std::__is_implicitly_default_constructible<ProtectedDefaultConstructibleWithBase>::value, "");
78static_assert(!std::__is_implicitly_default_constructible<PrivateDefaultConstructibleWithBase>::value, "");
79
80int main(int, char**) {
81 return 0;
82}
83

source code of libcxx/test/libcxx/type_traits/is_implicitly_default_constructible.pass.cpp