...
because the integers are stored in pointer order, which happens to be the order in which they are stored in the array.
Compliant Solution
To store pointers in a proper order, you should use the {{ Wiki Markup DereferenceLess
}} template, as described in
\
[[Meyers 01|AA. Bibliography#Meyers 01]\] Item 20:
Code Block | ||||
---|---|---|---|---|
| ||||
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