multiset key_comp() function in C++ STL
The std::multiset::key_comp() is an inbuilt function in C++ STL which returns a copy of the comparison object used by the container. By default, this is a less object, which returns the same as operator ‘<'.It is a function pointer or a function object which takes two arguments of the same type as the container elements and returns true if the first argument is considered to go before the second in the strict weak ordering it defines or false otherwise. Two keys are considered equivalent if key_comp returns false reflexively (i.e., no matter the order in which the keys are passed as arguments).
Parameter: This function does not accept any parameter.
Return Values: The function returns a copy of the comparison object used by the container.
Below examples illustrate the multiset::key_comp() method:
Example 1 :
Multiset has the elements 10 20 30 40
Example 2 :
Multiset has the elements 100 200 300 400