| 1 |
// Copyright (C) 2019-2025 Free Software Foundation, Inc. |
| 2 |
// |
| 3 |
// This file is part of the GNU ISO C++ Library. This library is free |
| 4 |
// software; you can redistribute it and/or modify it under the |
| 5 |
// terms of the GNU General Public License as published by the |
| 6 |
// Free Software Foundation; either version 3, or (at your option) |
| 7 |
// any later version. |
| 8 |
|
| 9 |
// This library is distributed in the hope that it will be useful, |
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
// GNU General Public License for more details. |
| 13 |
|
| 14 |
// You should have received a copy of the GNU General Public License along |
| 15 |
// with this library; see the file COPYING3. If not see |
| 16 |
// <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
// { dg-do compile { target c++20 } } |
| 19 |
|
| 20 |
#include <concepts> |
| 21 |
|
| 22 |
static_assert( !std::destructible<void> ); |
| 23 |
static_assert( std::destructible<char> ); |
| 24 |
static_assert( std::destructible<float> ); |
| 25 |
static_assert( std::destructible<int*> ); |
| 26 |
static_assert( std::destructible<int&> ); |
| 27 |
static_assert( std::destructible<int&&> ); |
| 28 |
static_assert( std::destructible<const int&> ); |
| 29 |
static_assert( !std::destructible<int[]> ); |
| 30 |
static_assert( std::destructible<int[2]> ); |
| 31 |
static_assert( std::destructible<int[2][3]> ); |
| 32 |
static_assert( !std::destructible<int()> ); |
| 33 |
static_assert( std::destructible<int(*)()> ); |
| 34 |
static_assert( std::destructible<int(&)()> ); |
| 35 |
|
| 36 |
enum E { }; |
| 37 |
static_assert( std::destructible<E> ); |
| 38 |
enum class CE { }; |
| 39 |
static_assert( std::destructible<CE> ); |
| 40 |
struct A { }; |
| 41 |
static_assert( std::destructible<A> ); |
| 42 |
union B { }; |
| 43 |
static_assert( std::destructible<B> ); |
| 44 |
|
| 45 |
struct C |
| 46 |
{ |
| 47 |
~C() noexcept(false) { } |
| 48 |
}; |
| 49 |
static_assert( !std::destructible<C> ); |
| 50 |
static_assert( std::destructible<C&> ); |
| 51 |
static_assert( !std::destructible<C[1]> ); |
| 52 |
class D |
| 53 |
{ |
| 54 |
public: |
| 55 |
D() { } |
| 56 |
private: |
| 57 |
~D() { } |
| 58 |
}; |
| 59 |
static_assert( !std::destructible<D> ); |
| 60 |
static_assert( std::destructible<D&> ); |
| 61 |
static_assert( !std::destructible<D[1]> ); |