Boost logo

Boost :

From: Emil Dotchevski (emil_at_[hidden])
Date: 2008-08-06 18:25:17


Does anyone besides me find this code useful:

http://codepad.org/zK0iOLp2

It could go in boost/handle.hpp and could be used to manage any type
of handle in a shared_ptr, for example one could do:

shared_ptr<int> s;
{
  int sockfd = socket(PF_INET,SOCK_STREAM,0);
  if( sockfd!=-1 )
    make_handle(sockfd,close).swap(s);
}

It would also work with HWND, so you get a shared_ptr<HWND> (even
without make_handle you could still use shared_ptr<HWND__> but
strictly speaking you'd be exploiting implementation details with
that.)

Emil Dotchevski
Reverge Studios, Inc.
http://www.revergestudios.com/reblog/index.php?n=ReCode


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