1*24dd2d2fSChristopher Di Bella //===----------------------------------------------------------------------===//
2*24dd2d2fSChristopher Di Bella //
3*24dd2d2fSChristopher Di Bella // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*24dd2d2fSChristopher Di Bella // See https://llvm.org/LICENSE.txt for license information.
5*24dd2d2fSChristopher Di Bella // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*24dd2d2fSChristopher Di Bella //
7*24dd2d2fSChristopher Di Bella //===----------------------------------------------------------------------===//
8*24dd2d2fSChristopher Di Bella
9*24dd2d2fSChristopher Di Bella // UNSUPPORTED: c++03, c++11, c++14, c++17
10*24dd2d2fSChristopher Di Bella
11*24dd2d2fSChristopher Di Bella // template<class T, class... Args>
12*24dd2d2fSChristopher Di Bella // concept constructible_from;
13*24dd2d2fSChristopher Di Bella // destructible<T> && is_constructible_v<T, Args...>;
14*24dd2d2fSChristopher Di Bella
15*24dd2d2fSChristopher Di Bella #include <array>
16*24dd2d2fSChristopher Di Bella #include <concepts>
17*24dd2d2fSChristopher Di Bella #include <memory>
18*24dd2d2fSChristopher Di Bella #include <string>
19*24dd2d2fSChristopher Di Bella #include <type_traits>
20*24dd2d2fSChristopher Di Bella
21*24dd2d2fSChristopher Di Bella struct Empty {};
22*24dd2d2fSChristopher Di Bella
23*24dd2d2fSChristopher Di Bella struct Defaulted {
24*24dd2d2fSChristopher Di Bella ~Defaulted() = default;
25*24dd2d2fSChristopher Di Bella };
26*24dd2d2fSChristopher Di Bella struct Deleted {
27*24dd2d2fSChristopher Di Bella ~Deleted() = delete;
28*24dd2d2fSChristopher Di Bella };
29*24dd2d2fSChristopher Di Bella
30*24dd2d2fSChristopher Di Bella struct Noexcept {
31*24dd2d2fSChristopher Di Bella ~Noexcept() noexcept;
32*24dd2d2fSChristopher Di Bella };
33*24dd2d2fSChristopher Di Bella struct NoexceptTrue {
34*24dd2d2fSChristopher Di Bella ~NoexceptTrue() noexcept(true);
35*24dd2d2fSChristopher Di Bella };
36*24dd2d2fSChristopher Di Bella struct NoexceptFalse {
37*24dd2d2fSChristopher Di Bella ~NoexceptFalse() noexcept(false);
38*24dd2d2fSChristopher Di Bella };
39*24dd2d2fSChristopher Di Bella
40*24dd2d2fSChristopher Di Bella struct Protected {
41*24dd2d2fSChristopher Di Bella protected:
42*24dd2d2fSChristopher Di Bella ~Protected() = default;
43*24dd2d2fSChristopher Di Bella };
44*24dd2d2fSChristopher Di Bella struct Private {
45*24dd2d2fSChristopher Di Bella private:
46*24dd2d2fSChristopher Di Bella ~Private() = default;
47*24dd2d2fSChristopher Di Bella };
48*24dd2d2fSChristopher Di Bella
49*24dd2d2fSChristopher Di Bella template <class T>
50*24dd2d2fSChristopher Di Bella struct NoexceptDependant {
51*24dd2d2fSChristopher Di Bella ~NoexceptDependant() noexcept(std::is_same_v<T, int>);
52*24dd2d2fSChristopher Di Bella };
53*24dd2d2fSChristopher Di Bella
54*24dd2d2fSChristopher Di Bella template <class T, class... Args>
test()55*24dd2d2fSChristopher Di Bella void test() {
56*24dd2d2fSChristopher Di Bella static_assert(std::constructible_from<T, Args...> ==
57*24dd2d2fSChristopher Di Bella (std::destructible<T> && std::is_constructible_v<T, Args...>));
58*24dd2d2fSChristopher Di Bella }
59*24dd2d2fSChristopher Di Bella
test()60*24dd2d2fSChristopher Di Bella void test() {
61*24dd2d2fSChristopher Di Bella test<bool>();
62*24dd2d2fSChristopher Di Bella test<bool, bool>();
63*24dd2d2fSChristopher Di Bella
64*24dd2d2fSChristopher Di Bella test<char>();
65*24dd2d2fSChristopher Di Bella test<char, char>();
66*24dd2d2fSChristopher Di Bella test<char, int>();
67*24dd2d2fSChristopher Di Bella
68*24dd2d2fSChristopher Di Bella test<int>();
69*24dd2d2fSChristopher Di Bella test<int, int>();
70*24dd2d2fSChristopher Di Bella test<int, int, int>();
71*24dd2d2fSChristopher Di Bella
72*24dd2d2fSChristopher Di Bella test<double, int>();
73*24dd2d2fSChristopher Di Bella test<double, float>();
74*24dd2d2fSChristopher Di Bella test<double, long double>();
75*24dd2d2fSChristopher Di Bella
76*24dd2d2fSChristopher Di Bella test<void>();
77*24dd2d2fSChristopher Di Bella test<void, bool>();
78*24dd2d2fSChristopher Di Bella test<void, int>();
79*24dd2d2fSChristopher Di Bella
80*24dd2d2fSChristopher Di Bella test<void*>();
81*24dd2d2fSChristopher Di Bella test<void*, std::nullptr_t>();
82*24dd2d2fSChristopher Di Bella
83*24dd2d2fSChristopher Di Bella test<int*>();
84*24dd2d2fSChristopher Di Bella test<int*, std::nullptr_t>();
85*24dd2d2fSChristopher Di Bella test<int[], int, int, int>();
86*24dd2d2fSChristopher Di Bella test<int[1]>();
87*24dd2d2fSChristopher Di Bella test<int[1], int>();
88*24dd2d2fSChristopher Di Bella test<int[1], int, int>();
89*24dd2d2fSChristopher Di Bella
90*24dd2d2fSChristopher Di Bella test<int (*)(int)>();
91*24dd2d2fSChristopher Di Bella test<int (*)(int), int>();
92*24dd2d2fSChristopher Di Bella test<int (*)(int), double>();
93*24dd2d2fSChristopher Di Bella test<int (*)(int), std::nullptr_t>();
94*24dd2d2fSChristopher Di Bella test<int (*)(int), int (*)(int)>();
95*24dd2d2fSChristopher Di Bella
96*24dd2d2fSChristopher Di Bella test<void (Empty::*)(const int&)>();
97*24dd2d2fSChristopher Di Bella test<void (Empty::*)(const int&), std::nullptr_t>();
98*24dd2d2fSChristopher Di Bella test<void (Empty::*)(const int&) const>();
99*24dd2d2fSChristopher Di Bella test<void (Empty::*)(const int&) const, void (Empty::*)(const int&)>();
100*24dd2d2fSChristopher Di Bella test<void (Empty::*)(const int&) volatile>();
101*24dd2d2fSChristopher Di Bella test<void (Empty::*)(const int&) volatile,
102*24dd2d2fSChristopher Di Bella void (Empty::*)(const int&) const volatile>();
103*24dd2d2fSChristopher Di Bella test<void (Empty::*)(const int&) const volatile>();
104*24dd2d2fSChristopher Di Bella test<void (Empty::*)(const int&) const volatile, double>();
105*24dd2d2fSChristopher Di Bella test<void (Empty::*)(const int&)&>();
106*24dd2d2fSChristopher Di Bella test<void (Empty::*)(const int&)&, void (Empty::*)(const int&) &&>();
107*24dd2d2fSChristopher Di Bella test<void (Empty::*)(const int&) &&>();
108*24dd2d2fSChristopher Di Bella test<void (Empty::*)(const int&)&&, void (Empty::*)(const int&)>();
109*24dd2d2fSChristopher Di Bella test<void (Empty::*)(const int&) throw()>();
110*24dd2d2fSChristopher Di Bella test<void (Empty::*)(const int&) throw(),
111*24dd2d2fSChristopher Di Bella void(Empty::*)(const int&) noexcept(true)>();
112*24dd2d2fSChristopher Di Bella test<void (Empty::*)(const int&) noexcept>();
113*24dd2d2fSChristopher Di Bella test<void (Empty::*)(const int&) noexcept(true)>();
114*24dd2d2fSChristopher Di Bella test<void (Empty::*)(const int&) noexcept(true),
115*24dd2d2fSChristopher Di Bella void (Empty::*)(const int&) noexcept(false)>();
116*24dd2d2fSChristopher Di Bella test<void (Empty::*)(const int&) noexcept(false)>();
117*24dd2d2fSChristopher Di Bella
118*24dd2d2fSChristopher Di Bella test<int&>();
119*24dd2d2fSChristopher Di Bella test<int&, int>();
120*24dd2d2fSChristopher Di Bella test<int&&>();
121*24dd2d2fSChristopher Di Bella test<int&&, int>();
122*24dd2d2fSChristopher Di Bella
123*24dd2d2fSChristopher Di Bella test<Empty>();
124*24dd2d2fSChristopher Di Bella
125*24dd2d2fSChristopher Di Bella test<Defaulted>();
126*24dd2d2fSChristopher Di Bella test<Deleted>();
127*24dd2d2fSChristopher Di Bella
128*24dd2d2fSChristopher Di Bella test<NoexceptTrue>();
129*24dd2d2fSChristopher Di Bella test<NoexceptFalse>();
130*24dd2d2fSChristopher Di Bella test<Noexcept>();
131*24dd2d2fSChristopher Di Bella
132*24dd2d2fSChristopher Di Bella test<Protected>();
133*24dd2d2fSChristopher Di Bella test<Private>();
134*24dd2d2fSChristopher Di Bella
135*24dd2d2fSChristopher Di Bella test<NoexceptDependant<int> >();
136*24dd2d2fSChristopher Di Bella test<NoexceptDependant<double> >();
137*24dd2d2fSChristopher Di Bella
138*24dd2d2fSChristopher Di Bella test<std::string, char*>();
139*24dd2d2fSChristopher Di Bella test<std::string, const char*>();
140*24dd2d2fSChristopher Di Bella test<std::string, std::string&>();
141*24dd2d2fSChristopher Di Bella test<std::string, std::initializer_list<char> >();
142*24dd2d2fSChristopher Di Bella
143*24dd2d2fSChristopher Di Bella test<std::unique_ptr<int>, std::unique_ptr<int> >();
144*24dd2d2fSChristopher Di Bella test<std::unique_ptr<int>, std::unique_ptr<int>&>();
145*24dd2d2fSChristopher Di Bella test<std::unique_ptr<int>, std::unique_ptr<int>&&>();
146*24dd2d2fSChristopher Di Bella
147*24dd2d2fSChristopher Di Bella test<std::array<int, 1> >();
148*24dd2d2fSChristopher Di Bella test<std::array<int, 1>, int>();
149*24dd2d2fSChristopher Di Bella test<std::array<int, 1>, int, int>();
150*24dd2d2fSChristopher Di Bella }
151*24dd2d2fSChristopher Di Bella
main(int,char **)152*24dd2d2fSChristopher Di Bella int main(int, char**) { return 0; }
153