std::map:
1std::map<int, std::string> m;2m[3] = "three";3m[1] = "one";4// Iteration: 1, 3 (sorted)
std::unordered_map:
1std::unordered_map<int, std::string> um;2um[3] = "three";3um[1] = "one";4// Iteration order: unknown
When to use:
map: ordered iteration, range queriesunordered_map: fast lookup, no ordering needed