Boost logo

Boost Users :

Subject: Re: [Boost-users] weak_from_this
From: Frank Mori Hess (frank.hess_at_[hidden])
Date: 2010-08-10 20:46:38


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tuesday 10 August 2010, Hite, Christopher wrote:
> shared_from_this contains a weak_ptr. Why not implement a weak_from_this()
> member function?
>
> Upgrading and downgrading a shared_ptr costs expensive atomic ops. I've
> got some setup code that just gives weak_ptr's to
> boost::singals2::slot::track().
>
> Is this a valid (and simple) feature request?

There is a boost/smart_ptr/enable_shared_from_raw.hpp which has a
weak_from_raw() free function. Unfortunately, I never got around to
documenting enable_shared_from_raw or trying to get it merged to release.
The main difference from enable_shared_from_this is that
enable_shared_from_raw is not a template class (no curiously recurring
template pattern), and shared_from_raw()/weak_from_raw() are free template
functions that take an argument instead of being member functions. Also,
they can be used in constructors (although it can be dangerous to do so if
you're not careful).

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkxh8u4ACgkQ5vihyNWuA4VgugCfX1W2edOqom9Yqhu66qdYOJfk
L6gAoKLpsoqbyou1llEwBgFSmoJrwS91
=WD2B
-----END PGP SIGNATURE-----


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net