When I use a unique_ptr instance, I frequently copy it around. Unique_ptr ‘s copying is actual moving.
The are different ways to code it.
- sometimes you need to use someFunc(move(myUniquePtr));
- sometimes you can omit move() and the semantics remain the same.
http://stackoverflow.com/questions/9827183/why-am-i-allowed-to-copy-unique-ptr has some examples. Note none of the functions have a parameter/return type showing “&&”. That’s because there is pbclone in play. The copying uses the move-constructor, which does have a && parameter.
I think some developers simply copy sample working code, without understanding why, like an ape. Some use threading constructs the same way. Nothing shame. I feel interviewers are interested in your understanding.