Is there a way to go from the iterator to the data structure? I.e. if
Is there a way for going back from i to v somehow?Code:std::vector<int> v; std::vector<int>::iterator i; i = v.begin();
Why would I want to do this?
I have a method which accepts an iterator and does something with the object inside the collection (i.e. the object the iterator is pointing to). However, the iterator can also be v.end().
I don't want to check for v.end() everytime but prefer letting the method check it. This method, as mentioned already, only gets the iterator delivered.
So is this possible?
Rephrased: Can you detect if an iterator equals vector.end() without having access to vector or getting vector.end() delivered additionally?