我正在尝试使用线程创建一个数组.我的代码看起来像这样:
boost::thread threads[10]; for(int i = 0; i < 10; i++){ client c(io_services[i], "www.boost.org", "/"); threads[i] ( boost::bind(workerFunc, i) ); }
我收到编译错误:
error: no match for call to ‘(boost::thread) (boost::_bi::bind_t> >)’ threads[i] ( boost::bind(workerFunc, i) );
我无法弄清楚我的代码中需要更改的内容.任何帮助将不胜感激.
您正在寻找:
boost::thread threads[10]; for(int i = 0; i < 10; i++){ client c(io_services[i], "www.boost.org", "/"); threads[i] = boost::thread( boost::bind(workerFunc, i) ); }