What are the rules for automatic generation of move operations?

Nikos Athanasiou gave a good answer but I wanted to add this tool that I think is very useful.

Here is a screenshot of Howard Hinnant’s presentation “Everything You Ever Wanted To Know About Move Semantics (and then some)” from ACCU 2014 conference which I think is a very good reminder of the rules of automatic generation of special members:

enter image description here

Clarification from Mr Hinnant from the comments:

The slide doesn’t say it, but the red squares indicate deprecated
behavior. I.e. if you don’t want to depend upon deprecated behavior,
then declare both of your copy members if you declare your destructor,
or one of the copy members (basically follow the C++98/03 “rule of 3”)

I recommend reading the slides to get the progressive construction of this table and have a detailed explanation of how and why we have this now.

Other presentations can be found there: http://accu.org/index.php/articles/1901

Leave a Comment