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
Yes there is one here:
#include // for null_deleter
class Foo
{
int x;
};
Foo foo;
boost::shared_ptr< Foo > sharedfoo( &foo, boost::serialization::null_deleter() );
There is, of course, a danger with the fact that you need to know the function you call doesn't store the shared_ptr for later use, as it actually goes against the policy of shared_ptr in that the underlying object remains valid until that of the last instance of the shared_ptr.