How do I clear the std::queue efficiently?

后端 未结 11 967
醉梦人生
醉梦人生 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:28

    Yes - a bit of a misfeature of the queue class, IMHO. This is what I do:

    #include 
    using namespace std;;
    
    int main() {
        queue  q1;
        // stuff
        q1 = queue();  
    }
    

提交回复
热议问题