I’ve read that all stl containers provide a specialisation of the swap algorithm so as to avoid calling the copy constructor and two assignment operations that the default method uses. However, when I thought it would be nice to use a queue in some code I was working on I noticed that (unlike vector and deque) queue doesn’t provide this method? I just decided to use a deque instead of a queue, but still I’m interested to know why this is?
I’ve read that all stl containers provide a specialisation of the swap algorithm so
Share
C++0x will add swap to container adapters like std::queue. I could only speculate why it is missing from the current standard.
In this discussion someone proposes a workaround: