Boost logo

Boost :

From: Rodolfo Lima (rodolfo_at_[hidden])
Date: 2003-02-19 22:09:18


I miss a custom destructor version of shared_from_this. The only one
function just accepts a pointer and construct a shared_ptr from it. Should
shared_from_this also match shared_ptr's constructor that takes a pointer
and it's destructor function object, or the lack of it is a design decision?

I need the following (something like it):

struct drawobj_deleter
{
    void operator()(const CDrawObj* pObj) const
    {
          DeleteDrawObj(pObj);
    }
};

main()
{
     shared_ptr<CDrawObj> pObj = shared_from_this(new CDrawObj,
drawobj_deleter());
}

I know I could use de constructor directly, but I prefer using
shared_from_this because this way it's more explicit that we're "crossing
the boundary" between raw pointer and smart_pointer.

rod.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk