c++ - 错误 C2893 函数模板专用化失败 'unknown-type std::invoke(_Callable &&,_Types &&...)'

标签 c++ multithreading visual-studio c++11 visual-studio-2015

我在 Visual Studio 2015 项目的 C++ 类中使用 std::thread。

class BaggageSoln {
        void mainProcess();
        // Threading functions
        void run();
        void startZED();        
        void closeZED();
private:
        std::thread zed_callback;

}

void BaggageSoln::startZED()
{
    // Start the thread for grabbing ZED data
    has_data = false;
    zed_callback = std::thread(&BaggageSoln::run);

    //Wait for data to be grabbed
    while (!has_data)
        sleep_ms(1);
}

void BaggageSoln::mainProcess() {}
void BaggageSoln::run() {}
void BaggageSoln::closeZED(){}

xthread 文件第 238 行发生错误。 有什么问题吗?

最佳答案

&BaggageSoln::run 需要调用一个实例,将其设为static 或提供一个实例。

zed_callback = std::thread(&BaggageSoln::run, this);

关于c++ - 错误 C2893 函数模板专用化失败 'unknown-type std::invoke(_Callable &&,_Types &&...)',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44518253/

相关文章:

c++ - 链接器在 Eclipse/JNI/ANT 中找不到库

c - 在多线程服务器程序中使用 linux 信号处理程序实现每 25 毫秒执行一次浮点计算的程序?

java - Hazelcast 分布式计算的基本概念

c# - Visual Studio 2015 社区版 : Error „lc. exe 退出,代码为 -1“

python - Numpy CAPI PyArray_新 Visual Studio 警告 C4055

c++ - 如何使用 Visual C++ 构建独立的 SDL 项目?

c++ - 如何捕获两个以上的连续信号?

c++ - 阅读字典并打印出给定长度的单词

C++ 在循环中创建线程时出错

visual-studio - VsVim 中的可视 block shift-i(nsert)