The user is supposed to take ownership of that object. I do not want to return a Boost.shared_ptr,
shared_ptr
expresses shared ownership, and you want your interface to express transfer of ownership. std::auto_ptr
would thus be more applicable here.
Internally however, I would like to store the pointer in a shared_ptr to prevent memory leaks in case of exceptions
Again, shared_ptr
may not be the best tool for that job. To prevent leaks in the case of exceptions, scoped_ptr
or auto_ptr
would be better suited.