August 2017
Intermediate to advanced
438 pages
14h 19m
English
Now, imagine the following situation: we have a resource that cannot be copied, which should be correctly freed in a destructor, and we want to return it from a function:
descriptor_owner construct_descriptor() { return descriptor_owner("Construct using this string"); }
Actually, you can work around such situations using the swap method:
void construct_descriptor1(descriptor_owner& ret) { descriptor_owner("Construct using this string").swap(ret); }
However, such a workaround does not allow us to use descriptor_owner in containers. By the way, it looks awful!
Read now
Unlock full access