On 07/09/2017 11:01 AM, Phil Bouchard via Boost wrote:
On 07/08/2017 10:39 PM, Phil Bouchard via Boost wrote:
That is flawless... If anybody is willing to fool this memory manager then please go ahead!
Actually I think I'll still need to fine tune-it but I'm getting there. Also it'll be better if I reintegrate the old "inclusive" mode (in the master branch) and the user can choose the mode at run-time or compile-time.
Little change here in the code: --- include/boost/smart_ptr/root_ptr.hpp (revision 678) +++ include/boost/smart_ptr/root_ptr.hpp (working copy) @@ -314,7 +314,8 @@ // upscale the proxy of the operand if (px_->depth() < p.px_->depth()) - propagate(p); + p.proxy(* px_); + base::operator = (p); I'm pretty sure I got it right if I add the notion of 'upscaling the scope of a variable'. For example: int main() { cout << "Scope 0: BEGIN" << endl; { node_proxy x; // 1st proxy node_ptr<A> a1 = make_node<A>(x, x, "a1"); cout << "Scope 1: BEGIN" << endl; { node_proxy x; // 2nd proxy node_ptr<A> b1 = make_node<A>(x, x, "b1"); node_ptr<A> b2 = make_node<A>(x, x, "b2"); a1 = b1; // upscale scope of b1 to use 1st proxy b1 = make_node<A>(x, x, "b3"); // scope of b1 will still be associated with the 1st proxy b1->i = b1; // cycle } cout << "Scope 1: END" << endl; } cout << "Scope 0: END" << endl; } Will output: Scope 0: BEGIN A::A(const boost::node_proxy&, const char*): a1 Scope 1: BEGIN A::A(const boost::node_proxy&, const char*): b1 A::A(const boost::node_proxy&, const char*): b2 A::~A(): a1 A::A(const boost::node_proxy&, const char*): b3 A::~A(): b2 Scope 1: END A::~A(): b1 A::~A(): b3 Scope 0: END Now here b1 got "upscaled" because it was once associated with a variable of a higher scope: a1 (closure in Javascript). And you can't downscale a variable to a lower scope so b1 will get destroyed in scope 0. Do you understand what I'm talking about? Thanks, -Phil