Why doesn't std::queue support a clear() function?

前端 未结 4 793
感情败类
感情败类 2021-02-01 16:12

I have requirement: for a function, I get the input as a stream of numbers. I mean, the function keeps on getting called with single number in each call. I am using std::q

4条回答
  •  爱一瞬间的悲伤
    2021-02-01 16:58

    Apart from what has been said already, you can clear a queue very easily:

    queue q;
    ...
    q = queue(); // Assign an empty queue
    

    or in C++11

    q = {};
    

提交回复
热议问题