std::swap vs std::exchange vs swap operator
std::swap vs std::exchange swap(x, y) and exchange(x, y) are not the same thing. exchange(x, y) never assigns a new value to y. You could do so if you use it like this: y = exchange(x, y). But that isn’t the main use case for exchange(x, y). N3668 includes the statement: The benefit isn’t huge, but … Read more