I have defined a unordered map object as follows. Here ndmInst is a user defined class. slmEndpointsTimingInfo is also a user defined class. I have also shown how I am inserting it into it and the comparator function. However I am getting error during compiling this code as shown at bottom. Can you give me some idea how to resolve this build error? Code lines mentioned in the error are shown as comment in the code block.
std::unordered_map<std::pair<ndmInst*, bool>, std::vector<slmEndpointsTimingInfo>, cmpClkgate> clkgateEndpointsMap;
slmEndpointsTimingInfo endpointsInfoObj;
std::pair<ndmInst*, bool> p = std::make_pair(clkFaninInsts[0], isFallEdgeClk);
clkgateEndpointsMap[p].push_back(endpointsInfoObj); //slmPMUEPAsgnStrgy.cc:125
class cmpClkgate {
public:
bool operator()(const std::pair<ndmInst*, bool>& p1, const std::pair<ndmInst*, bool>& p2) const { // this slmPMUEPAsgnStrgy.cc:81
if (p1.first != p2.first) {
return p1.first < p2.first;
}
return p1.second < p2.second;
}
};
/depotbld/RHEL7.0/gcc-9.5.0/include/c++/9.5.0/bits/hashtable_policy.h: In instantiation of ‘std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, std::__detail::_Default_ranged_hash, true>::__hash_code std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, std::__detail::_Default_ranged_hash, true>::_M_hash_code(const _Key&) const [with _Key = std::pair<ndmInst*, bool>; _Value = std::pair<const std::pair<ndmInst*, bool>, std::vector<dc::slmEndpointsTimingInfo> >; _ExtractKey = std::__detail::_Select1st; _H1 = dc::cmpClkgate; _H2 = std::__detail::_Mod_range_hashing; std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _H1, _H2, std::__detail::_Default_ranged_hash, true>::__hash_code = long unsigned int]’:
/depotbld/RHEL7.0/gcc-9.5.0/include/c++/9.5.0/bits/hashtable_policy.h:695:19: required from ‘std::__detail::_Map_base<_Key, _Pair, _Alloc, std::__detail::_Select1st, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits, true>::mapped_type& std::__detail::_Map_base<_Key, _Pair, _Alloc, std::__detail::_Select1st, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits, true>::operator[](const key_type&) [with _Key = std::pair<ndmInst*, bool>; _Pair = std::pair<const std::pair<ndmInst*, bool>, std::vector<dc::slmEndpointsTimingInfo> >; _Alloc = std::allocator<std::pair<const std::pair<ndmInst*, bool>, std::vector<dc::slmEndpointsTimingInfo> > >; _Equal = std::equal_to<std::pair<ndmInst*, bool> >; _H1 = dc::cmpClkgate; _H2 = std::__detail::_Mod_range_hashing; _Hash = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>; std::__detail::_Map_base<_Key, _Pair, _Alloc, std::__detail::_Select1st, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits, true>::mapped_type = std::vector<dc::slmEndpointsTimingInfo>; std::__detail::_Map_base<_Key, _Pair, _Alloc, std::__detail::_Select1st, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits, true>::key_type = std::pair<ndmInst*, bool>]’
/depotbld/RHEL7.0/gcc-9.5.0/include/c++/9.5.0/bits/unordered_map.h:986:20: required from ‘std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type& std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::operator[](const key_type&) [with _Key = std::pair<ndmInst*, bool>; _Tp = std::vector<dc::slmEndpointsTimingInfo>; _Hash = dc::cmpClkgate; _Pred = std::equal_to<std::pair<ndmInst*, bool> >; _Alloc = std::allocator<std::pair<const std::pair<ndmInst*, bool>, std::vector<dc::slmEndpointsTimingInfo> > >; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::mapped_type = std::vector<dc::slmEndpointsTimingInfo>; std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::key_type = std::pair<ndmInst*, bool>]’
slmPMUEPAsgnStrgy.cc:125:28: required from here
/depotbld/RHEL7.0/gcc-9.5.0/include/c++/9.5.0/bits/hashtable_policy.h:1382:16: error: static assertion failed: hash function must be invocable with an argument of key type
1382 | static_assert(__is_invocable<const _H1&, const _Key&>{},
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/depotbld/RHEL7.0/gcc-9.5.0/include/c++/9.5.0/bits/hashtable_policy.h:1384:16: error: no match for call to ‘(const dc::cmpClkgate) (const std::pair<ndmInst*, bool>&)’
1384 | return _M_h1()(__k);
| ~~~~~~~^~~~~
slmPMUEPAsgnStrgy.cc:81:8: note: candidate: ‘bool dc::cmpClkgate::operator()(const std::pair<ndmInst*, bool>&, const std::pair<ndmInst*, bool>&) const’
81 | bool operator()(const std::pair<ndmInst*, bool>& p1, const std::pair<ndmInst*, bool>& p2) const {
| ^~~~~~~~
slmPMUEPAsgnStrgy.cc:81:8: note: candidate expects 2 arguments, 1 provided
I could not find any answer in google search to resolve this build error.