It'll copy the pointer p
into the pointer pm
.
"Moving" pointers makes no sense because:
- they have no move constructor
- they have no move assignment operator
- they are trivially simple and there is nothing to gain from moving them
Your expectation that the entire array will be somehow "moved" also makes no sense because:
- you are already only obtaining handles to the same data, so there's nowhere for it to move to
- the type
int*
has no knowledge about the data its instances may point to
Remember that the terribly-named std::move
doesn't actually move anything. It just gives you an rvalue out of a name that might otherwise be treated as an lvalue.
In this case, the distinction is irrelevant, so it's as if you didn't write move
at all.
Move semantics are useful for larger, more complex objects that indirectly manage memory, for example using pointers. You would expect the move constructor or move assignment operator for such a type to swap pointers. That's as far as the abstraction goes; that's the extent of its usefulness.
Trying to apply the same logic to pointers themselves just doesn't have any meaning, except in the case of a unique_ptr
where this abstraction is found in its very purest form, because such an object is an extremely thin wrapper over a naked pointer. It's still only the wrapper that gets moved.
The best you could do would be to copy p
into pm
, then arbitrarily make p
"invalid" by setting it to some unusable value. Again, pretty useless.