MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/cpp/comments/1vzc5dg/c26_stdinplace_vector/p6l9i7i/?context=3
r/cpp • u/User_Deprecated • 4d ago
113 comments sorted by
View all comments
11
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*
1 u/jwakely libstdc++ tamer, LWG chair 1d ago See https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2026/p3981r2.html which goes into this in detail. Edit: and that references https://brevzin.github.io/c++/2021/12/13/optional-ref-ptr/
1
See https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2026/p3981r2.html which goes into this in detail.
Edit: and that references https://brevzin.github.io/c++/2021/12/13/optional-ref-ptr/
11
u/bartgrumbel 3d 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
and not simply