Tech > C++_STL_Notes

C++ Standard Template Library Notes


For an iterator to remain independent of the container type, the comparison with the end() method may use the != operator rather than the < operator, as the < operator is only implemented by random access containers. However, be careful to ensure that the iterator does not move to a position beyond end() when using the != operator.


for (i = c.begin(); i != c.end(); ++i) { }


To avoid potentially expensive startup code in some implementations of <iostream>, only include the <iosfwd> header file, unless you specifically need definitions from <iostream>.


-- Frank Dean - 10 Jun 2012