Paul Dovydaitis
We are using a multi index container to store some data indexed both by a text key and by a timestamp. [...] To do this, we tried to overload operator< in the following way: bool MyTransaction::operator<(const Transaction & rhs) const { const std::time_t WINDOW = 2; if (getHashKey() == rhs.getHashKey()) { if ((epochTime() - WINDOW) <= rhs.epochTime() && (epochTime() + WINDOW) >= rhs.epochTime()) { return false; } else { return (epochTime() < rhs.epochTime()); } } else { return (getHashKey() < rhs.getHashKey()); } }
This less-than operator is ill-defined according to the semantics
expected by Boost.MultiIndex indexed indices (as well as STL
associative containers and a number of stdlib algorithms).
In particular the operator must implement a strict weak ordering:
http://cpp-next.com/archive/2010/02/order-i-say/
Among other, a strict weak ordering has the property that
"equivalence" defined as x~y := !(x