C++ Language/Std/Stl/CollectionClasses/SortedCollections/Map/SortClass

From Wikibooks, open books for an open world
Jump to navigation Jump to search

The ordering of items does not matter in a map-literal. What does matter is the "sort-class" template-parameter (the default is std::less<> if omitted). The sort-class determines the actual item-ordering within STL's internal representation (by ordering their keys). When iterators use ++ and --, they follow that sort-class order (not the map-literal's apparent order).

Additional information about specifying a sort-class (includes interactive examples)