Namespaces
Variants
Views
Actions

C++ named requirements: Destructible

From cppreference.com
< cpp‎ | named req
 
 
C++ named requirements
Basic
Destructible
Type properties
Library-Wide
Container
Container Elements
(C++11)

Iterator
Stream I/O
Formatters
(C++20)
Random Numbers
(C++11)    
Concurrency
(C++11)
(C++11)
Ranges
Other
(C++11)


 

Specifies that an instance of the type can be destructed.

[edit] Requirements

The type T satisfies Destructible if

Given

  • u, an expression of type T.

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.

[edit] 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.

[edit] See also

checks if a type has a non-deleted destructor
(class template) [edit]
specifies that an object of the type can be destroyed
(concept) [edit]