Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/136.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 使用模板和可变模板进行线程初始化_C++_Multithreading_Templates - Fatal编程技术网

C++ 使用模板和可变模板进行线程初始化

C++ 使用模板和可变模板进行线程初始化,c++,multithreading,templates,C++,Multithreading,Templates,我需要使用模板初始化std::thread class Loader { template <class T, class ...TArgs> static void work(T t, TArgs ...args) { //do stuff } template <class T, class ...TArgs> static void Load(T t, TArgs ...args) {

我需要使用模板初始化
std::thread

class Loader
{
    template <class T, class ...TArgs>
    static void work(T t, TArgs ...args)
    {
        //do stuff
    }
    template <class T, class ...TArgs>
    static void Load(T t, TArgs ...args)
    {

        thread thr = thread(Loader::work,t,args...);
        thr.join()
    }
}
类加载器
{
模板
静态无效功(T、T、TArgs…args)
{
//做事
}
模板
静态空隙荷载(T、TArgs…args)
{
线程thr=线程(加载器::work,t,args;
thr.join()
}
}
我把它绑定在自定义类初始化上,它已经工作了,但我不知道该如何处理线程


感谢您的建议

您需要明确指定模板中使用的类型:

thread thr = thread(Loader::work<T, TArgs...>,t,args...);
thread thr=线程(加载器::work,t,args;