Boost logo

Boost :

Subject: [boost] [shared_ptr] Set pointer to null
From: Mateusz Loskot (mateusz_at_[hidden])
Date: 2009-11-09 06:29:45


Hi,

I'd like to make a custom deleter resetting pointer to 0 or other value
(e.g. for debugging purposes) after resource has been deallocated.
Would anyone suggest better option to this presented below?

struct DeleterT
{
     void operator()(::T* ptr)
     {
         ::DestroyT(ptr);

         // uses Visual C++ specific integer type
         *reinterpret_cast<__int64*>(&ptr) = 0;
     }
};

Best regards,

-- 
Mateusz Loskot, http://mateusz.loskot.net

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