【发布时间】:2015-03-04 01:23:13
【问题描述】:
我正在尝试将原子变量传递给如下函数:
// function factor receives an atomic variable
void factor(std::atomic<int> ThreadsCounter)
{
.........
}
// main starts here
int main()
{
// Atomic variable declaration
std::atomic<int> ThreadsCounter(0);
// passing atomic variable to the function factor through a thread
Threadlist[0] = std::thread (factor, std::ref(ThreadsCounter));
Threadlist[0].join();
return 0;
}
运行上述代码时,出现以下错误:
错误 2 错误 C2280: 'std::atomic::atomic(const std::atomic &)' : 试图引用已删除的函数 c:\program files (x86)\microsoft visual studio 12.0\vc\include\功能性 1149 1 klu_factor
有人知道如何解决这个问题吗?非常感谢您的帮助。
【问题讨论】: