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
3
u/tialaramex Aug 28 '26
Of course if you
v.clear()in those examples, ensuring the compiler knows how big v is, the optimiser gives the same result for both cases.Your traverse a DFA example sounds plausible because the optimiser probably can't see why it can elide the capacity check, but I'd be very sceptical without seeing a full working system that you can win 7% perf.
If you're correct about 7% perf then
unchecked_push_backmakes sense - a lot of things are worth doing for 7% perf