When passing an std::unique_ptr
by value (or an rvalue reference) the user is explicitly forced to call std::move
(or cast to rvalue) thus resulting in greater clarity. However when one is passed by lvalue reference the method being called can simply call std::move
itself, also transferring ownership, but with shorter user code. So, the question is:
When an object takes ownership of an object via an std::unique_ptr
, is the convention to pass it by value, rvalue reference or lvalue reference?