
20 Sep
2011
20 Sep
'11
4:12 p.m.
Very much that, yes.
shared_ptr<outer> o = make_shared<outer>(); shared_ptr<inner> i = shared_ptr<inner>(o, &o->i);
The aliasing ctor holds the second pointer argument, while using the refcounting of the first argument.
There's no restriction that the pointer has to be to inside the object at all, but it tends to be the common use case.
Wow! I never payed attention to that ctor. Great feature. I think it's worth to be highlighted somewhere in the docs. Thanks.