So similarly to my previous question, I wanted to store a few attributes as a key for my map and the value will also be a different struct.
I now have a map like so:
std::map<SKey, SValue> m_mMap;
SKey has the following structure:
Struct SKey
{
string str1,
string str2,
unsigned long long ull1
};
I want to implement the quickest way to retrieve an iterator of a match to all these variables. So something like this:
std::map<SKey, SValue>::iterator iter = m_mMap.find(m_sKey);
What I have so far to check if there is a match in the map and to retrieve the iterator is the following:
inline bool operator<(const SKey& lhs, const SKey& rhs)
{
return std::tie(lhs.strSrcAddr, lhs.strDstAddr, lhs.ullSequenceNo) < std::tie(rhs.strSrcAddr, rhs.strDstAddr, rhs.ullSeqNo);
}
Is this the correct way to find a match of an SKey object? Or is there a quicker way? I've tested this but i'm not entirely convinced it works because it seems to return false when the left side and the right side are the same. What am i doing wrong? Any help or advice would be appreciated and if there is a quicker way of doing this i'd appreciate it because my program is very concentrated on performance.
Thanks