I asked this before but never really got an answer. So I will try again
I have a std::vector that I search using lower_bound(). To do this I have a struct with a () operator like so:
LMABREP struct looks like:Code:struct LM_LESS { bool operator () (const LMABREP& lhs , const LMABREP& rhs) { if (lhs.sLID.size() != rhs.sLID.size()) return lhs.sLID.size() > rhs.sLID.size(); return lhs.sLID < rhs.sLID; } };
So basically sLID contains a number and I am looking for it using lower_bound(). The reason being is there is a possible repeat.Code:struct LMABREP { string sLID; string sStreetNumber; string sStreet; string sStreetSufix; string sStreetPrefix; };
My question is can I turn my operator () into a template because I use functions like this a lot with many different vectors with many different structs. I really dont want to have to write a new () every time I use a different struct.




Reply With Quote