
23 Nov
2008
23 Nov
'08
9:43 a.m.
On Thursday 20 November 2008 14:23:49 Jens Finkhäuser wrote:
If you're talking workarounds, here's another one: why return shared_ptr at all? If it's a factory you're implementing (i.e. something that creates objects, and doesn't hold references to them), there's little reason to return one. Return a raw pointer, and build a shared_ptr from the return value.
I would have said the same, but IMHO it should return std::auto_ptr instead. In cases where it returns a derived type, splitting into a public, nonvirtual function returning auto_ptr<BaseT> and a pure virtual one that can then support covariant return types is a suitable solution. Uli