
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Wednesday 06 August 2008 18:25 pm, Emil Dotchevski wrote:
Does anyone besides me find this code useful:
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); }
Couldn't you use lambda for this? boost::shared_ptr<int> s; { int sockfd = socket(PF_INET,SOCK_STREAM,0); if( sockfd!=-1 ) s.reset(&sockfd, boost::lambda::bind(close, * boost::lambda::_1)); } I've never really used lambda, but it compiles at least. By the way, is there any documentation on the lambda headers (which ones to include to use what)? I didn't see anything in the lambda docs. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFImvp55vihyNWuA4URAjJrAJ9pWAw6YESdzuAcbZSbJF672tQqsQCgwlBc SMEGxtEXucTsieb0g0uDK/M= =ijrr -----END PGP SIGNATURE-----