vendredi 26 août 2016

STL iterator comparison

Is iterator comparison operator == or != well defined?

I mean, if I do on container named abc

auto itr1 = find(abc.begin(), abc.end(), id); //line1
...
...
auto itr2 = find(abc.begin(), abc.end(), id);//line2

would itr1==itr2 always hold true, assuming I did not modify the container 'abc' in between? Is this guaranteed by the standard? What exactly being compared here? If underlying values are compared it must be true. My confusion is what should be used between *ir1 == *itr2 and itr1==itr2? Are there any container specific behavior for this operator?

Aucun commentaire:

Enregistrer un commentaire