I was going over some C++ source code from a library related to a pet-project I'm working on and encountered something I don't understand. In a place where I expected a pointer dereference followed by assignment, the library authors use std::swap()
near the end of the function to write the result:
std::swap(*out, result);
I expected to see something like this:
*out = result;
Note that result
is a typedef
of size_t
and out
is a pointer to that same type.
When it comes to "systems programming", my background is in C and C# but not much at all in C++. Is there any particular reason for this type of "assignment"?