0

Hi everyone,
I'm trying to compare list iterators:

list<int> l;
list<int>::iterator lb = l.begin();
list<int>::iterator le = l.end();
if (lb < le) //here I'm getting error - no operator match these operands:
{
//do something
}

And when I change this that instead of list I have vector everything works as intended. Is there any restriction on list operators?
Looking forward to your answers.
Thank you

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

There are different iterator categories. The iterators for a vector are the most flexible and they are called random access iterators. Lists use bidirectional iterators, and those do not support comparing with less.

Edited by Tom Gunn: n/a

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.