Writing a custom iterator -- what to do if you're at the end of the array?
<p>I'm writing a custom iterator for a Matrix class, and I want to implement the increment method, which gets called when the iterator is incremented:</p>

<pre><code>void MatrixIterator::increment()
{
    // go to the next element
}
</code></pre>

<p>Suppose the iterator has been incremented <strong>too many times</strong> and now points to past the end of the matrix (i.e. past the one-past-the-end point). What is the best practice for this situation? Should I catch this with an assert, or should I just say it's the user's responsibility to keep track of where the iterator is pointing and it's none of my business?</p>
