Moving a pointer on the grid would ideally look something like this:
That's how it'd look with dumb pointers. But, you can't do that with unique_ptrs, because the correct assignment operator is not defined. Shared pointers would actually work. auto_ptr is a perfect fit though, because auto_ptr will do both steps in the assignment; to move an auto_ptr you'd just do this:Code:grid[move_to_x][move_to_y] = grid[move_from_x][move_from_y]; grid[move_from_x][move_from_y] = 0;
That also illustrates why auto_ptr is weird and bad in general. That's not behavior you'd expect from a normal pointer. But it is what you want here.Code:grid[move_to_x][move_to_y] = grid[move_from_x][move_from_y];
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.