Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2008-03-12 21:37:03

on Sun Feb 24 2008, "Marco Costalba" <> wrote:

> On Sun, Feb 24, 2008 at 9:34 PM, Brian Ravnsgaard Riis
> <brian_at_[hidden]> wrote:
>> I don't deal in raw pointers in application code though (well, if I can
>> avoid it), so I added methods to the
>> dispatcher template to return shared_ptrs instead. get_shared_by_key was
>> the name I hacked up.
> Hi Brian,
> thanks for your words.
> Actually the choice to mimic a standard operator new is mainly due to
> - Keep it simple and with well known behaviour, as a toy should be
> - Do not impose a choice on a particular smart pointer, but let the
> user wrap the returned pointer in his/her preferred one. Of course the
> smart pointer class could be passed in as a template parameter, but
> this complicates the implementation and so goes against one of my main
> goals with this factory.

You should return std::auto_ptr, which -- unlike shared_ptr -- doesn't
impose any permanent choice but is also safe.

Dave Abrahams
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at