GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::is_destructible,std::is_trivially_destructible,std::is_nothrow_destructible(3) C++ Standard Libary std::is_destructible,std::is_trivially_destructible,std::is_nothrow_destructible(3)

std::is_destructible,std::is_trivially_destructible,std::is_nothrow_destructible - std::is_destructible,std::is_trivially_destructible,std::is_nothrow_destructible


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 T is a reference type, provides the member constant value equal to true.


If T is (possibly cv-qualified) void, a function type, or an array of unknown bound,
value equals false.


If T is an object type, then, for the type U equal to
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.


The behavior of a program that adds specializations for any of the templates
described on this page is undefined.


Helper variable templates


template< class T > (since C++17)
inline constexpr bool is_destructible_v = is_destructible<T>::value;
template< class T >
inline constexpr bool is_trivially_destructible_v = (since C++17)
is_trivially_destructible<T>::value;
template< class T >
inline constexpr bool is_nothrow_destructible_v = (since C++17)
is_nothrow_destructible<T>::value;

Inherited from std::integral_constant


value true if T is destructible, false otherwise
[static] (public static member constant)


operator bool converts the object to bool, returns value
(public member function)
operator() returns value
(C++14) (public member function)


Type Definition
value_type bool
type std::integral_constant<bool, value>


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.

// Run this code


#include <iostream>
#include <string>
#include <type_traits>
struct Foo {
std::string str;
~Foo() noexcept {};
};
struct Bar {
~Bar() = default;
};
int main() {
std::cout << std::boolalpha
<< "std::string is destructible? "
<< std::is_destructible<std::string>::value << '\n'
<< "Foo is trivially destructible? "
<< std::is_trivially_destructible_v<Foo> << '\n'
<< "Foo is nothrow destructible? "
<< std::is_nothrow_destructible<Foo>() << '\n'
<< "Bar is trivially destructible? "
<< std::is_trivially_destructible<Bar>{} << '\n';
}


std::string is destructible? true
Foo is trivially destructible? false
Foo is nothrow destructible? true
Bar is trivially destructible? true


Defect reports


The following behavior-changing defect reports were applied retroactively to
previously published C++ standards.


DR Applied to Behavior as published Correct behavior
LWG 2049 C++11 the specification was incompletable because of made complete
the imaginary wrapping struct


is_constructible
is_trivially_constructible
is_nothrow_constructible checks if a type has a constructor for specific arguments
(C++11) (class template)
(C++11)
(C++11)
has_virtual_destructor checks if a type has a virtual destructor
(C++11) (class template)
destructible specifies that an object of the type can be destroyed
(C++20) (concept)
destructor releases claimed resources

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.