mardi 22 août 2017

std::move operation C++

Lines from a book:

The following example shows the use of std::move to transfer ownership of a dynamic object into a thread:

void process_big_object(std::unique_ptr<big_object>);

std::unique_ptr<big_object> p(new big_object);
p->prepare_data(42);
std::thread t(process_big_object,std::move(p));

By specifying std::move(p) in the std::thread constructor, the ownership of the big_object is transferred first into internal storage for the newly created thread and then into process_big_object.

I understand stack and heap; any idea, what actually is this internal storage ?

Aucun commentaire:

Enregistrer un commentaire