Namespaces
Variants
Views
Actions

Difference between revisions of "Template:cpp/container/destructor"

From cppreference.com
(+dynarray specific note)
m (Added "triviality" note for `inplace_vector`.)
 
(9 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{cpp/container/{{{1|}}}/title | ~{{{1|}}}}}
+
{{#vardefine:cont|{{{1|inplace_vector}}}}}<!--
{{cpp/container/{{{1|}}}/navbar}}
+
-->{{cpp/container/{{#var:cont}}/title|~{{#var:cont}}}}
{{ddcl | notes={{cpp/container/mark since c++11 | {{{1}}}}} |
+
{{cpp/container/{{#var:cont}}/navbar}}
~{{{1}}}();
+
{{ddcl|since={{cpp/std|{{#var:cont}}}}|notes={{#ifeq:{{#var:cont}}|vector|{{mark constexpr since c++20}}}}|
 +
{{#switch:{{#var:cont}}|inplace_vector=constexpr ~|~}}{{#var:cont}}();
 
}}
 
}}
  
{{cpp/container/if ad|{{{1|}}}
+
A {{lt|cpp/language/destructor}}. {{#switch:{{#var:cont}}|inplace_vector=Also, a {{lsd|cpp/language/destructor#Trivial destructor}} if {{c|std::is_trivially_destructible_v<T>}} is {{c|true}}.}}
|Destructs the container adaptor.
+
<!---->
|Destructs the container.
+
Destructs the {{tt|{{#var:cont}}}}. The destructors of the elements are called and the used storage is deallocated. Note, that if the elements are pointers, the pointed-to objects are not destroyed.
}} The destructors of the elements are called and the used storage is deallocated. Note, that if the elements are pointers, the pointed-to objects are not destroyed.
+
 
+
{{#ifeq:{{{1|}}}|dynarray
+
| The global {{c|operator delete}} is called only if the {{c|operator new}} was called during construction}}
+
  
 
===Complexity===
 
===Complexity===
{{cpp/container/if ad|{{{1|}}}
+
Linear in the size of the {{tt|{{#var:cont}}}}.
|Linear in the size of the container adaptor.
+
|Linear in the size of the container.
+
}}
+

Latest revision as of 03:50, 4 September 2024

 
 
 
 
constexpr ~inplace_vector();
(since C++26)

A destructor. Also, a trivial destructor if std::is_trivially_destructible_v<T> is true. Destructs the inplace_vector. The destructors of the elements are called and the used storage is deallocated. Note, that if the elements are pointers, the pointed-to objects are not destroyed.

[edit] Complexity

Linear in the size of the inplace_vector.