Versions Compared

Key

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

...

Code Block
typedef set<int, less<int> > IntSetLess;

IntSetLess::const_iterator islIter;
IntSetLess isl;

isl.insert(5);
isl.insert(10);
isl.insert(20);

pair<IntSetLess::const_iterator, IntSetLess::const_iterator> pisl;

pisl = isl.equal_range(10);

for (islIter = pisl.first; islIter \!= pisl.second; \++islIter) {
&nbsp;&nbsp;&nbsp; cout << "Set contains: " << \*islIter << endl;
}

Priority: P2 Level: L3

Using an invalid ordering rule can lead to erratic behavior or infinite loops.

Component

Value

Severity

1 (low)

Likelihood

2 (probable)

Remediation cost

1 (high)

References

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