You should only consider source pointers in special cases, such as passing a pointer across a DLL boundary.
Between shared_ptr and unique_ptr , my opinion should prefer the latter. This makes the interface more flexible for your users. They can always convert the returned unique_ptr to shared_ptr if they wish, but more importantly, they can also call unique_ptr::release and then manually manipulate the pointer (maybe this is not a good idea, but it leaves the option open).
If your factory needs to assign a custom delete element for the unique_ptr returned, the difference in behavior between unique_ptr and shared_ptr that you should be aware of is that the former will not call the deleter if the managed pointer is nullptr , but the latter will. So, if your factory can return nullptr (possibly as a failure condition), and someone converts unique_ptr to shared_ptr , then make sure that the remote statement can handle the call with nullptr as an argument.
source share