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
Using a unique_ptr might be OK.
You then reset it to obtain an empty queue and release the memory of the first queue.
As to the complexity? I'm not sure - but guess it's O(1).
Possible code:
typedef queue quint;
unique_ptr p(new quint);
// ...
p.reset(new quint); // the old queue has been destroyed and you start afresh with an empty queue