Boost logo

Boost :

From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2008-08-07 09:36:51


-----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:
>
> 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);
> }

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-----


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