value_compare::operator() function

The map value_compare::operator() compares the keys of the two pair element and returns a bool value accordingly.

bool operator( ) (const value_type& x, const value_type& y) const;

value_type -A pair type element.

Note the value_compare is a class member of the map container.

x -A first pair element.

y -A second pair element.

Return type
bool -True if the key of the first pair element is smaller than the second pair element.

Code example

map<int,string>mp ;

map<int,string>::value_compare valc=mp.value_comp( ) ;

pair<int,string> pr{23 , “23” } , pr1{45 , “455” };

cout<< valc( pr,pr1 ); //calls the operator( ) function




Stop wasting time,earn money($$$) from your website-Join Now!