Re:The Next Step for Generics
by temac on Tuesday June 16, 2020 @05:21PM
(#23544323)
> Value types in C++ cannot be null
They can just not exist. And C++ being C++, dereferencing an empty std::optional is UB. In practice this particular UB often leads to way worse consequences than more "conventional" null-pointer derefs.
Re:The Next Step for Generics
by gpderetta on Tuesday June 16, 2020 @07:29PM
(#23545620)
Then write your own optional that always checks on dereference or toggle whatever compilation flag enables checking in the standard library you are using.
They can just not exist. And C++ being C++, dereferencing an empty std::optional is UB. In practice this particular UB often leads to way worse consequences than more "conventional" null-pointer derefs.