std::expected<T,E>::operator bool, std::expected<T,E>::has_value

Checks whether *this represents an expected value.

# Declarations

constexpr explicit operator bool() const noexcept;

(since C++23)

constexpr bool has_value() const noexcept;

(since C++23)

# Return value

Returns true if the object currently contains an expected value and false otherwise.

# Notes

A std::expected object is never valueless. If has_value() returns true, operator*() can be used to access the expected value; otherwise, error() can be used to access the unexpected value.

# See also