The map::key_comp() is a function in STL in C++ that returns a copy of comparison object used by container that compare keys.
Return value: This method returns the comparison object used by container that compare keys.
Below examples illustrate the working of key_comp() method:
mymap contain: x => 50 y => 100 z => 150
mymap contain: a => 100 b => 200 c => 300
GeeksforGeeks has prepared a complete interview preparation course with premium videos, theory, practice problems, TA support and many more features. Please refer Placement 100 for details
- Function Overloading vs Function Overriding in C++
- How to call some function before main() function in C++?
- Python - Call function from another function
- How to get the function name inside a function in PHP ?
- How to call function within function in C or C++
- Difference between Virtual function and Pure virtual function in C++
- What happens when a virtual function is called inside a non-virtual function in C++
- fma() function in C++
- exp() function C++
- log() function in C++
- div() function in C++
- max() function for valarray in C++
- map rbegin() function in C++ STL
- map rend() function in C++ STL
- valarray abs() function in C++
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.