Hello,
I'm currently using a vector to store objects in my Singleton class.
I have a function that checks if a specific object is already inside the vector and reports true if it is present.
my for loop however jump right through it. I've tried it with using an int to loop through the locations, an iterator and size_t but all three just jump through the entire vector without accessing the elements.
When I look at the vector in memory with the debugger I noticed that the first time the vector is complelty empty (as it should be since its just initialized), but the second time there is one reference to my object in it, i cna read it values and adress through the debugger, but the vector reports its size as 0 and the iterator just jumps through it althoug the begin and end adress are different.
this is the code
The vector is defined as std::vector<Dri ve> drives; inside the header of my Singleton class.
I'm currently using a vector to store objects in my Singleton class.
I have a function that checks if a specific object is already inside the vector and reports true if it is present.
my for loop however jump right through it. I've tried it with using an int to loop through the locations, an iterator and size_t but all three just jump through the entire vector without accessing the elements.
When I look at the vector in memory with the debugger I noticed that the first time the vector is complelty empty (as it should be since its just initialized), but the second time there is one reference to my object in it, i cna read it values and adress through the debugger, but the vector reports its size as 0 and the iterator just jumps through it althoug the begin and end adress are different.
this is the code
Code:
for(std::vector<Drive>::const_iterator it = drives.begin(); it != drives.end(); ++it) { // if(drives[i].GetDriveLetter() == DriveLetter) if(it->GetDriveLetter() == DriveLetter) { // DEBUG OutputDebugStringA(AnsiString("[DriveManager] :: Found a Drive that has DriveLetter = '" + AnsiString(DriveLetter) + "'").c_str()); // We found a drive with the same DriveLetter, // set our return value to true. return_value = true; // exit the for loop using a break. break; } }
Comment