I never knew that was the behavior of reverse iterators, very interesting.
I see what you're saying about checking for end() in the constructor because it's not valid so I made that change like this:
Now if I get what you're saying, this should be how I refer to the last element of the list:Code:circular_list_iterator( std::list<T>& container, typename std::list<T>::iterator iter ) : container( &container ), iter( iter ){ if( iter == container.end() ){ iter = container.begin(); } };
Both now give me the same result.Code:/* Either: */ circular_list_iterator<int> it( m_list, m_list.end() ); --it; /* Or: */ circular_list_iterator<int> it( m_list, m_list.begin() ); --it;
Thank You Daved and CornedBee.



LinkBack URL
About LinkBacks


