Provide a strict weak ordering for DelegateMementos.
| 594 | #endif |
| 595 | // Provide a strict weak ordering for DelegateMementos. |
| 596 | inline bool IsLess(const DelegateMemento &right) const { |
| 597 | // deal with static function pointers first |
| 598 | #if !defined(FASTDELEGATE_USESTATICFUNCTIONHACK) |
| 599 | if (m_pStaticFunction !=0 || right.m_pStaticFunction!=0) |
| 600 | return m_pStaticFunction < right.m_pStaticFunction; |
| 601 | #endif |
| 602 | if (m_pthis !=right.m_pthis) return m_pthis < right.m_pthis; |
| 603 | // There are no ordering operators for member function pointers, |
| 604 | // but we can fake one by comparing each byte. The resulting ordering is |
| 605 | // arbitrary (and compiler-dependent), but it permits storage in ordered STL containers. |
| 606 | return dMemcmp(&m_pFunction, &right.m_pFunction, sizeof(m_pFunction)) < 0; |
| 607 | |
| 608 | } |
| 609 | // BUGFIX (Mar 2005): |
| 610 | // We can't just compare m_pFunction because on Metrowerks, |
| 611 | // m_pFunction can be zero even if the delegate is not empty! |