std::expected::~expected(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– NAME πŸ’–

std::expected::~expected β€” bestie, it's literally the destructor for std::expected, and yes the name is a whole mood: std::expected::~expected πŸŽ€


🌸 SYNOPSIS 🌸

constexpr ~expected();  (since C++23)

Ok so this is the cleanup girlie, and she's been around since C++23 ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

So what does this destructor actually do? It destroys the currently contained value. That's the whole vibe. But which value? Depends on what's inside, bestie:

  • If has_value() is false, it destroys the unexpected value 🫢
  • Otherwise, if T is not (possibly cv-qualified) void, it destroys the expected value πŸ’…

No cap, that's it. It's giving "know what you're holding and clean it up accordingly."

✨ when is this destructor trivial? ✨

This destructor is trivial if both of these are true:

  • either T is (possibly cv-qualified) void, or std::is_trivially_destructible_v<T> is true, and
  • std::is_trivially_destructible_v<E> is true πŸ”₯

Read that carefully, bestie β€” it's an "either/or" situation for T, and then an "and" for E. The way that trivial-destructor condition is structured? Iconic. Don't fumble it πŸ™ˆ


πŸ’€ EXAMPLE πŸ’€

This section is incomplete. Reason: no example.

Yeah… no example yet 😭 It literally says "no example." We're not gonna invent one, that would be a whole lie. Category says it all:

  • Todo no example

🧚 CATEGORY 🧚

  • Todo no example

and that's the whole page, bestie ✨ This little gem came from http://cppreference.com, dated 2024.06.10, and it's filed under std::expected::~expected(3). Go forth and destruct responsibly πŸ’–πŸ¦‹

πŸ“¦ where this page comes from