Is there a way to pass multiple objects to the custom destructor for a shared_ptr? OR, can i pass an instance's function?
Is there a way to pass multiple objects to the custom destructor for a shared_ptr? OR, can i pass an instance's function?
Eh, what? That makes even less sense than usual.
A shared_ptr doesn't have a "custom destructor," its destructor simply deletes the object being pointed to. If that object has a polymorphic destructor, then the proper destructor will be invoked. I can't make heads or tails of what you're asking.
According to the documentation for smart_ptr
it takes a deletor object, and it looks like the destructor just calls: d(p);Code:template<class Y, class D> shared_ptr(Y * p, D d);
So you can create your custom deletor's constructor to take as many parameters as you want, just as long as the operator() function only takes 1 parameter which is the pointer to be deleted.