
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.