Reputation: 957
I have a class that I do not intend to copy/move around and want to make sure I don't accidentally do that.
class Foo {
public:
Foo(const Foo&) = delete;
// Are these 3 needed?
Foo(Foo&) = delete;
Foo& operator=(const Foo&) = delete;
Foo& operator=(Foo&&) = delete;
}
Is there any purpose of also deleting the move constructor and/or the move/copy assignment operators, or does deleting the copy constructor automatically tells the compiler to not generate them?
Upvotes: 2
Views: 1101
Reputation: 7601
Check out the lists on when such functions are implicitly deleted and when not. So the short answer to your question without repeating what is written in the documentary:
Is there any purpose of also deleting the move constructor and/or the move/copy assignment operators [...]?
Yes, there certainly is. Even if it is just emphasizing more strongly in a redundant way that a particular operation is not permitted, so it may make the interface of your code more expressive.
Upvotes: 2