r/cpp 6d ago

C++26: std::inplace_vector

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

121 comments sorted by

View all comments

13

u/bartgrumbel 6d ago

I am sure there is a good reason for that, but why is the "optional reference" not simply a pointer? Is that not semantically the same thing, but way easier to deal with.

I.e. why

std::optional<T&>

and not simply

T*

-17

u/carrottread 6d ago

Probably just a desire to use new shiny stuff as optional references were not so long ago added to standard.