Guaranteed copying of leading paper using the void in the designer

Document P0135R0 gives 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' 

It confused me:

 void NonMoveable(NonMoveable&) = delete; 

What is it? How can a constructor be invalid?

UPD Someone linked the likely answer - No! This question is completely different.

+6
source share
1 answer

This "void" is what we will call the "typo". It was intended that this intention would remove the move assignment operator (although this is not strictly necessary, as this will remove the copy constructor). Given that the person wrote "void", it is not surprising that the person also skipped the && part and forgot const in the copy constructor parameter (also not necessary).

Basically, there are a lot of things wrong; someone wrote this in a hurry.

+6
source

All Articles