Top "Move-semantics" questions

Move semantics is a programming language feature that allows a copy operation to be replaced by a more efficient "move" when the source object is a temporary or an otherwise expiring object.

Can I list-initialize a vector of move-only type?

If I pass the following code through my GCC 4.7 snapshot, it tries to copy the unique_ptrs into the vector. #…

c++ c++11 initializer-list move-semantics
Can I move-assign a std::map's contents into another std::map?

Is it possible to insert the contents of a temporary std::map temp into another std::map m by using …

c++ c++11 move-semantics
why is the destructor call after the std::move necessary?

In The C++ programming language Edition 4 there is an example of a vector implementation, see relevant code at the end …

c++ memory-management c++11 move-semantics explicit-destructor-call
Is it possible to std::move local stack variables?

Please consider the following code: struct MyStruct { int iInteger; string strString; }; void MyFunc(vector<MyStruct>& vecStructs) { MyStruct …

c++ c++11 move move-semantics
Why does std::move prevent RVO?

In many cases when returning a local from a function, RVO kicks in. However, I thought that explicitly using std::…

c++ c++11 move-semantics rvo
What can I do with a moved-from object?

Does the standard define precisely what I can do with an object once it has been moved from? I used …

c++ c++11 variable-assignment swap move-semantics
How to use c++11 move semantics to append vector contents to another vector?

Consider this snippet: class X; void MoveAppend(vector<X>& src, vector<X>& dst) { dst.…

c++ c++11 move-semantics
std::vector::emplace_back and std::move

Is there any advantage of using std::vector::emplace_back and std::move together? or it is just redundant since …

c++ c++11 vector move-semantics
Is there any case where a return of a RValue Reference (&&) is useful?

Is there a reason when a function should return a RValue Reference? A technique, or trick, or an idiom or …

c++ c++11 move-semantics rvalue-reference
Is this correct usage of C++ 'move' semantics?

Tonight I've been taking a look at some code I've been working on over the last few days, and began …

c++ c++11 move-semantics c++-standard-library