Boost logo

Boost :

Subject: Re: [boost] [smart_ptr] shared_ptr template type
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2009-07-09 12:08:54

Frank Mori Hess wrote:

> I wonder if it might be better/possible to have a shared_ptr<T> that didn't
> assume its corresponding "raw" pointer type was T* but rather T. For
> example, what is now a shared_ptr<int> would be specified as a
> shared_ptr<int*>. The motivation would be to allow support for other classes
> as the "raw" pointer type. For example, I might want to have a
> shared_ptr<monitor<T*> > where the monitor<T*> has an operator->() which does
> automatic locking/unlocking of a mutex before/after forwarding the
> operator->() to the plain T pointer.

Why not having monitor_ptr< T > contain the shared_ptr and implement
operator-> the way you described? Making shared_ptr templated on a
pointer type is way unusual compared to other smart pointer types.

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