0

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?

4

1 回答 1

0

A great 'wood-for-the-trees' moment - I was simply negelcting to copy my altered undo operation back to the undo stack. Once I stopped looking for the "error" and just read my code, it was obvious! D'oh!

于 2013-01-13T21:12:48.613 回答