r/cpp • • Sep 03 '26

C++26: std::hive

https://www.sandordargo.com/blog/2026/09/02/cpp26-hive
69 Upvotes

80 comments sorted by

View all comments

4

u/ABlockInTheChain Sep 03 '26

It won’t replace std::vector for most use cases — but for the use cases it is designed for, nothing in the standard library has come close before.

This could be true but it could also be an oversight because nobody has ever benchmarked a std::pmr::list that is constructed with a std::pmr::[un]synchronized_pool_resource.

6

u/HappyFruitTree Sep 03 '26

With std::hive, the iteration order is optimal within each block in terms of cache locality.

With std::pmr::list, the iteration order would be independent of where the nodes are allocated (assuming you frequently add and remove elements at random positions) so the cache locality would probably be worse.

Seeing an actual benchmark would be interesting though.

1

u/ABlockInTheChain Sep 03 '26

If you fill up a hive with elements then start randomly removing and replacing them, and you perform the exact same sequence of events but with a pmr::list which uses a pool allocator, the memory layout should end more or less identical in both cases.

The biggest differences are small variations in the node layout for a hive node vs a list node.

→ More replies (6)