Boost logo

Boost :

From: gchen (chengang31_at_[hidden])
Date: 2007-04-15 01:20:27

Emil Dotchevski wrote:
> 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.

Maybe could add a new shared<T>, but still keep shared_ptr, as a

typedef shared<T*> shared_ptr;

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