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, c++11, c++14, c++17
10
11// template<class T>
12// concept destructible = is_nothrow_destructible_v<T>;
13
14#include <concepts>
15#include <type_traits>
16
17struct Empty {};
18
19struct Defaulted {
20 ~Defaulted() = default;
21};
22struct Deleted {
23 ~Deleted() = delete;
24};
25
26struct Noexcept {
27 ~Noexcept() noexcept;
28};
29struct NoexceptTrue {
30 ~NoexceptTrue() noexcept(true);
31};
32struct NoexceptFalse {
33 ~NoexceptFalse() noexcept(false);
34};
35
36struct Protected {
37protected:
38 ~Protected() = default;
39};
40struct Private {
41private:
42 ~Private() = default;
43};
44
45template <class T>
46struct NoexceptDependant {
47 ~NoexceptDependant() noexcept(std::is_same_v<T, int>);
48};
49
50template <class T>
51void test() {
52 static_assert(std::destructible<T> == std::is_nothrow_destructible_v<T>);
53}
54
55void test() {
56 test<Empty>();
57
58 test<Defaulted>();
59 test<Deleted>();
60
61 test<Noexcept>();
62 test<NoexceptTrue>();
63 test<NoexceptFalse>();
64
65 test<Protected>();
66 test<Private>();
67
68 test<NoexceptDependant<int> >();
69 test<NoexceptDependant<double> >();
70
71 test<bool>();
72 test<char>();
73 test<int>();
74 test<double>();
75}
76

source code of libcxx/test/std/concepts/concepts.lang/concept.destructible/destructible.compile.pass.cpp