##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# 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.

### [edit] Parameters

(none)

### [edit] Return value

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

### [edit] Exceptions

`noexcept` specification:
noexcept
Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/utility/optional/operator_bool&oldid=91711"
Category:

- unconditionally noexcept

Hidden categories:

- Pages with unreviewed unconditional noexcept template
- Pages with unreviewed noexcept template