How can I add boost threads to a vector

后端 未结 1 964
予麋鹿
予麋鹿 2021-01-12 03:07

I have something like this that is incorect:

vector vec;
for(int agent = 1; agent <= numAgents; ++agent)
{
    boost::thread agentThr         


        
相关标签:
1条回答
  • 2021-01-12 03:50
    • You must have a compiler with move-semantics supported in order to make your code work,
    • or use vector<shared_ptr<boost::thread>> with code like:

      vec.push_back(make_shared<boost::thread>(sellTickets, agent, numTickets/numAgents));
      
    • or use boost::thread_group.

    0 讨论(0)
提交回复
热议问题