std::optional::~optional(3)
π std::optional::~optional(3) π
okay bestie, this is the std::optional::~optional(3) page from the C++ Standard Libary manual β yes, that's the manual name right there, folded in at the top like a lil name tag π«Ά.
π NAME π
std::optional::~optional β the manual's description is literally just std::optional::~optional again, so it's giving "I am my own summary" energy π
.
β¨ Synopsis β¨
Here's the signature, exactly, no edits:
~optional(); (since C++17)
(constexpr since C++20)
That's the whole synopsis, and the since C++17 / constexpr since C++20 notes are right there in it β keep those eras in mind π.
π Notes π
If the object contains a value and the type T is not trivially destructible (see std::is_trivially_destructible), it destroys the contained value by calling its destructor, as if by value().T::~T().
Otherwise, it does nothing. literally nothing, iconically π.
If T is trivially-destructible, then this destructor is also trivial, so std::optional<T> is also trivially-destructible. slay β¨.
π«Ά Defect reports π«Ά
The following behavior-changing defect reports were applied retroactively to previously published C++ standards:
- DR:
P2231R1- Applied to:
C++20 - Behavior as published: the destructor was not
constexprwhile non-trivial destructors can beconstexprin C++20 - Correct behavior: made
constexpr
- Applied to:
periodt, that's the whole receipt π .
and that's the page! source/version: http://cppreference.com Β· date: 2024.06.10 β byeee, drink water and stan trivial destructors responsibly ππΈ
π¦ 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