r/cpp • u/User_Deprecated • Aug 02 '26
How fast is C++26's std::hive?
https://lemire.me/blog/2026/08/02/how-fast-is-c26s-stdhive/
255
Upvotes
r/cpp • u/User_Deprecated • Aug 02 '26
View all comments
Show parent comment
37
u/bartgrumbel Aug 03 '26
Two big plusses: first it is reference stable, whereas vector.push_back invalidates all existing pointers and references to vector members, which is the cause for a lot of memory safety bugs.
Second, the maximum runtime per insertion is more stable. A vector‘s push_back can be O(size) it if reallocates.
The third of the two advantages is that it works well with objects that cannot be moved or copied after construction.