std::is_destructible,std::is_trivially_destructible,std::is_nothrow_destructible (3) - Linux Manuals
std::is_destructible,std::is_trivially_destructible,std::is_nothrow_destructible: std::is_destructible,std::is_trivially_destructible,std::is_nothrow_destructible
NAME
std::is_destructible,std::is_trivially_destructible,std::is_nothrow_destructible - std::is_destructible,std::is_trivially_destructible,std::is_nothrow_destructible
Synopsis
Defined in header <type_traits>
template< class T > (1) (since C++11)
struct is_destructible;
template< class T > (2) (since C++11)
struct is_trivially_destructible;
template< class T > (3) (since C++11)
struct is_nothrow_destructible;
1) If an imaginary struct containing a member object of type T has a non-deleted destructor, provides the member constant value equal true. For any other type, value is false. (until C++14)
1) If T is a reference type, provides the member constant value equal true
If T is (possibly cv-qualified) void, a function type, or an array of unknown bound, value equals false. (since C++14)
If T is an object type, then, for the type U equal std::remove_all_extents<T>::type, if the expression std::declval<U&>().~U() is well-formed in unevaluated context, value equals true. Otherwise, value equals false.
2) same as 1), and additionally std::remove_all_extents<T>::type is either a non-class type or a class type with a trivial destructor.
3) same as 1), but the destructor is noexcept.
T shall be a complete type, (possibly cv-qualified) void, or an array of unknown bound. Otherwise, the behavior is undefined.
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 behavior is undefined.
Helper variable templates
template< class T > (since C++17)
inline constexpr bool is_destructible_v = is_destructible<T>::value;
template< class T > (since C++17)
inline constexpr bool is_trivially_destructible_v = is_trivially_destructible<T>::value;
template< class T > (since C++17)
inline constexpr bool is_nothrow_destructible_v = is_nothrow_destructible<T>::value;
Inherited from std::integral_constant
Member constants
value true if T is destructible, false otherwise
[static]
Member functions
operator bool (public member function)
operator() returns value
(C++14)
Member types
Type Definition
value_type bool
type std::integral_constant<bool, value>
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
// Run this code
Output:
See also
is_constructible
is_trivially_constructible
is_nothrow_constructible checks if a type has a constructor for specific arguments
(C++11)
(C++11)
(C++11)
has_virtual_destructor checks if a type has a virtual destructor
(C++11)