#include <toast/enable_unintrusive_from_this.hpp>
Sometimes it is desirable to be able to return a smart pointer that points to 'this.' Even if you could construct an unintrusive_ptr from a raw pointer, you wouldn't want to do this because it would receive a new reference count and a double free would eventually occur. This solution to the problem is taken from boost::shared_ptr. You have your class subclass this one, which will add an internal weak pointer to your class. Then your class' member functions can call unintrusive_from_this() to get a legitimate unintrusive_ptr.
Protected Member Functions | |
enable_unintrusive_from_this (enable_unintrusive_from_this const &) | |
enable_unintrusive_from_this & | operator= (enable_unintrusive_from_this const &) |
unintrusive_ptr< T > | unintrusive_from_this () |
unintrusive_ptr< T const > | unintrusive_from_this () const |
Friends | |
class | unintrusive_ptr |