Subject: [boost] enable_shared_from_this::weak_from_this() request
From: Marat Abrarov (abrarov_at_[hidden])
Date: 2011-06-11 04:17:51
Hi, boost users and experts.
I often use boost::enable_shared_from_this.
I know - it contains boost::weak_ptr, which is initiated in the details of
Also sometimes I need function weak_from_this() at the classes derived from
I currently use something like:
: public boost::enable_shared_from_this<my_class>
, private boost::noncopyable
...somewhere in my_class details...
typedef my_class this_type;
typedef boost::weak_ptr<this_type> this_type_weak_ptr;
}; // my_class
But as I know restoring shared_ptr from weak_ptr (done in shared_from_this()) is
quite expensive. So my_class::weak_from_this() does unnecessary work instead of
just copy internal weak_ptr stored in enable_shared_from_this.
So the question is - why there is no weak_from_this() member function in
May be it would be useful to add such member function?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk