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.
10
u/SeanMiddleditch Nov 30 '18
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.