C
Comp1597
Suppose I have a function with a parameter of type
vector<int>::iterator
How can I test whether that iterator is at the beginning of a vector?
If i denotes the vector<int>::iterator parameter, I could be tempted
to say if (--i == 0) However I believe it's an error to
decrement an iterator before the beginning of a vector.
There's probably a solution involving copying the iterator to a
reverse_iterator but I'm probably missing something really simple.
vector<int>::iterator
How can I test whether that iterator is at the beginning of a vector?
If i denotes the vector<int>::iterator parameter, I could be tempted
to say if (--i == 0) However I believe it's an error to
decrement an iterator before the beginning of a vector.
There's probably a solution involving copying the iterator to a
reverse_iterator but I'm probably missing something really simple.