Hello, reading the documentation for enable_shared_from_this,
I can't understand why this kind of base class is needed. In
the example code in the documentation, we have:
class Y: public enable_shared_from_this<Y>Isn't this piece of code equivalent (since the two pointers share ownership):
{
public:
shared_ptr<Y> f()
{
return shared_from_this();
}
}
int main()
{
shared_ptr<Y> p(new Y);
shared_ptr<Y> q = p->f();
assert(p == q);
assert(!(p < q || q < p)); // p and q must share ownership
}