对码当歌,猿生几何?

std::optional::operator bool, std::optional::has_value

From cppreference.com
< cpp‎ | utility‎ | optional
 
 
 
 
constexpr explicit operator bool() const;
(since C++17)
constexpr bool has_value() const;
(since C++17)

Checks whether *this contains a value.

Parameters

(none)

Return value

true if *this contains a value, false if *this does not contain a value.

Exceptions

noexcept specification:  
noexcept