Lines from Anthony Williams book:
The following example uses std :: move to transfer ownership of a dynamic object to a stream:
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 constructor std::thread, ownership is big_objecttransferred first to the internal storage for the newly created stream, and then to process_big_object.
I understand the stack and the bunch; any idea that this is actually internal storage ?
Why can't they directly transfer ownership of process_big_object?
source
share