r/cpp • u/User_Deprecated • Aug 26 '26
C++26: std::inplace_vector
https://www.sandordargo.com/blog/2026/08/26/cpp26-inplace-vector
181
Upvotes
r/cpp • u/User_Deprecated • Aug 26 '26
View all comments
Show parent comment
6
u/simonask_ Aug 27 '26
If we’re maximizing rustiness, you could let `try_push` return `Result<&mut T, T>`.
A mutable reference to the location of the just appended element, or the element you tried to push by value if it fails. There are a couple of APIs like this in the standard library.