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.

What is the behaviour of compiler generated move constructor?

Does std::is_move_constructible<T>::value == true imply that T has a usable move constructor? If so, …

c++ c++11 move-semantics
Moving unique_ptrs from one vector to another

I'd like to move the unique_ptr's stored in an unsorted vector of them to another vector, that will contain …

c++ c++11 move-semantics unique-ptr
Should one use a std::move on a nullptr assignment?

I came across the following. Is there any advantage to doing a move on the nullptr? I assume it is …

c++11 move-semantics nullptr
Is a moved-from vector always empty?

I know that generally the standard places few requirements on the values which have been moved from: N3485 17.6.5.15 [lib.types.…

c++ c++11 vector language-lawyer move-semantics
Move-only version of std::function

Because std::function is copyable, the standard requires that callables used to construct it also be copyable: n337 (20.8.11.2.1) template<…

c++ c++11 move-semantics
Is unique_ptr guaranteed to store nullptr after move?

Is unique_ptr guaranteed to store nullptr after move? std::unique_ptr<int> p1{new int{23}}; std::unique_…

c++ c++11 move-semantics unique-ptr
Why do we copy then move?

I saw code somewhere in which someone decided to copy an object and subsequently move it to a data member …

c++ c++11 move-semantics
Can I typically/always use std::forward instead of std::move?

I've been watching Scott Meyers' talk on Universal References from the C++ and Beyond 2012 conference, and everything makes sense so …

c++ c++11 move-semantics rvalue-reference perfect-forwarding
Is returning with `std::move` sensible in the case of multiple return statements?

I'm aware that it's normally not a good idea to return with std::move, i.e. bigObject foo() { bigObject result; /*...*/ …

c++ c++11 move-semantics return-value-optimization
Why are move semantics for a class containing a std::stringstream causing compiler errors?

How can I make this simple class movable? What I thought was correct just produces a wall of errors... #include &…

c++ c++11 g++ stringstream move-semantics