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
相關文章
相關標籤/搜索