How to attach boost::shared_ptr (or another smart pointer) to reference counter of object's parent?
- by Checkers
I remember encountering this concept before, but can't find it in Google now.
If I have an object of type A, which directly embeds an object of type B:
class A {
B b;
};
How can I have a smart pointer to B, e. g. boost::shared_ptr<B>, but use reference count of A? Assume an instance of A itself is heap-allocated I can safely get its shared count using, say, enable_shared_from_this.