Skip to content

Glossary: Coding Interviews in C++

std::optional

Also written: optional, std::nullopt, nullopt

C++'s "maybe a value": it holds a value or is empty (`std::nullopt`). Test it in an `if` and read it with `*` or `->`.

Where the book teaches it

Related terms

Pointer