
6 Aug
2008
6 Aug
'08
10:25 p.m.
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