Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Providing an invalid ordering rule for an associative container or as a comparison criterion with the sorting algorithms can result in erratic behavior or infinite loops. (See Meyers01 §21 for examples.)

Non-Compliant Code Example

...

Wiki Markup
To store pointers in a proper order, you should use the {{DereferenceLess}} template, as described in 
\[[Meyers 01|AA. References#MeyersBibliography#Meyers 01]\] Item 20:

Code Block
bgColor#ccccff
struct DereferenceLess {
  template <typename PtrType>
  bool operator()(PtrType pl1, PtrType pl2) const {
    return *pl1 < *pl2;
  }
};

...

Wiki Markup
\[[Meyers 01|AA. References#MeyersBibliography#Meyers 01]\] Item 21: Always have comparison functions return false for equal values.
\[[Sutter 05|AA. References#SutterBibliography#Sutter 05]\] Item 83: Use a checked STL implementation.
\[[ISO/IEC 14882-2003|AA. References#ISOBibliography#ISO/IEC 14882-2003]\] Section 24: Iterators Library.

...