[Boost-users] weak_from_this

359 views
Skip to first unread message

Hite, Christopher

unread,
Aug 10, 2010, 9:48:32 AM8/10/10
to 'boost...@lists.boost.org'

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?

Chris

Frank Mori Hess

unread,
Aug 10, 2010, 8:46:38 PM8/10/10
to boost...@lists.boost.org
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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 mailing list
Boost...@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users

Reply all
Reply to author
Forward
0 new messages