Re: [boost] About rcgc_shared_ptr
A downgrade implementation can be like this (which is actually my former implementation during the experiments) We define an interface: struct IDIsposable { virtual void Dispose() = 0; }; And implement this interface with class A class A : public IDisposable { Public; A():disposed(false){} public: virtual void Dispose(){ if(!this->disposed){ this->_pb.Dispose();//this Dispose belongs to rcgc_shared_ptr this->_pc.Dispose(); //this Dispose belongs to rcgc_shared_ptr this->disposed = true; } } bool disposed; rcgc_shared_ptr<B> _pb; rcgc_shared_ptr<C> _pc; }; And we don’t care about ~A() and let the rcgc_shared_ptr call Dispose method of the IDisposable. This would avoid the dtors definition. However, this is not as elegant as the previous given solution in C++, having to write more code which we don’t like to do, although no difference in other languages or platforms. I’m sorry that I have to call it a day now and have to get some sleep (4:06am here) Waiting for your kindly response and suggestions. Best Regards, Yilin
participants (1)
-
逸霖 杨