0

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?

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by bradbobak
0

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.... ;-)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.