If we use a structure or a class as a key then a comparison function is required to place the values in the tree but if a pair is used as a key then how the map data structure place the values in the tree. I.e. there has to be something to compare the keys and store them in to a tree.
Asked
Active
Viewed 584 times
1 Answers
7
The default comparison function for std::map
is std::less
using the Key type for the arguments. std::less
just calls the <
operator on its arguments, which is defined for std::pair
(it compares first
and second
lexicographically, using their operator<
).

Matteo Italia
- 123,740
- 17
- 206
- 299

tweej
- 832
- 4
- 16
-
Thanks was lookin for this explanation. – Rajat Sati Jul 18 '17 at 15:28