It's quite simple actually but the standard documentation can be quite confusing if what you want to find is a practical way to do it. I find this discussion shed a light to this issue quite clearly.
It turn out that what you need to do is
- make a custom deallocator function that takes pointer to the class
- pass the function name as the second parameter to the shared_ptr's constructor
1:
2:void deallocatorFunc(ClassA *p)
3:{
4: //deallocate p
5:}
6:
7:boost::shared_ptr< ClassA > ptr(new ClassA(), deallocatorFunc);
No comments:
Post a Comment