   Subscripting iterators
  If I have a vector<...>::iterator iter, does iter[1] do what is the obvious semantic intention?  The reason I try this sintax is for something likefor (std::vector<size_t>::iterator itf = _f.begin(); itf < _f.end(); itf += 3){size_t ia(*itf), ib(itf[1]), ic(itf[2]);....   
Quote:Original post by PruneIf I have a vector<...>::iterator iter, does iter[1] do what is the obvious semantic intention?  The reason I try this sintax is for something likefor (std::vector<size_t>::iterator itf = _f.begin(); itf < _f.end(); itf += 3){size_t ia(*itf), ib(itf[1]), ic(itf[2]);....std::vector::iterator should be a random access iterator. See here for what operations a type must have to be considered a random access iterator. If the table is correct it "Supports offset dereference operator ([])". So you're good from a valid syntax point of view. From other points of view... I'm not going to get into. I'm giving you the bullets but you need to put them in the gun and shoot!   ;  By "other" I simply mean treating the iterator as a vector overlapping the first with a different starting position.  In this case I just want to recreate mesh normals:void Mesh::Normalize(void){for (std::vector<vector3f>::iterator itn = _v.begin(); itn < _n.end(); ++itn) itn->zero();for (std::vector<size_t>::iterator itf = _f.begin(); itf < _f.end(); itf += 3){size_t i0(*itf), i1(itf[1]), i2(itf[2]);vector3f norm(cross(_v[i0] - _v[i1], _v[i2] - _v[i1]));_n[i0] += norm;_n[i1] += norm;_n[i2] += norm;}for (std::vector<vector3f>::iterator itn = _v.begin(); itn < _n.end(); ++itn) itn->normalize();}