r/cpp • • Aug 26 '26

C++26: std::inplace_vector

https://www.sandordargo.com/blog/2026/08/26/cpp26-inplace-vector
181 Upvotes

121 comments sorted by

View all comments

Show parent comment

2

u/Raknarg Sep 01 '26

I am sure there is a good reason for that, but why is the "optional reference" not simply a pointer?

Its not semantically the same, that's actually the reason we care about optional references at all. They are functionally the same in the sense that mechanically a pointer can fulfill all the requirements of an optional reference, but an optional reference gives you very clear ideas on the ownership and purpose of the type, while a pointer does not. A pointer can mean a whole bunch of different stuff and you have to rely on context and documentation to figure out what it means.