I came across the following code in a project.
map_erase_if(cfgIp.m_raw, RawCreate());
I understand that this will call the function defined by () inside the structure.
The Rawcreate is a structure which is given below .
struct RawCreate {
bool operator()(const Device::StoreElm& el) {
Pcap* pcap = NULL;
pcap = Pcap::findServer(el.second->name());
if (!pcap) {
try {
MEM_NEW(pcap,Pcap(*el.second));
} catch (Exception& ex) {
MAND_LOG(DBG_SIPTCP, "Error:%s", ex.what());
}
}
for (RejItr itr = CfgIp::m_rejectList.begin(); itr != CfgIp::m_rejectList.end(); ++itr) {
if(ip_equal(itr->first, pcap->getInterface(), false) && !itr->second.empty()) {
pcap->blockReg();
}
}
if (pcap) {
MEM_DELETE(el.second);
return true;
}
return false;
}
};
I have seen operator overloading with class objects.I know class and structure has only few differences in cpp.But using overloading within a structure in this way is a new thing for me.Can any one clarify its usage?