multithreading - 没有匹配函数调用 ‘std::thread::thread(<unresolved overloaded function type>)’

标签 multithreading c++11

void show_image(){
   // Create a Mat to store images
Mat cam_image;
ERROR_CODE err; 

// Loop until 'e' is pressed
char key = '';
while (key != 'e') {

    // Grab images 
    err = cam.grab();

    // Check if successful
    if (err == SUCCESS) {
        // Retrieve left image and show with OpenCV
        cam.retrieveImage(zed_image, VIEW_LEFT);
        cv::imshow("VIEW", cv::Mat(cam_image.getHeight(), cam_image.getWidth(), CV_8UC4, cam_image.getPtr<sl::uchar1>(sl::MEM_CPU)));
        key = cv::waitKey(5);
    } else
        key = cv::waitKey(5);
}
}

上面的函数被这个函数调用-threaded-:

void startCAM()
{

    if(show_left){
     cam_call = std::thread(show_image);
    }
    //Wait for data to be grabbed
    while(!has_data)
      sleep_ms(1);
}

我得到了错误:

     error: no matching function for call to ‘std::thread::thread(<unresolved     overloaded function type>)’
      cam_call = std::thread(show_image);

应该注意我没有使用类或对象,所以 show_image 不是成员函数

最佳答案

错误显示 std::thread::thread(<unresolved overloaded function type>) , 这意味着有多个名为 show_image 的函数.

您需要选择其中一个重载。例如:

std::thread(static_cast<void(*)()>(show_image));

关于multithreading - 没有匹配函数调用 ‘std::thread::thread(<unresolved overloaded function type>)’,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44908313/

相关文章:

c++ - c++ 标准是否保证堆栈展开并出现异常?

c++ - Lambda 作为模板函数

c++ - 将 SIGTERM 绑定(bind)到成员函数

c++ - 我可以拥有非拥有的共享指针吗?

java - 如何在多个线程中运行一个 jar 文件?

c++ - 在非静态成员函数上使用 C++ 11 多线程

c++ - 为什么插入用户定义的析构函数需要用户定义的复制构造函数

java - Spring Boot 中的多线程 cron 作业

c++ - Boost.thread 可能的内存泄漏

android - 从非 UI 线程更新 View