|
Boost Users : |
Subject: Re: [Boost-users] shared_ptr design question
From: Igor R (boost.lists_at_[hidden])
Date: 2011-09-20 12:12:05
> 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.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net