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
A common idiom for clearing standard containers is swapping with an empty version of the container:
void clear( std::queue &q ) { std::queue empty; std::swap( q, empty ); }
It is also the only way of actually clearing the memory held inside some containers (std::vector)