I have the following struct:
struct IDirect3D
{
IDirect3D() : ref_count_(0) {}
unsigned long Release() { return --ref_count_; }
private:
long ref_count_;
~IDirect3D() {}
};
I want to use shared_ptrfor it, as in the following code (minimal example):
int main()
{
boost::shared_ptr<IDirect3D> ptr;
IDirect3D* p = 0;
ptr.reset( p, boost::mem_fn( &IDirect3D::Release ) );
return 0;
}
In most cases, this works fine, but at the same time, if pequal 0. I have the following deleter that I want to use:
template<typename T, typename D>
inline void SafeDeleter( T*& p, D d )
{
if ( p != NULL ) {
(p->*d)();
p = NULL;
}
}
But the following code gives a lot of errors (it looks like it unloads everything bind.hpp):
ptr.reset( p, boost::bind( SafeDeleter, _1, &IDirect3D::Release ) );
What happened to my use bind?
source
share