Use std::optional
rather than sentinel values
#2964
Merged
std::optional
rather than sentinel values
#2964