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

Show parent comment

2

u/HappyFruitTree Sep 04 '26

Finding next used slot should need just a single LZCNT, no loop, and would maintain the iteration of a block to be O(1).

What if there are more than 64 empty slots between the current element and the next?

4

u/Tringi github.com/tringi Sep 04 '26

Yeah, that would be significantly slower. Theoretically. Practically I'd guess that any attempt to measure real difference between 3 instructions and this 10 or so instruction loop (likely unrolled) would be completely obliterated by cache access latency and such.