std::optional

Applies to: cpp

std::optional<T> represents either a value of type T or no value, avoiding sentinel values in many APIs.

std::optional<int> id;
if (id) use(*id);

See also: null, return