Line 2 before C ++ 11 would name the copy constructor and all these temporary instances, but with a specific move constructor to be called here.
That's right, except that any worthy optimizer will "free" a copy, so that before C ++ 11 it could have been avoided, and a C ++ 11 post could have been avoided. Same thing for line 3.
- I know, as soon as we move an object whose data will be lost when called.
Depends on how the constructor / move destination is implemented. If you do not know, this is what you should accept.
So, I am above an example of how to change line 2 to move object "b" to foo (is std :: move (b) used?).
That's right. std::move changes the type of the expression to r-value, and therefore the move constructor is called.
I read the move constructor more efficiently than the copy constructor.
This may be, in some cases. For example, the std::vector move constructor is much faster than a copy.
I can only think of a situation where we have memory on the heap, there is no need to allocate again in the case of the move constructor. Does this statement mean when we have no memory on the heap?
The statement is not universal, because for objects with a trivial copy constructor, the move constructor is not more efficient. But owning dynamic memory is not strictly a requirement for more efficient movement. In general, a move can be effective if the object owns any external resource, which can be dynamic memory, or it can be, for example, a reference counter or a file descriptor to be released in the destructor and, therefore, designed for a copy - which can be avoided when moving.
Is it even more efficient than passing by reference (no, right?)?
Really no. However, if you intend to transfer the object inside the function where you pass it by reference, you will need to pass a non-constant link and, therefore, will not be able to transfer temporary files.
In short: the link is great for temporarily accessing the object you are storing; moving is great for granting ownership.