1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
11 // template<class T, class... Args>
12 // concept constructible_from;
13 // destructible<T> && is_constructible_v<T, Args...>;
19 #include <type_traits>
24 ~Defaulted() = default;
34 ~NoexceptTrue() noexcept(true);
36 struct NoexceptFalse
{
37 ~NoexceptFalse() noexcept(false);
42 ~Protected() = default;
50 struct NoexceptDependant
{
51 ~NoexceptDependant() noexcept(std::is_same_v
<T
, int>);
54 template <class T
, class... Args
>
56 static_assert(std::constructible_from
<T
, Args
...> ==
57 (std::destructible
<T
> && std::is_constructible_v
<T
, Args
...>));
70 test
<int, int, int>();
73 test
<double, float>();
74 test
<double, long double>();
81 test
<void*, std::nullptr_t
>();
84 test
<int*, std::nullptr_t
>();
85 test
<int[], int, int, int>();
88 test
<int[1], int, int>();
91 test
<int (*)(int), int>();
92 test
<int (*)(int), double>();
93 test
<int (*)(int), std::nullptr_t
>();
94 test
<int (*)(int), int (*)(int)>();
96 test
<void (Empty::*)(const int&)>();
97 test
<void (Empty::*)(const int&), std::nullptr_t
>();
98 test
<void (Empty::*)(const int&) const>();
99 test
<void (Empty::*)(const int&) const, void (Empty::*)(const int&)>();
100 test
<void (Empty::*)(const int&) volatile>();
101 test
<void (Empty::*)(const int&) volatile,
102 void (Empty::*)(const int&) const volatile>();
103 test
<void (Empty::*)(const int&) const volatile>();
104 test
<void (Empty::*)(const int&) const volatile, double>();
105 test
<void (Empty::*)(const int&)&>();
106 test
<void (Empty::*)(const int&)&, void (Empty::*)(const int&) &&>();
107 test
<void (Empty::*)(const int&) &&>();
108 test
<void (Empty::*)(const int&)&&, void (Empty::*)(const int&)>();
109 test
<void (Empty::*)(const int&) throw()>();
110 test
<void (Empty::*)(const int&) throw(),
111 void(Empty::*)(const int&) noexcept(true)>();
112 test
<void (Empty::*)(const int&) noexcept
>();
113 test
<void (Empty::*)(const int&) noexcept(true)>();
114 test
<void (Empty::*)(const int&) noexcept(true),
115 void (Empty::*)(const int&) noexcept(false)>();
116 test
<void (Empty::*)(const int&) noexcept(false)>();
128 test
<NoexceptTrue
>();
129 test
<NoexceptFalse
>();
135 test
<NoexceptDependant
<int> >();
136 test
<NoexceptDependant
<double> >();
138 test
<std::string
, char*>();
139 test
<std::string
, const char*>();
140 test
<std::string
, std::string
&>();
141 test
<std::string
, std::initializer_list
<char> >();
143 test
<std::unique_ptr
<int>, std::unique_ptr
<int> >();
144 test
<std::unique_ptr
<int>, std::unique_ptr
<int>&>();
145 test
<std::unique_ptr
<int>, std::unique_ptr
<int>&&>();
147 test
<std::array
<int, 1> >();
148 test
<std::array
<int, 1>, int>();
149 test
<std::array
<int, 1>, int, int>();