How do I clear the std::queue efficiently?

后端 未结 11 958
醉梦人生
醉梦人生 2020-12-12 09:10

I am using std::queue for implementing JobQueue class. ( Basically this class process each job in FIFO manner). In one scenario, I want to clear the queue in one shot( delet

11条回答
  •  無奈伤痛
    2020-12-12 09:30

    In C++11 you can clear the queue by doing this:

    std::queue queue;
    // ...
    queue = {};
    

提交回复
热议问题