From Jason Turner

[util.smartptr.shared.cast]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpwm2rmc45/{from.md → to.md} +14 -18
tmp/tmpwm2rmc45/{from.md → to.md} RENAMED
@@ -1,12 +1,12 @@
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>
7
- shared_ptr<T> static_pointer_cast(shared_ptr<U>&& r) noexcept;
8
  ```
9
 
10
  *Mandates:* The expression `static_cast<T*>((U*)nullptr)` is
11
  well-formed.
12
 
@@ -18,19 +18,18 @@ shared_ptr<T>(R, static_cast<typename shared_ptr<T>::element_type*>(r.get()))
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
28
  template<class T, class U>
29
- shared_ptr<T> dynamic_pointer_cast(const shared_ptr<U>& r) noexcept;
30
  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
@@ -46,19 +45,18 @@ well-defined behavior.
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
56
  template<class T, class U>
57
- shared_ptr<T> const_pointer_cast(const shared_ptr<U>& r) noexcept;
58
  template<class T, class U>
59
- shared_ptr<T> const_pointer_cast(shared_ptr<U>&& r) noexcept;
60
  ```
61
 
62
  *Mandates:* The expression `const_cast<T*>((U*)nullptr)` is well-formed.
63
 
64
  *Returns:*
@@ -69,13 +67,12 @@ shared_ptr<T>(R, const_cast<typename shared_ptr<T>::element_type*>(r.get()))
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
79
  template<class T, class U>
80
  shared_ptr<T> reinterpret_pointer_cast(const shared_ptr<U>& r) noexcept;
81
  template<class T, class U>
@@ -93,9 +90,8 @@ shared_ptr<T>(R, reinterpret_cast<typename shared_ptr<T>::element_type*>(r.get()
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
 
 
1
  ##### Casts <a id="util.smartptr.shared.cast">[[util.smartptr.shared.cast]]</a>
2
 
3
  ``` cpp
4
  template<class T, class U>
5
+ constexpr shared_ptr<T> static_pointer_cast(const shared_ptr<U>& r) noexcept;
6
  template<class T, class U>
7
+ constexpr shared_ptr<T> static_pointer_cast(shared_ptr<U>&& r) noexcept;
8
  ```
9
 
10
  *Mandates:* The expression `static_cast<T*>((U*)nullptr)` is
11
  well-formed.
12
 
 
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()))` can result in undefined
24
+ behavior, attempting to delete the same object twice. — *end note*]
 
25
 
26
  ``` cpp
27
  template<class T, class U>
28
+ constexpr shared_ptr<T> dynamic_pointer_cast(const shared_ptr<U>& r) noexcept;
29
  template<class T, class U>
30
+ constexpr shared_ptr<T> dynamic_pointer_cast(shared_ptr<U>&& r) noexcept;
31
  ```
32
 
33
  *Mandates:* The expression `dynamic_cast<T*>((U*)nullptr)` is
34
  well-formed. The expression
35
  `dynamic_cast<typename shared_ptr<T>::element_type*>(r.get())` is
 
45
  returns a non-null value `p`, `shared_ptr<T>(`*`R`*`, p)`, where *`R`*
46
  is `r` for the first overload, and `std::move(r)` for the second.
47
  - Otherwise, `shared_ptr<T>()`.
48
 
49
  [*Note 10*: The seemingly equivalent expression
50
+ `shared_ptr<T>(dynamic_cast<T*>(r.get()))` can result in undefined
51
+ behavior, attempting to delete the same object twice. — *end note*]
 
52
 
53
  ``` cpp
54
  template<class T, class U>
55
+ constexpr shared_ptr<T> const_pointer_cast(const shared_ptr<U>& r) noexcept;
56
  template<class T, class U>
57
+ constexpr shared_ptr<T> const_pointer_cast(shared_ptr<U>&& r) noexcept;
58
  ```
59
 
60
  *Mandates:* The expression `const_cast<T*>((U*)nullptr)` is well-formed.
61
 
62
  *Returns:*
 
67
 
68
  where *`R`* is `r` for the first overload, and `std::move(r)` for the
69
  second.
70
 
71
  [*Note 11*: The seemingly equivalent expression
72
+ `shared_ptr<T>(const_cast<T*>(r.get()))` can result in undefined
73
+ behavior, attempting to delete the same object twice. — *end note*]
 
74
 
75
  ``` cpp
76
  template<class T, class U>
77
  shared_ptr<T> reinterpret_pointer_cast(const shared_ptr<U>& r) noexcept;
78
  template<class T, class U>
 
90
 
91
  where *`R`* is `r` for the first overload, and `std::move(r)` for the
92
  second.
93
 
94
  [*Note 12*: The seemingly equivalent expression
95
+ `shared_ptr<T>(reinterpret_cast<T*>(r.get()))` can result in undefined
96
+ behavior, attempting to delete the same object twice. — *end note*]
 
97