std::optional<T>::operator bool, std::optional<T>::has_value_C++中文网

constexpr explicit operator bool() const noexcept;

(C++17 起)

constexpr bool has_value() const noexcept;

(C++17 起)

检查 *this 是否含值。

参数

(无)

返回值

*this 含值则为 true ,若 *this 不含值则 false