according to item 25 in effective C++ 3rd edition, if we have a class with a pointer to another type that contains the real data, we need to define a swap for it. but i am doubt whether it is still necessary since C++ introduce move? Of course, I talk about class with move operations
who can help me analyze it? Not just the answer. thank you!
AFAIR you might not define your own swap function if you have noexcept move constructor and noexcept move assigment operator defined. In this case default swap operation will be efficient.
Then again, both of those (and copy assigment too) might be defined through swap operation, so it is kinda circular.
> if we have a class with a pointer to another type that contains the real data, we need to define a swap for it.
> but i am doubt whether it is still necessary since C++ introduce move?
It is not necessary.
In C++11 the pointer would be a standard or user-defined smart pointer (which is move-aware).
Except for classes designed exclusively to manage ownership of resources, we would adhere to 'the rule of zero'. http://en.cppreference.com/w/cpp/language/rule_of_three