Skip to content

Search topics & cppreference

Search all study topics, concept maps, and 6,587 C++ and C reference pages.

std::expected<T,E>::~expected

Destroys the contained value:

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

Main template destructor

Destroys the contained value:

  • If has_value() is true, destroys the expected value.
  • Otherwise, destroys the unexpected value.

This destructor is trivial if std::is_trivially_destructible_v<T> and std::is_trivially_destructible_v<E> are both true.

void partial specialization destructor

If has_value() is false, destroys the unexpected value.

This destructor is trivial if std::is_trivially_destructible_v<E> is true.

Example

This section is incomplete
Reason: no example

Content from this page on cppreference.com, licensed under CC-BY-SA 3.0 and GFDL. Modified: restyled, site navigation removed, code windows added. Offline snapshot of 9 February 2025.