C++ 11 多线程之坑
2018-08-20 本文已影响0人
不羁的风_1a8c
代码:
std::thread t1(do_detect, vector1, face1, pic_paths1);
编译报错:
thread:342:5: error: attempt to use a deleted function __invoke(_VSTD::move(_VSTD::get<1>(__t)), _VSTD::move(_VSTD::get<_Indices>(__t))...);
原因是C++11构造函数中传入时要求必须是引用,不然会调用move方法,而move方法已经弃用
需要改为(传入引用):
std::thread t1(std::ref(do_detect), std::ref(vector1), std::ref(face1), std::ref(pic_paths1));