Home >Backend Development >C++ >When Does the C 11 Compiler Automatically Generate Move Operations?
Rules for Automatic Generation of Move Operations
In C 11, the compiler's ability to automatically generate move operations differs from the rules for copy operations in C 98.
Move Constructor and Move Assignment Operator
Under the following conditions, the compiler will automatically generate a move constructor and move assignment operator:
Cases Where Move Operations Are Not Automatically Generated
The compiler will not automatically generate move operations if any of the following conditions are met:
Tool for Verifying Automatic Generation Rules
The following resource provides a visual representation of the rules for automatic generation of special members, including move operations:
[Image of Howard Hinnant's ACCU 2014 presentation slide](https://i.sstatic.net/b2VBV.png)
Additional Clarification
The red squares in the table indicate deprecated behavior. If you wish to avoid relying on deprecation, consider following the "rule of 3" from C 98/03: declare both copy members if you declare the destructor, or declare at least one copy member.
The above is the detailed content of When Does the C 11 Compiler Automatically Generate Move Operations?. For more information, please follow other related articles on the PHP Chinese website!