[Boost-users] weak_from_this

已查看 362 次
跳至第一个未读帖子

Hite, Christopher

未读,
2010年8月10日 09:48:322010/8/10
收件人 '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

未读,
2010年8月10日 20:46:382010/8/10
收件人 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

回复全部
回复作者
转发
0 个新帖子