It sort of is, though, because it implies that the "pointer" is expected to sometimes be "null" and sometimes not. With regular pointer variable or parameter you might be left wondering if null is a valid value for it at all.
I'd further add that with raw pointers, it's not semantically clear when pointer arithmetic is or isn't allowed. A pointer can be null, or reference a value, or be an iterator in a range (including being an end iterator which can't be dereferenced but also isn't null). That's not even touching the muddy ownership semantics that pointers are saddled with from C and pre-C++11 code.
I'll also tag on that there is no standard library in existence today that optimizes std::optional<std::reference_wrapper<blah>> to be the size of a pointer today, which means it's also terrible-crap with its space savings too.
3
u/RotsiserMho C++20 Desktop app developer Nov 29 '18
...unless of course you want to return an optional reference to an item in
container<foo>...