reverse iterator operator==
From: Alexander Stippler (stip_at_mathematik.uni-ulm.de)
Date: 12/31/03
- Next message: Daniel: "Developing an app to controll multiple screens at once"
- Previous message: Alexander Stippler: "Re: template instantiation trouble"
- Next in thread: Ron Natalie: "Re: reverse iterator operator=="
- Reply: Ron Natalie: "Re: reverse iterator operator=="
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 31 Dec 2003 16:52:08 +0100
Hello,
the standard requires a type reverse_iterator. But in the form it is
required and implemented for all compilers I know, there is IMO something
missing, which is essential for its usage.
With normal iterators you can compare a const_iterator and an iterator for
equality, using reverse_iterator as is, you can't. I can understand the
reason, why it's not provided. But does reverse_iterator make sense this
way? A simple example:
std::vector<int> v;
std::vector<int>::const_reverse_iterator it;
for (it=v.rbegin(); it!=v.rend(); ++it) {}
This won't compile, since it and v.rend() have different types and no
operator!= is defined for those. Isn't it unnatural that I can do the same
loop as above traversing the vector forward and it is legal code, but by
inverting the traversal direction, I create illegal code?
Any experiences with reverse_iterators? What do you think?
regards,
alex
- Next message: Daniel: "Developing an app to controll multiple screens at once"
- Previous message: Alexander Stippler: "Re: template instantiation trouble"
- Next in thread: Ron Natalie: "Re: reverse iterator operator=="
- Reply: Ron Natalie: "Re: reverse iterator operator=="
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]