
Kenny Riddile:
I'm trying to do something like this:
boost::shared_ptr<const Foo> fooPtr( boost::static_pointer_cast<const Foo>(typeErasedFoo), CustomDeleter<const Foo>() );
where typeErasedFoo is of type:
boost::shared_ptr<const void>
What does CustomDeleter do? There is no constructor that takes another shared_ptr and a deleter. You can either associate a raw pointer with a deleter: shared_ptr( Y* p, D d ); or you can make a copy of another shared_ptr: shared_ptr( shared_ptr<Y> const& r ); Since the two shared_ptr instances now refer to the same object, it is not possible for one of them to use deleter A and for the other to use a deleter B. There only exists a single deleter, which is shared between the two. Depending on what you're trying to do, http://www.boost.org/doc/libs/1_38_0/libs/smart_ptr/sp_techniques.html#anoth... may give you some ideas though.