std::vector::~vector(3)
π std::vector::~vector π
okay bestie, welcome to the destructor page from the C++ Standard Libary manual, section 3 β and yes, "Libary" is literally how it's spelled in the header, iykyk, we are not coming for the typo, we are respecting the typo π«Ά. This is the goodbye page. The "your lifetime is up, queen" page π
β¨
πΈ NAME πΈ
std::vector::~vector β it's giving destructor. Specifically, the destructor of std::vector. No cap.
β¨ Synopsis β¨
~vector(); (constexpr since C++20)
so since C++20 this thing is constexpr, which is lowkey iconic of it π.
π Description π
okay so picture this: the vector has served its purpose, the main character energy has faded, and now it's time to clean up. Destructs the vector. That's the whole gig π.
The destructors of the elements are called and the used storage is deallocated. Like, every single element gets its own little farewell moment, and then the memory the vector was using gets handed back. Very "everybody say bye" π¦.
β οΈ but bestie, listen β if the elements are pointers, the pointed-to objects are not destroyed. the vector is not gonna chase down every pointer and delete what it points to for you. that is not the vibe. that is your job. don't @ me π
π§ Complexity π§
Linear in the size of the vector. so it's O(n), it walks the whole squad, no shortcuts, no magic. big vector = longer goodbye. that's just how it is π.
and that's the page! source is http://cppreference.com, dated 2024.06.10, and the whole thing is std::vector::~vector(3) β destructor out, bestie, stay slay π
β¨π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms