Implement compiler-generated movements

How do the move constructors implicitly create the compiler and move the assistant operator implemented by the compiler?

Does the compiler use the idiom with copy and replace with the unified operator= (with its reliable guarantee of the safety of exceptions) or implements an element transition?

+4
source share
2 answers

Does the compiler use the idiom with copy and replace with a single operator = (with its reliable guarantee of the safety of exceptions) or implements an element transition?

In paragraph 12.8 / 15 of the C ++ 11 standard:

The implicit copy / move constructor for a non-unit class X performs a phased copy / move of its bases and members . [...]

In addition, according to clause 12.8 / 28:

An implicit copy / move assignment operator for a non-unit class X executes / moves the assignment of its subobjects . [...]

+2
source

This move in order, just as implicit copy operations make a copy in order. See 12.8 [class.copy] paragraphs 15 and 25.

It would not be possible to copy and change for a type that cannot be copied or cannot be replaced, you do not want the move operations to depend on another special member or swap member, which may be absent or may not work properly.

+4
source

All Articles