说明
The header <boost/enable_shared_from_this.hpp> defines the class template enable_shared_from_this. It is used as a base class that allows a shared_ptr to the current object to be obtained from within a member function.
继承该类就可以进行基于当前子类进行安全的weap_ptr到shared_ptr的转换...
代码实例
以下代码中Y类继承enable_shared_from_this,, 从而我们可以直接在函数中调用shared_from_this获得该对象的shared_ptr
|
该类的实现
|
结论
这个实用类提供了简单的shared_ptr转换和安全的weak式验证... 这样通过继承就可以使用
shared_from_this进行安全当前类weak_ptr到shared_ptr的转换...