I'm trying to use boost::shared_ptr and boost::enable_shared_from_this to no avail. It looks as if shared_from_this() is returning the wrong shared_ptr. Here is what I see:
Task* task = new TaskSubClass();
boost::shared_ptr<Task> first = boost::shared_ptr<Task>(task); // use_count = 1, weak_count = 1
boost::shared_ptr<Task> second = first; // use_count = 2, weak_count = 1
boost::shared_ptr<Task> third = first->shared_from_this(); // use_count = 2, weak_count = 2
I also noticed that first.px=third.px
but first.pn.pi!=third.pn.pi
. That is, they both share the same object but they use a different counter. How can I get the two to share the same counter?