Namespaces
Variants

std::meta::is_destructible_type, std::meta::is_trivially_destructible_type, std::meta::is_nothrow_destructible_type

From cppreference.com
< cpp | meta
 
 
 
Reflection library
 
Reflection types and queries
Type properties
Type property queries
 
Defined in header <meta>
consteval bool is_destructible_type( std::meta::info r );
(1) (since C++26)
consteval bool is_trivially_destructible_type( std::meta::info r );
(2) (since C++26)
consteval bool is_nothrow_destructible_type( std::meta::info r );
(3) (since C++26)

Returns true if r represents a type T that is destructible, trivially destructible or non-throwing destructible, respectively, that is, T has an appropriate destructor.

1) Equivalent to return std::is_destructible_v<T>;.
2) Equivalent to return std::is_trivially_destructible_v<T>;.
3) Equivalent to return std::is_nothrow_destructible_v<T>;.

If T is not a complete type, (possibly cv-qualified) void, or an array of unknown bound, the program is ill-formed.

If an instantiation of a template above depends, directly or indirectly, on an incomplete type, and that instantiation could yield a different result if that type were hypothetically completed, the program is ill-formed.

Parameters

r - a reflection value to test

Return value

true if r represents a type that is:

1) destructible,
2) trivially destructible or
3) non-throwing destructible,

as described above. Otherwise, false.

Exceptions

Throws std::meta::exception if r does not represent a type or type alias.

Notes

Because the C++ program terminates if a destructor throws an exception during stack unwinding (which usually cannot be predicted), all practical destructors are non-throwing even if they are not declared noexcept. All destructors found in the C++ standard library are non-throwing.

Storage occupied by trivially destructible objects may be reused without calling the destructor.

Example

#include <meta>
#include <string>

struct Foo
{
    std::string str;
    ~Foo() noexcept {};
};

struct Bar
{
    ~Bar() = default;
};

static_assert(
    is_destructible_type(^^std::string) == true and
    is_destructible_type(^^Foo) == true and
    is_trivially_destructible_type(^^Foo) == false and
    is_nothrow_destructible_type(^^Foo) == true and
    is_trivially_destructible_type(^^Bar) == true and
"");

int main() {}

See also

checks if reflected type has a constructor for specific arguments
(function template) [edit]
checks if reflected type has a virtual destructor
(function) [edit]
specifies that an object of the type can be destroyed
(concept) [edit]
destructor releases claimed resources[edit]
checks if a type has a non-deleted destructor
(class template) [edit]