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