Assuming code that looks vaguely like this:
bool LoadGame() {
vector<string> SaveFile = LoadFromSaveFile();
Data = SaveFile.begin();
LoadCharacters(&Data);
// containing LoadOneCharacter(&Data) calls
LoadLocations(&Data);
// >> LoadOneLocation(&Data) calls
// etc.
}
Is there any way to check whether Data is currently pointing at SaveFile::end() while within LoadCharacters(), LoadLocations(), etc., without passing SaveFile::end() to all the functions invoked by LoadGame()?
(If only dereferencing end() and beyond threw an exception instead of generating undefined behavior!)
This is not possible, in the general case
In specific cases, you may be able to exploit implementation specific details of the iterator implementation to get at the container.
The iterators of the standard container library have no such details documented AFAIR.
A special case would be input iterators like
std::istream_iterator<>which can always be compared to default-constructed instance of itself to check for end-of-input.