|
|
|
|
|
by witcher_rat
1466 days ago
|
|
> being able to create pointer to objects inside the map (I never did that, but do other people really do that?) Yes, we do it at my day job in several places, where we take advantage of the pointer stability to improve our overall performance a lot. And a much more impactful performance improvement for our overall product, than micro-optimizations of the unordered_map's insert/erase times would achieve. Think of, for example, multi-index containers. Or an ordered hash-map (one that is both a hash map and keeps insertion ordering). In such cases you can keep the actual objects in an unordered_map, and only store pointers to the nodes in other containers (e.g., vectors). Obviously you can achieve the same thing with open-addressing hashmaps, by making the map's nodes unique_ptrs (i.e., creating the actual objects on the heap externally), which is what such hashmaps tell you to do if you need pointer stability. But you asked if anyone really used pointer stability, hence my answer. |
|