I have a sorted std::vector and I have to using the reverse_iterator for searching. It does return me the reverse_iterator for the element I search for. But I need to know the corresponding the forward iterator in the vector. I search the stackoverflow and it shows several posts that people recommend to use base() for conversion
vector<double>::reverse_iterator rit = std::upper_bound(sortData.rbegin(), sortData.rend(), 0.3);
cout << "the element in the vector with reverse iterator is " << *rit << endl;
However, in the post I found, people said to tell the corresponding forward iterator, I need to use (rit+1).base() instead of rit.base(), I don't understand why. If I do that way, I can't retrieve the same element. So I use rit.base() instead, so is it right?
vector< double >::iterator it=rit.base();
cout << "the element in the vector with forward iterator is " << *it << endl;