The copy-and-swap idiom identifies that we can implement a classes copy/move assignment operators in terms of its copy/move constructor and achieve st
Continue ReadingC++: Swap Containers
On lines 7–8, we create two std::vectors and initialise them with values. On line 10, we swap the contents of the two std::vectors using the std:
Continue ReadingC++: Swap Values
On lines 6–7, we create two std::string objects whose values we wish to swap. However, this sample will also apply to any other swappable type. O
Continue ReadingC++: Generic Swap
The task is to write a generic swap function or operator which exchanges the values of two variables (or, more generally, any two storage places that
Continue Reading