The C ++ standard likes to throw exceptions in rules defined in one place in a completely different place.
Elimination rules for copying / moving are specified in 12.8 / 31. There are two copy / move operations in your code.
The first is easy: inside operator D
temporary constructed in the return expression is moved to the temporary, representing the return value of the function. Bullet 3 allows you to exclude this move.
The second is moving the return value of the temporary function to object d
. Again, bullet 3 allows elite.
- when a temporary class object that was not attached to the link (12.2) is copied / transferred to the class object with the same cv-unqualified type, the copy / move operation can be omitted by directly constructing the temporary object in the target of the missed copy / move
source share