sizeof(integers)/sizeof(integers[0]) on vector<int> (x64)

Pages: 12
or for any type of iterator then std::next(it, n) can be used where n is 0 or positive. -ve n can be used with at-least bi-directional iterators. There is also std::prev(it, n) if the iterator is at least bi-directional.
https://cplusplus.com/reference/iterator/
Note < is only meaningful if the iterators are consecutive (eg for vector). If the iterators are not consecutive then != must be used (!= can also be used with consecutive ones).

IMO using != no matter what the layout of the container might be makes it easier to remember and use.

One Comparison, One Iterator, One Choice, Blah Blah Blah.

IMO using != no matter what the layout of the container might be makes it easier to remember and use.


That is exactly what I find myself using already, I love consistency.
Topic archived. No new replies allowed.
Pages: 12