
I wonder if anyone could help me with a particular problem I'm having with shared_ptr. I'm working on a policy template, and I want the policy template to both privately inherit, and inject enable_shared_from_this - but the 2 things seem to be mutually exclusive. Let me give you an idea of what I'm trying to do (with some gross simplification to make the code a little simpler): template <class T> class policy : public enable_shared_from_this<T> { }; template <class T> class base : private policy<T> { public: shared_ptr<T> get_ptr() { return shared_from_this(); } }; class MyClass : public base<MyClass> { }; test() { shared_ptr<MyClass> obj( new MyClass ); shared_ptr<MyClass> obj1 = obj->get_ptr(); } If you run this you get a "conversion from MyClass* to boost::enable_shared_from_this<T> * exists, but is inaccessible" error (on VC++7.1). The same is true with protected inheritance. Is there any way around this? Thanks Dave Handley