Small fix to enable_shared_from_this.adoc

This commit is contained in:
Peter Dimov
2017-06-13 02:51:02 +03:00
parent f770e53989
commit 5b7d3c08ab

View File

@ -125,16 +125,14 @@ NOTE: These members throw `bad_weak_ptr` when `*this` is not owned by a `shared_
`weak_this_` is initialized by `shared_ptr` to a copy of itself when it's constructed by a pointer to `*this`. `weak_this_` is initialized by `shared_ptr` to a copy of itself when it's constructed by a pointer to `*this`.
For example, in the following code: For example, in the following code:
``` ```
class Y: public boost::enable_shared_from_this<Y> class Y: public boost::enable_shared_from_this<Y> {};
{
};
int main() int main()
{ {
boost::shared_ptr<Y> p(new Y); boost::shared_ptr<Y> p(new Y);
} }
``` ```
the construction of `p` will automatically initialize `p->weak_this_` to `p`. the construction of `p` will automatically initialize `p\->weak_this_` to `p`.
==== ====
``` ```