unordered_map key_eq() function in C++ STL Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report unordered_map::key_eq() is a built-in function in C++ STL which returns a boolean value according to the comparison. It depends on the key equivalence comparison predicate used by the unordered_map container. The key equivalence comparison is a predicate which takes two arguments and returns a boolean value indicating whether they are to be considered equivalent. It returns true if they are equivalent else it returns false. It is adopted by the container on construction and is similar to the (==) operator used in the comparison. Syntax unordered_map_name.key_eq()(args1, args2) Parameter: The function accepts two mandatory parameters args1 and args2, between whom the comparison is to be done. The data_type is same as that of the unordered_map. Return Value: The function returns a boolean value. Below programs illustrate the unordered_map::key_eq() function. Example 1: CPP // CPP program to illustrate the // unordered_map::key_eq() function #include <bits/stdc++.h> using namespace std; int main() { // Declaring unordered_map unordered_map<string, string> sample; // check details bool answer = sample.key_eq()("GEEKS", "geeks"); // checks if both are same if (answer) cout << "GEEKS and geeks are treated" << " similarly in the container\n"; else cout << "GEEKS and geeks are treated" << " dissimilarly in the container\n"; return 0; } Output: GEEKS and geeks are treated dissimilarly in the container Example 2: CPP // CPP program to illustrate the // unordered_map::key_eq() function #include <bits/stdc++.h> using namespace std; int main() { unordered_map<int, int> sample; bool answer = sample.key_eq()(100, 200); // check if (answer) cout << "100 and 200 are treated " << "similarly in the container\n"; else cout << "100 and 200 are treated" << " dissimilarly in the container\n"; answer = sample.key_eq()(100, 100); if (answer) cout << "100 and 100 are treated " << "similarly in the container\n"; else cout << "100 and 100 are treated " << "dissimilarly in the container\n"; return 0; } Output: 100 and 200 are treated dissimilarly in the container 100 and 100 are treated similarly in the container Comment More infoAdvertise with us Next Article unordered_multimap cend() function in C++ STL A ankit15697 Follow Improve Article Tags : Technical Scripter C++ cpp-unordered_map cpp-unordered_map-functions Practice Tags : CPP Similar Reads unordered_multimap key_eq() function in C++ STL unordered_multimap::key_eq() is a built-in function in C++ STL which returns a boolean value according to the comparison. It depends on the key equivalence comparison predicate used by the unordered_multimap container. The key equivalence comparison is a predicate which takes two arguments and retur 2 min read unordered_set key_eq() function in C++ STL The unordered_set key_eq() is a built-in function in C++ STL which returns a boolean value according to the comparison. It returns the key equivalence comparison predicate used by the unordered_set. The key equivalence comparison is a predicate that takes two arguments and returns a bool value indic 2 min read unordered_map end( ) function in C++ STL The unordered_map::end() is a built-in function in C++ STL which returns an iterator pointing to the position past the last element in the container in the unordered_map container. In an unordered_map object, there is no guarantee that which specific element is considered its first element. But all 3 min read unordered_multimap cend() function in C++ STL The unordered_multimap::cend() is a built-in function in C++ STL which returns a constant iterator pointing to the position after the last element in the container or to the position after the last element in one of its bucket. Syntax: unordered_multimap_name.cend(n) Parameters: The function accepts 2 min read unordered_map emplace_hint() function in C++ STL The unordered_map::emplace_hint() is a built-in function in C++ STL which inserts the key and its element in the unordered_map container with a given hint. It effectively increases the container size by one as unordered_map is the container that stores keys with the element value. The hint provided 2 min read unordered_multimap empty() function in C++ STL The unordered_multimap::empty() is a built-in function in C++ STL which returns a boolean value. It returns true if the unordered_multimap container is empty. Otherwise, it returns false. Syntax: unordered_multimap_name.empty() Parameters: The function does not accept any parameter. Return Value: It 2 min read Like