Is there a stock no-op deallocator in Boost to use with boost::shared_ptr for static objects, etc.
I know it\'s ultra-trivial to write, but I don\'t wan
FWIW, this what I'm using. I use it in unit tests to adapt a local into a shared_ptr.
// The class NoOp_sptr_Deleter can be used to construct a shared_ptr<>()
// that will NOT delete the pointee.
// This can be helpful in unit-testing. Wrapping a local as a shared_ptr.
// Do take care with the lifetimes though.
struct NoOp_sptr_Deleter
{
void operator()(void const *) const {}
};
template
boost::shared_ptr FakeSharedPtrFromRef(T& aRef)
{
return boost::shared_ptr(&aRef, NoOp_sptr_Deleter() );
}