...
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) { cout << "Set contains: " << \*islIter << endl; } |
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.