4 ms·
> 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 ofte
by temac 6y ago
> 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.
- gpderetta 6y agoThen write your own optional that always checks on dereference or toggle whatever compilation flag enables checking in the standard library you are using.