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?

Yes it did. There were are number of horrible errors associated with
gcc-3.4 series on reverse iterators. You have to use == and !( iter == v.rbegin()) or as you say write you own.

I am sorry but I pity you having to write for 3.4. (My problem is I have users who want to use 4.4 alpha.... ;-)

Ok, thanks for the reply. I'm marking this as solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.