[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / concepts / concepts.lang / concept.constructible / constructible_from.compile.pass.cpp
blobfe0ecece3382f9a034cafcfe5f0bc1128746bc46
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 //===----------------------------------------------------------------------===//
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...>;
15 #include <array>
16 #include <concepts>
17 #include <memory>
18 #include <string>
19 #include <type_traits>
21 struct Empty {};
23 struct Defaulted {
24 ~Defaulted() = default;
26 struct Deleted {
27 ~Deleted() = delete;
30 struct Noexcept {
31 ~Noexcept() noexcept;
33 struct NoexceptTrue {
34 ~NoexceptTrue() noexcept(true);
36 struct NoexceptFalse {
37 ~NoexceptFalse() noexcept(false);
40 struct Protected {
41 protected:
42 ~Protected() = default;
44 struct Private {
45 private:
46 ~Private() = default;
49 template <class T>
50 struct NoexceptDependant {
51 ~NoexceptDependant() noexcept(std::is_same_v<T, int>);
54 template <class T, class... Args>
55 void test() {
56 static_assert(std::constructible_from<T, Args...> ==
57 (std::destructible<T> && std::is_constructible_v<T, Args...>));
60 void test() {
61 test<bool>();
62 test<bool, bool>();
64 test<char>();
65 test<char, char>();
66 test<char, int>();
68 test<int>();
69 test<int, int>();
70 test<int, int, int>();
72 test<double, int>();
73 test<double, float>();
74 test<double, long double>();
76 test<void>();
77 test<void, bool>();
78 test<void, int>();
80 test<void*>();
81 test<void*, std::nullptr_t>();
83 test<int*>();
84 test<int*, std::nullptr_t>();
85 test<int[], int, int, int>();
86 test<int[1]>();
87 test<int[1], int>();
88 test<int[1], int, int>();
90 test<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)>();
118 test<int&>();
119 test<int&, int>();
120 test<int&&>();
121 test<int&&, int>();
123 test<Empty>();
125 test<Defaulted>();
126 test<Deleted>();
128 test<NoexceptTrue>();
129 test<NoexceptFalse>();
130 test<Noexcept>();
132 test<Protected>();
133 test<Private>();
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>();