I think the concept of a pointer that cleans up after it self like std::shared_ptr is cool, but I was wondering if there is a better third party smart pointer out there.
The problem with the shared_ptr is that of recursive references. This occurs when you have something like this:
class A{ public: std::shared_ptr<A> other; A() { } }; //Later std::shared_ptr<A> a = std::make_shared<A>(); std::shared_ptr<A> b = std::make_shared<A>(); a->other = b; //Memory leak b->other = a; //Memory leak Is there a smarter smart pointer out there that can sense when I should have used a weak pointer and doesn't leak (or at least gives a warning)? (After a brief google search I can not find anything)
delete thisin a destructor.Adoes not compile.A() : self(*this) { }Huh? What is this supposed to do? What are you trying to achieve?