Optimal swapping of stl containers

Never use a temporary variable to swap two stl containers instead always use std::swap function. This function has different overloaded versions specialized in swapping every standard container. So what’s the difference if we use a temporary variable swap and std::swap. The idea is that basically all stl containers use dynamic memory to store data, so […]
Continue reading…