Boost logo

Boost :

From: Emil Dotchevski (emildotchevski_at_[hidden])
Date: 2007-04-14 20:38:05


In a discussion with Peter Dimov, following thoughts triggered by the recent
posts arguing that after a move, shared_ptr should clear px, it occured to
me that perhaps shared_ptr<T> could have T px member instead of T * px.
Peter correctly pointed out that in that case, the class template would be
called "shared", not "shared_ptr".

Note that I would still be able to say shared<foo *> to get (almost) the
same thing as shared_ptr<foo>. There are a few things that need
clarification, but overall I don't see drawbacks of shared<foo *> compared
to shared_ptr<foo>.

Peter came up with other potential uses, such as shared<int> which would be
implicitly convertible to shared<double>. You can add things like
shared<pthread_t>, or shared<HWND>. Speaking of HWND, I already wrote my own
win_handle<T>, with partial specialization win_handle<T *> which has a
shared_ptr<T> member. All that so I can write win_handle<HWND>, and it only
works because HWND happens to be a pointer.

Just a wacky idea. :)

Emil Dotchevski


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk