I want to implement a some functionality, where I will be needing two queues from STL. And I frequently have to do some operations based on input data,and I may need to move all elements from one queue to another and vice versa.But I am thinking that if i maintain reference to two queues,then I can just swap references instead of two queues.So is it possible in C++ that I have two references to two queues, and i can swap those references as per requirement ?How can i do it if possible?Normally i would have done as follow:
Queue<int> Q1;
Queue<int> Q2;
I can swap like:
Queue<int> Q3=Q1;
Q1=Q2;
Q2=Q3;
But it will do entire data copy and can be a very time consuming operation.How can i represent Q1 and Q2 as reference and then perform just swap of reference?