|
Boost : |
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2008-08-08 09:30:49
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Friday 08 August 2008 09:25 am, Frank Mori Hess wrote:
> > boost::shared_ptr<void> s;
> > {
> > int sockfd = socket(PF_INET, SOCK_STREAM, 0);
> > if( sockfd != -1)
> > s.reset(static_cast<void*>(sockfd), bind(close,
> > static_cast_<int>(_1)));
> > }
>
> make_handle() Emil's handle.hpp creates a shared_ptr which points at a copy
> of the handle, whose lifetime is also controlled by the shared_ptr. So,
> you can access the handle through the shared_ptr as well as having the
> shared_ptr call the handle's cleanup function in its deleter. But my
> attempt at using lambda stores a pointer to the original handle in the
> shared_ptr, which becomes invalid as soon as the original handle goes out
> of scope.
Oh, and now I realize you are solving the problem by copying the handle into a
void*. handle.hpp is still more useable though, since it could be used with
any handle-like class, not just ints or similar that can copied into a void*.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFInEqJ5vihyNWuA4URAn+2AJ950uziyl/L8oWXKsj7pw4YzkN9VgCgxlSV
5ew6UUNQREACoYhF0kHLvRI=
=L0TC
-----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