If all you care about is a timestamp and the other attributes just don't matter, you can use the following, which is a strict weak order. You will never know in what order the objects of the same timestamp will appear:
bool operator< (const KeyT& key) const
{
return timestamp < key.timestamp;
}
If you need to order all the attributes, I suggest boost::tie:
bool operator< (const KeyT& key) const
{
return boost::tie(timestamp, a, b, c, d, e) < boost::tie(key.timestamp, key.a, key.b, key.c, key.d, e.key);
}
source
share