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/unchangeableusername Aug 27 '26
I feel like this ought to be the case but this godbolt example shows that it's not quite the same.
I'd argue that the
unchecked_*functions are useful when the next value youpush_backis dependent on the previous values (and can guarantee size never exceeds capacity). Recording states when traversing a DFA is the first example I can think of, although I don't how common doing stuff like this is. But I did find a 7% performance improvement for this specific use case when using a hackyunchecked_push_backequivalent forstd::vectorover the regularpush_back(reservewas called beforehand in both situations).