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 17 struct Empty {}; 18 19 struct Defaulted { 20 ~Defaulted() = default; 21 }; 22 struct Deleted { 23 ~Deleted() = delete; 24 }; 25 26 struct Noexcept { 27 ~Noexcept() noexcept; 28 }; 29 struct NoexceptTrue { 30 ~NoexceptTrue() noexcept(true); 31 }; 32 struct NoexceptFalse { 33 ~NoexceptFalse() noexcept(false); 34 }; 35 36 struct Protected { 37 protected: 38 ~Protected() = default; 39 }; 40 struct Private { 41 private: 42 ~Private() = default; 43 }; 44 45 template <class T> 46 struct NoexceptDependant { 47 ~NoexceptDependant() noexcept(std::is_same_v<T, int>); 48 }; 49 50 template <class T> test()51void test() { 52 static_assert(std::destructible<T> == std::is_nothrow_destructible_v<T>); 53 } 54 test()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