最近在学 C++11 smart pointer
发现除了 shared_ptr, weak_ptr,unique_ptr,
还有个 enable_shared_from_this,
但我不知道 enable_shared_from_this 的用途在哪???
好像主要是为了 shared_from_this
class base : public std::enable_shared_from_this<base> {};
shared_ptr<base> a= make_shared<base>();
shared_ptr<base> b=a->shared_from_this();
a中的count 会+1,
但是我不继承 enable_shared_from_this , 不使用 shared_from_this,
直接 shared_ptr<base> b=a;
也是一样的 a的 count +1, 不是吗???
那 enable_shared_from_this 的用途是????
另外 如果我 class base 继承了 enable_shared_from_this,
但是却 unique_ptr<base> a= make_unique<base>();
这样会发生什么事????