The C++ Standard Template Library is the flagship example for libraries based on the
generic programming paradigm. The usage of this library is intended to minimize classical
C/C++ errors, but does not warrant bug-free programs. Furthermore, many new kinds
of errors may arise from the inaccurate use of the generic programming paradigm, like
dereferencing invalid iterators or misunderstanding remove-like algorithms. In this
paper we present some typical scenarios that may cause undefined or weird behaviour.
We present approaches that can be used for developing different safe iterators to
avoid run-time errors. Some of these iterators are able to manipulate the container
directly, hence they cannot result in undefined behaviour when an algorithm needs
to add elements to the container or delete elements from the container. Our iterators
are able to indicate if they are invalid. Algorithms' preconditions are evaluated
with our iterators.