Check if iterator to std::map points to second last element
<p>I'm (forward) iterating over a std::map and would like to find if the iterator points to the <em>second last</em> element.  I can't seem to find how to do that anywhere.</p>

<p>I've got:</p>

<pre><code>bool
isSecondLastFile(const TDateFileInfoMap::const_iterator &amp;tsFile)
{
    TDateFileInfoMap::reverse_iterator secondLastIt = mFileInfoMap.rbegin()  + 1;
    return (tsFile == secondLastIt);
}
</code></pre>

<p>Where <code>TDateFileInfoMap</code> is std::map</p>

<p>I'm getting:</p>

<pre><code>error: no match for ‘operator==’ in ‘tsFile == secondLastIt’
/usr/lib/gcc/i686-redhat-linux/4.4.7/../../../../include/c++/4.4.7/bits/stl_tree.h:287: note: candidates are: bool std::_Rb_tree_const_iterator&lt;_Tp&gt;::operator==(const std::_Rb_tree_const_iterator&lt;_Tp&gt;&amp;) const [with _Tp = std::pair&lt;const long int, TFileInfo&gt;]
</code></pre>

<p>Does that mean I can't compare the forward and reverse iterator?</p>

<p>How do I figure out if the forward iterator is pointing at the second last element?</p>