Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

...

because the integers are stored in pointer order, which happens to be the order in which they are stored in the array.

Compliant Solution

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

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

...

This rule appears in the Java Secure Coding Standard as MET10-J. Follow the general contract when implementing the compareTo() method.

Bibliography

...

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

...

ARR39-CPP. Do not treat arrays polymorphically      06. Arrays and the STL (ARR)      ARR41-CPP. A container's allocator should never have a data field that is not static