3 ms·
Semantically though, not having a pointer value and having a value - even null - are two different things. For example, doing pointer arithmetic in the former c
by Koshkin 8y ago
Semantically though, not having a pointer value and having a value - even null - are two different things. For example, doing pointer arithmetic in the former case would be meaningless.
- netheril96 8y agoNull pointer arithmetic is undefined, so just as pointless as arithmetic on an empty optional pointer. Your example fails to prove that optional pointer has any valid use.
- deleted 8y ago[deleted]
- Koshkin 8y agoSure, my point might seem theoretical; to explain further, the difference is that when std::optional pointer is used correctly its behavior in the absence of a value is perfectly defined! Which is a good thing.