I was sorting through some C ++ source code from a library related to the home project I'm working on, and came across something, T understand. In the place where I was expecting the pointer to be dereferenced followed by assignment, the authors of the library 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 the same type.
When it comes to "system programming", my background is in C and C #, but not very much in C ++. Is there any special reason for this type of "appointment"?
c ++ variable-assignment swap
easuter
source share