enable_shared_from_this和shared_from_this

shared_from_this()是enable_shared_from_this<T>的成员 函数,返回shared_ptr<T>。首先须要注意的是,这个函数仅在shared_ptr<T>的构造函数被调用以后才能使 用。缘由是enable_shared_from_this::weak_ptr并不在构造函数中设置,而是在shared_ptr<T>的 构造函数中设置。   以下代码是错误的: cl
相关文章
相关标签/搜索