mardi 26 octobre 2021

Make thread library [closed]

I want to simulate thread library. I already make separate class and function template but I get error to use both of them. How can I use both of them? Are they right or I should follow another method.

class thread  {
public:
    thread() { }
};
template <class P,class ... _Args >
void thread(P(*f) ( _Args ... __args ), _Args ... __args ){(*f ) ( __args ...) ;}

I want to have following constructor and function by thread.

void add(){
  cout<<"Method add"<<endl;
}
int main()
{
  thread t1;
  thread(add);
  thread(bar,0);  
  thread();  
  return 1;
}

Aucun commentaire:

Enregistrer un commentaire