I have a large array of object pointers (lets call it A), and a smaller map of object pointers (M) keyed with the index of A.
While iterating M, I want to swap the mapped pointer (second) with the pointer that is currently at that index (first) in A.
I have something like this:
map<LONG, Object*>::iterator mit;
for (mit = M.begin(); mit != M.end(); mit++)
{
if ((*mit).first != NO_ID)
{
Object* pTmp = pA->ReplaceObject((*mit).first, (*mit).second);
if (pTmp != NULL)
{
M.at((*mit).first) = pTmp;
}
}
}
Here ReplaceObject first gets A[(*mit).first] for return, then changes A[(*mit).first] to (*mit).second.
My mapped pointer is staying stubbornly unchanged - though the debugger, appears to show the change happens correctly.
What am I doing wrong?