Difference between revisions of "cpp/named req/Destructible"
From cppreference.com
m (T. Canens moved page cpp/concept/Destructible to cpp/named req/Destructible without leaving a redirect: Text replace - "cpp/concept" to "cpp/named req") |
(named req/core) |
||
Line 6: | Line 6: | ||
===Requirements=== | ===Requirements=== | ||
− | The type {{tt|T}} satisfies {{ | + | The type {{tt|T}} satisfies {{named req/core|Destructible}} if |
Given | Given | ||
Line 24: | Line 24: | ||
Destructors are called implicitly at the end of [[cpp/language/lifetime|object lifetime]] such as when leaving [[cpp/language/scope|scope]] or by the [[cpp/language/delete|delete-expression]]. Explicit destructor call as shown in the type requirement table is rare. | Destructors are called implicitly at the end of [[cpp/language/lifetime|object lifetime]] such as when leaving [[cpp/language/scope|scope]] or by the [[cpp/language/delete|delete-expression]]. Explicit destructor call as shown in the type requirement table is rare. | ||
− | Thanks to [[cpp/language/operator_member_access#Built-in_member_access_operators|pseudo destructor call]], all scalar types meet the requirement of {{ | + | Thanks to [[cpp/language/operator_member_access#Built-in_member_access_operators|pseudo destructor call]], all scalar types meet the requirement of {{named req/core|Destructible}}, while array types and reference types do not. Note that {{lc|std::is_destructible}} allows arrays and reference types. |
===See also=== | ===See also=== | ||
Line 31: | Line 31: | ||
{{dsc end}} | {{dsc end}} | ||
− | + | {{langlinks|de|es|fr|it|ja|pt|ru|zh}} | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + |
Revision as of 00:45, 17 June 2018
Specifies that an instance of the type can be destructed.
Requirements
The type T
satisfies Destructible if
Given
-
u
, a expression of typeT
The following expressions must be valid and have their specified effects
Expression | Post-conditions |
---|---|
u.~T() | All resources owned by u are reclaimed, no exceptions are thrown.
|
Notes
Destructors are called implicitly at the end of object lifetime such as when leaving scope or by the delete-expression. Explicit destructor call as shown in the type requirement table is rare.
Thanks to pseudo destructor call, all scalar types meet the requirement of Destructible, while array types and reference types do not. Note that std::is_destructible allows arrays and reference types.
See also
(C++11)(C++11)(C++11) |
checks if a type has a non-deleted destructor (class template) |