我正在尝试填充 vector 线程;具有遍历目录的函数,但我遇到了问题
这是我的:
//create vector of threads
vector<thread> threads;
for(unsigned i=0; i < threadNum; ++i)
{
threads.push_back(thread(grep(arguments, r))); //best c++ 11
}
这是我得到的错误:
error c2440: '<function-style-cast>': cannot conver from 'void' to std::thread
谁能解释原因并给出答案?谢谢
编辑
grep是函数名
void grep(Arguments arguments, regex r){}
最佳答案
大概你是想说类似的话
threads.push_back(thread(grep, arguments, r));
甚至更好:
threads.emplace_back(grep, arguments, r);
关于c++ - 尝试使用函数填充线程 vector - 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11994439/