從我似乎可以這樣傳遞參數給線程函數的boost ::線程文件:傳遞參數,以提高::線程沒有重載函數需要兩個參數
boost::thread* myThread = new boost::thread(callbackFunc, param);
然而,當我做該編譯器抱怨
沒有重載函數需要兩個參數
我的代碼:
#include <boost/thread/thread.hpp>
void Game::playSound(sf::Sound* s) {
boost::thread soundThread(playSoundTask, s);
soundThread.join();
}
void Game::playSoundTask(sf::Sound* s) {
// do things
}
我正在使用Ogre3d附帶的提升副本,我猜可能會很老。有趣的是,我看了一下thread.hpp,它有2個或多個參數的構造函數的模板。
你的第一個問題是試圖初始化'thread'對象與'螺紋*',但你的錯誤是不相關的 - 這聽起來像你要麼缺少'#include'或者使用**真的**舊版本的Boost ... –
ildjarn
2013-03-06 22:53:53
你能發佈一個[sscce](http:// sscce。組織/)? – juanchopanza 2013-03-06 22:56:30
@ildjarn啊,我傻了。我在描述我的代碼時犯了一個錯字。我會用我的實際代碼和更多信息更新這個問題 – 2013-03-06 23:03:04