:
1) swap . , . , a.swap(b) . : , , swap , , . X, (X &, X &) X:: swap (X &). , X:: swap (X &) , . X -, - , , .
2) if you need another container that has the same elements for which you want to transfer ownership Create a simple copy to increase efficiency
source
share