Is there really no guaranteed order in an unordered_map? I ask this because I would like to specify an order for an unorderded_map, so that it is possible to iterate the container from begin() to end() according to the specified order (while preserving the efficiency of an hashed access to single elements, globally speaking).
Is there really no guaranteed order in an unordered_map? I ask this because I
Share
You know, it has its name for a reason…
To actually give it an order, you’d need to implement your own hash that somehow gives you the wanted order.
Now, for a solution to your actual problem, you can just create a
std::mapfrom yourstd::unordered_map, and even with minimal overhead for the insert (no copies):