【发布时间】:2013-07-14 11:50:03
【问题描述】:
尝试制作简单的代码工作:
std::thread threadFoo;
std::thread&& threadBar = std::thread(threadFunction);
threadFoo = threadBar; // thread& operator=( thread&& other ); expected to be called
得到一个错误:
使用已删除函数'std::thread& std::thread::operator=(const std::thread&)'
我明确地将threadBar 定义为右值引用,而不是普通的。为什么没有调用预期的运算符?如何将一个线程移到另一个线程?
谢谢!
【问题讨论】:
标签: c++ multithreading c++11 move-semantics assignment-operator