首先是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)...如果你把它寫成答案,我將能夠關閉這張票:) –