Possible Duplicate:
Implementing comparision operators via 'tuple' and 'tie', a good idea?
sometimes I need to write some ugly functors
e.g.
lhs.date_ < rhs.date_ ||
lhs.date_ == rhs.date_ && lhs.time_ < rhs.time_ ||
lhs.date_ == rhs.date_ && lhs.time_ == rhs.time_ && lhs.id_ < rhs.id_ .....
it really annoyed me.
So I started avoiding that writing following:
std::make_tuple( lhs.date_, lhs.time_, lhs.id_ ) <
std::make_tuple(rhs.date_, rhs.time_, rhs.id_ );
and I am almost happy, but mind that I'm probably using tuples not by their purpose makes me worry.
Could you criticize this solution?
Or it's a good practice?
How do you avoid such comparisons?
UPDATE:
Thanks for pointing on std::tie to avoid copying objects.
And thanks for pointing on duplicate question