This is my example code:
#include <vector>
std::vector<int> v;
int main(int, char **)
{
std::vector<int>::const_reverse_iterator iter = v.rbegin();
if (iter != v.rbegin()) // or v.rend(), whatever, just problematic
{
}
}
Is this supposed to compile correctly?
Using g++ 4.2.4 it does.
Using
sbox-i686-linux-gcc (GCC) 3.4.4 (release) (CodeSourcery ARM 2005q3-2)
I get :
error: no match for 'operator!=' in 'iter != std::vector<_Tp, _Alloc>::rbegin() [with _Tp = int, _Alloc = std::allocator<int>]()
Kind of makes const reverse iterating a non-const vector inconvenient.
this makes me think operator != (vector<T>::const_reverse_iterator, vector<T>::reverse_iterator) is not defined. Should I just check for this build environment and define the operator myself, or is there a better suggestion?