After some more research and testing I found the solution. Apparently according to the standard [24.4.1/1] the relationship between i.base() and i is:
&*(reverse_iterator(i)) == &*(i - 1)
(from a Dr. Dobbs article):
So you need to apply an offset when getting the base(). Therefore the solution is:
m_CursorStack.erase( --(i.base()) );
EDIT
Updating for C++11.
reverse_iterator i
is unchanged:
m_CursorStack.erase( std::next(i).base() );
reverse_iterator i
is advanced:
std::advance(i, 1);
m_CursorStack.erase( i.base() );
I find this much clearer than my previous solution. Use whichever you require.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…