
- C++ Library - Home
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- The C++ STL Library
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- The C++ Advanced Library
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ Library -
- C++ STL Library Cheat Sheet
- C++ STL - Cheat Sheet
- C++ Programming Resources
- C++ Programming Tutorial
- C++ Useful Resources
- C++ Discussion
C++ multimap::value_comp() Function
The C++ std::multimap::value_comp() function is a comparator that is used to return a comparison object that compare the elements stored in the multimap. This function helps to determine the order of the elements by comparing pairs using the multimap sorting criterion, which is defined by its comparison function. The time complexity of this function is constant i.e. O(1).
Syntax
Following is the syntax for std::multimap::value_comp() function.
value_compare value_comp() const;
Parameters
It does not accept any parameter.
Return value
This function returns a comparison object for element values.
Example
Let's look at the following example, where we are going to demonstrate the usage of value_comp() function.
#include#include
Output
Following is the output of the above code −
Comparing First Two Elements: False
Example
Consider the following example, where we are going to use the value_comp() to sort the elements of multimap.
#include#include
Output
Output of the above code is as follows −
{1, Audi} {2, Ciaz} {3, Sail} {3, Verna}
Example
In the following example, we are going to use the value_comp() to find the minimum and maximum elements in multimap.
#include#include
Output
If we run the above code it will generate the following output −
Min Element: {1, 1} Max Element: {3, 4444}