首先是CPP的std ::线程的尝试,我想说的是,我已经就这一主题使用删除功能
(Xcode 7: C++ threads ERROR: Attempting to use a deleted function研究,但没有相关的...
(Error creating std::thread on Mac OS X with clang: "attempt to use a deleted function") )
(xcode - "attempt to use a deleted function" - what does that mean?)
这是我的问题... ...:
铛错误:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/thread:347:5: error: attempt to use a deleted function
__invoke(_VSTD::move(_VSTD::get<0>(__t)), _VSTD::move(_VSTD::get<_Indices>(__t))...);
这是我的代码:
bool GenAI::loadAIs()
{
bool ret = true;
if (_nbThread > 1)
{
std::vector<std::thread> threads;
for (unsigned int i = 0; i < _nbThread; ++i)
threads.push_back(std::thread(static_cast<void (GenAI::*)(bool &, unsigned int)>(&GenAI::loadAIs), this, ret, i));
for (unsigned int i = 0; i < _nbThread; ++i)
threads[i].join();
}
else
loadAIs(ret, 0);
return ret;
}
// And the prototype of the function that i try to call
void GenAI::loadAIs(bool & ret, unsigned int iThread);
如果有人可以帮助我,会非常有帮助! :)
问候;)
它应该像'std :: ref(ret)',你应该有'bool'通过'thread'或使用'std :: atomic'...... –
Jarod42
非常感谢你,它是没有编译的std :: ref(ret)...如果你把它写成答案,我将能够关闭这张票:) –