Boost logo

Boost :

From: Dirk Gregorius (dirk_at_[hidden])
Date: 2004-12-29 08:51:27


Thanks for your help and sorry for not looking carefully at the
documentation:

I tried the following for a Windows device context:

The creation function is: HDC GetDC( HWND)
The deletion function is: int ReleaseDC( HWND, HDC );

// Code like in the documentation...
typedef shared_ptr<void> handle;
handle make_dc( HWND hWnd )
{
    // The release function takes two arguments, so I tried an adapter
functor...unfortunately it does not work
    handle( GetDC( hWnd ), bind1( ReleaseDC, hWnd ) );
}

My problem is to bind the window handle to the custom delete function.
My compilter spits aout a lot of error messages here.
Can I use boost::bind here or boost::function?

BTW: How does shared_ptr call the custom delete function? For a COM
object it should call in the D'tor:

raw_ptr->Release();

While in my case it should call ( what is the usual way in the C++
standard IIRC ):

Release( raw_ptr );

Does the shard_ptr interface figures this out in some clever way and
manage this internally?

Regards,

-Dirk


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