inconsistent behaviour of const_iterator and const_reverse_iterator

S

Serengeti

hello,
I've had some hard time trying to understand why does this code
compile:
http://cpp.sourceforge.net/?show=10151 (*)
while this doesn't:
http://cpp.sourceforge.net/?show=10150 (**)

Any insights would be greatly appreciated.
tia,
Slawek


(*)
#include <vector>
using std::vector;

int main()
{
vector<double> vect;
for(vector<double>::const_iterator v = vect.begin(); v !=
vect.end(); v++);
}

(**)
#include <vector>
using std::vector;

int main()
{
vector<double> vect;
for(vector<double>::const_reverse_iterator v = vect.rbegin(); v !=
vect.rend(); v++);
}
 
J

Jonathan Mcdougall

Serengeti said:
hello,
I've had some hard time trying to understand why does this code
compile:
http://cpp.sourceforge.net/?show=10151 (*)
while this doesn't:
http://cpp.sourceforge.net/?show=10150 (**)

Any insights would be greatly appreciated.
tia,
Slawek


(*)
#include <vector>
using std::vector;

int main()
{
vector<double> vect;
for(vector<double>::const_iterator v = vect.begin(); v !=
vect.end(); v++);
}

(**)
#include <vector>
using std::vector;

int main()
{
vector<double> vect;
for(vector<double>::const_reverse_iterator v = vect.rbegin(); v !=
vect.rend(); v++);
}

This is a defect:
http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#280


Jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top