我为这种错误获得的所有解决方案都具有通过引用传递变量的功能。如果我按值传递变量并仍然得到错误怎么办? 这是我的代码
这些是MyProcess类中的公共全局变量
int n,gt,rt;
string paths[10];
std::thread t[10];
这是我创建多个线程的函数。
void MyProcess::start(){
int j;
for (int i = 0; i < n; i++){
j=i+1;
t[i] =std::thread(processVideo, paths[i], j, gt, rt);
}
for (int i = 0; i < n; i++)
t[i].join();
}
这是我在线程中调用的函数的定义
void MyProcess::processVideo(string videoFilename, int pos, int gt, int rt){}
我得到的错误是这个
C:\Qt\Tools\mingw530_32\i686-w64-mingw32\include\c++\functional:1426: error: static assertion failed: Wrong number of arguments for pointer-to-member
static_assert(_Varargs::value
^
C:\Qt\Tools\mingw530_32\i686-w64-mingw32\include\c++\functional:1505: error: no type named 'type' in 'class std::result_of<std::_Mem_fn<void (MyProcess::*)(std::__cxx11::basic_string<char>, int, int, int)>(std::__cxx11::basic_string<char>, int, int, int)>'
typedef typename result_of<_Callable(_Args...)>::type result_type;
^
C:\Qt\Tools\mingw530_32\i686-w64-mingw32\include\c++\functional:1526: error: no type named 'type' in 'class std::result_of<std::_Mem_fn<void (MyProcess::*)(std::__cxx11::basic_string<char>, int, int, int)>(std::__cxx11::basic_string<char>, int, int, int)>'
_M_invoke(_Index_tuple<_Indices...>)
^
提前致谢。