6

In the paper P0135R0 there is an example:

struct NonMoveable {
  NonMoveable(int);
  NonMoveable(NonMoveable&) = delete;
  void NonMoveable(NonMoveable&) = delete;
  std::array<int, 1024> arr;
};
NonMoveable make() {
  return NonMoveable(42); // ok, directly constructs returned object
}
auto nm = make(); // ok, directly constructs 'nm'

This confused me:

void NonMoveable(NonMoveable&) = delete;

What is it? How constructor can be void?

UPD. Someone linked probable answer - No! This question is totally different.

Community
  • 1
  • 1
vladon
  • 8,158
  • 2
  • 47
  • 91

1 Answers1

6

That "void" is what we would call a "typo". The intent was likely to remove the move assignment operator (though not strictly necessary, since deleting the copy constructor would do that). Considering that the person wrote "void", it's not surprising that the person also missed the && part, and forgot the const in the copy constructor's parameter (also not strictly necessary).

Basically, there's a lot wrong there; someone wrote it in a hurry.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982