In order of best to worse:
- someFunction(const T&);
- someFunction(T&);
- someFunction(const std::unique_ptr<T>&);
- someFunction(std::unique_ptr<T>&);
The first one is the best because it does not modify the object it and it will work with the object no matter how you have allocated it (for example, you could switch to shared_ptr with no problems).
Number two will also work regardless of what smart pointer you are using; however, it assumes that you can modify the object, and whenever you can make something const, you should.
Numbers 3 and 4 both allow the object being pointed-to to be mutated; however, #3 does not allow the smart pointer to be modified, while number 4 does. Both have the disadvantage that they force the use of unique_ptr, whereas the two above it would work regardless of smart pointer class.
Passing a unique_ptr by value, as you have in some of the other examples is not an option; a unique_ptr is supposed to be unique. If you are copying it, consider using shared_ptr.
For the first two, if you invoked it on the result of back(), it would look like:
someFunction(*(lst.back())); // dereference lst.back() before passing it in.
For the latter two, if you invoked it on the resut of back(), it would look like:
someFunction(lst.back()); // pass the smart pointer, not the object to
// which the smart pointer currently points.