Template function will not compile when called as a thread

前端 未结 4 750
暗喜
暗喜 2021-01-04 20:22

I have a problem relating to template functions and threads:

template 
void Threader(TYPE_size counter)
{
    counter++;
}
int main()
         


        
4条回答
  •  独厮守ぢ
    2021-01-04 20:46

    There is no function named Threader. When you write Threader or something, then the compiler creates a function. If you then write Threader, then the compiler creates a new function. You can either provide a default template parameter, or give it a parameter when you call it.

    template 
    

    or

    thread one(Threader, counter);
    

提交回复
热议问题