tmp/tmpjvxlid77/{from.md → to.md}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
-
#### Casts <a id="util.smartptr.shared.cast">[[util.smartptr.shared.cast]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
template<class T, class U>
|
| 5 |
shared_ptr<T> static_pointer_cast(const shared_ptr<U>& r) noexcept;
|
| 6 |
template<class T, class U>
|
|
@@ -17,11 +17,11 @@ shared_ptr<T>(R, static_cast<typename shared_ptr<T>::element_type*>(r.get()))
|
|
| 17 |
```
|
| 18 |
|
| 19 |
where *`R`* is `r` for the first overload, and `std::move(r)` for the
|
| 20 |
second.
|
| 21 |
|
| 22 |
-
[*Note
|
| 23 |
`shared_ptr<T>(static_cast<T*>(r.get()))` will eventually result in
|
| 24 |
undefined behavior, attempting to delete the same object
|
| 25 |
twice. — *end note*]
|
| 26 |
|
| 27 |
``` cpp
|
|
@@ -31,12 +31,12 @@ template<class T, class U>
|
|
| 31 |
shared_ptr<T> dynamic_pointer_cast(shared_ptr<U>&& r) noexcept;
|
| 32 |
```
|
| 33 |
|
| 34 |
*Mandates:* The expression `dynamic_cast<T*>((U*)nullptr)` is
|
| 35 |
well-formed. The expression
|
| 36 |
-
`dynamic_cast<typename shared_ptr<T>::element_type*>(r.get())` is
|
| 37 |
-
formed.
|
| 38 |
|
| 39 |
*Preconditions:* The expression
|
| 40 |
`dynamic_cast<typename shared_ptr<T>::element_type*>(r.get())` has
|
| 41 |
well-defined behavior.
|
| 42 |
|
|
@@ -45,11 +45,11 @@ well-defined behavior.
|
|
| 45 |
- When `dynamic_cast<typename shared_ptr<T>::element_type*>(r.get())`
|
| 46 |
returns a non-null value `p`, `shared_ptr<T>(`*`R`*`, p)`, where *`R`*
|
| 47 |
is `r` for the first overload, and `std::move(r)` for the second.
|
| 48 |
- Otherwise, `shared_ptr<T>()`.
|
| 49 |
|
| 50 |
-
[*Note
|
| 51 |
`shared_ptr<T>(dynamic_cast<T*>(r.get()))` will eventually result in
|
| 52 |
undefined behavior, attempting to delete the same object
|
| 53 |
twice. — *end note*]
|
| 54 |
|
| 55 |
``` cpp
|
|
@@ -68,11 +68,11 @@ shared_ptr<T>(R, const_cast<typename shared_ptr<T>::element_type*>(r.get()))
|
|
| 68 |
```
|
| 69 |
|
| 70 |
where *`R`* is `r` for the first overload, and `std::move(r)` for the
|
| 71 |
second.
|
| 72 |
|
| 73 |
-
[*Note
|
| 74 |
`shared_ptr<T>(const_cast<T*>(r.get()))` will eventually result in
|
| 75 |
undefined behavior, attempting to delete the same object
|
| 76 |
twice. — *end note*]
|
| 77 |
|
| 78 |
``` cpp
|
|
@@ -92,10 +92,10 @@ shared_ptr<T>(R, reinterpret_cast<typename shared_ptr<T>::element_type*>(r.get()
|
|
| 92 |
```
|
| 93 |
|
| 94 |
where *`R`* is `r` for the first overload, and `std::move(r)` for the
|
| 95 |
second.
|
| 96 |
|
| 97 |
-
[*Note
|
| 98 |
`shared_ptr<T>(reinterpret_cast<T*>(r.get()))` will eventually result in
|
| 99 |
undefined behavior, attempting to delete the same object
|
| 100 |
twice. — *end note*]
|
| 101 |
|
|
|
|
| 1 |
+
##### Casts <a id="util.smartptr.shared.cast">[[util.smartptr.shared.cast]]</a>
|
| 2 |
|
| 3 |
``` cpp
|
| 4 |
template<class T, class U>
|
| 5 |
shared_ptr<T> static_pointer_cast(const shared_ptr<U>& r) noexcept;
|
| 6 |
template<class T, class U>
|
|
|
|
| 17 |
```
|
| 18 |
|
| 19 |
where *`R`* is `r` for the first overload, and `std::move(r)` for the
|
| 20 |
second.
|
| 21 |
|
| 22 |
+
[*Note 9*: The seemingly equivalent expression
|
| 23 |
`shared_ptr<T>(static_cast<T*>(r.get()))` will eventually result in
|
| 24 |
undefined behavior, attempting to delete the same object
|
| 25 |
twice. — *end note*]
|
| 26 |
|
| 27 |
``` cpp
|
|
|
|
| 31 |
shared_ptr<T> dynamic_pointer_cast(shared_ptr<U>&& r) noexcept;
|
| 32 |
```
|
| 33 |
|
| 34 |
*Mandates:* The expression `dynamic_cast<T*>((U*)nullptr)` is
|
| 35 |
well-formed. The expression
|
| 36 |
+
`dynamic_cast<typename shared_ptr<T>::element_type*>(r.get())` is
|
| 37 |
+
well-formed.
|
| 38 |
|
| 39 |
*Preconditions:* The expression
|
| 40 |
`dynamic_cast<typename shared_ptr<T>::element_type*>(r.get())` has
|
| 41 |
well-defined behavior.
|
| 42 |
|
|
|
|
| 45 |
- When `dynamic_cast<typename shared_ptr<T>::element_type*>(r.get())`
|
| 46 |
returns a non-null value `p`, `shared_ptr<T>(`*`R`*`, p)`, where *`R`*
|
| 47 |
is `r` for the first overload, and `std::move(r)` for the second.
|
| 48 |
- Otherwise, `shared_ptr<T>()`.
|
| 49 |
|
| 50 |
+
[*Note 10*: The seemingly equivalent expression
|
| 51 |
`shared_ptr<T>(dynamic_cast<T*>(r.get()))` will eventually result in
|
| 52 |
undefined behavior, attempting to delete the same object
|
| 53 |
twice. — *end note*]
|
| 54 |
|
| 55 |
``` cpp
|
|
|
|
| 68 |
```
|
| 69 |
|
| 70 |
where *`R`* is `r` for the first overload, and `std::move(r)` for the
|
| 71 |
second.
|
| 72 |
|
| 73 |
+
[*Note 11*: The seemingly equivalent expression
|
| 74 |
`shared_ptr<T>(const_cast<T*>(r.get()))` will eventually result in
|
| 75 |
undefined behavior, attempting to delete the same object
|
| 76 |
twice. — *end note*]
|
| 77 |
|
| 78 |
``` cpp
|
|
|
|
| 92 |
```
|
| 93 |
|
| 94 |
where *`R`* is `r` for the first overload, and `std::move(r)` for the
|
| 95 |
second.
|
| 96 |
|
| 97 |
+
[*Note 12*: The seemingly equivalent expression
|
| 98 |
`shared_ptr<T>(reinterpret_cast<T*>(r.get()))` will eventually result in
|
| 99 |
undefined behavior, attempting to delete the same object
|
| 100 |
twice. — *end note*]
|
| 101 |
|