mirror of
https://github.com/boostorg/smart_ptr.git
synced 2025-07-31 13:17:23 +02:00
Small fix to enable_shared_from_this.adoc
This commit is contained in:
@ -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`.
|
||||||
====
|
====
|
||||||
|
|
||||||
```
|
```
|
||||||
|
Reference in New Issue
Block a user