1
votes

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?

1
"or does deleting the copy constructor automatically tells the compiler to not generate them?" Why don't you just try? - Jodocus

1 Answers

3
votes

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.