tmp/tmp2z2ds28g/{from.md → to.md}
RENAMED
|
@@ -1,194 +0,0 @@
|
|
| 1 |
-
## `auto_ptr` <a id="depr.auto.ptr">[[depr.auto.ptr]]</a>
|
| 2 |
-
|
| 3 |
-
The class template `auto_ptr` is deprecated. The class template
|
| 4 |
-
`unique_ptr` ([[unique.ptr]]) provides a better solution.
|
| 5 |
-
|
| 6 |
-
### Class template `auto_ptr` <a id="auto.ptr">[[auto.ptr]]</a>
|
| 7 |
-
|
| 8 |
-
The class template `auto_ptr` stores a pointer to an object obtained via
|
| 9 |
-
`new` and deletes that object when it itself is destroyed (such as when
|
| 10 |
-
leaving block scope [[stmt.dcl]]).
|
| 11 |
-
|
| 12 |
-
The class template `auto_ptr_ref` is for exposition only. An
|
| 13 |
-
implementation is permitted to provide equivalent functionality without
|
| 14 |
-
providing a template with this name. The template holds a reference to
|
| 15 |
-
an `auto_ptr`. It is used by the `auto_ptr` conversions to allow
|
| 16 |
-
`auto_ptr` objects to be passed to and returned from functions.
|
| 17 |
-
|
| 18 |
-
``` cpp
|
| 19 |
-
namespace std {
|
| 20 |
-
template <class Y> struct auto_ptr_ref; // exposition only
|
| 21 |
-
|
| 22 |
-
template <class X> class auto_ptr {
|
| 23 |
-
public:
|
| 24 |
-
typedef X element_type;
|
| 25 |
-
|
| 26 |
-
// [auto.ptr.cons] construct/copy/destroy:
|
| 27 |
-
explicit auto_ptr(X* p =0) throw();
|
| 28 |
-
auto_ptr(auto_ptr&) throw();
|
| 29 |
-
template<class Y> auto_ptr(auto_ptr<Y>&) throw();
|
| 30 |
-
auto_ptr& operator=(auto_ptr&) throw();
|
| 31 |
-
template<class Y> auto_ptr& operator=(auto_ptr<Y>&) throw();
|
| 32 |
-
auto_ptr& operator=(auto_ptr_ref<X> r) throw();
|
| 33 |
-
~auto_ptr() throw();
|
| 34 |
-
|
| 35 |
-
// [auto.ptr.members] members:
|
| 36 |
-
X& operator*() const throw();
|
| 37 |
-
X* operator->() const throw();
|
| 38 |
-
X* get() const throw();
|
| 39 |
-
X* release() throw();
|
| 40 |
-
void reset(X* p =0) throw();
|
| 41 |
-
|
| 42 |
-
// [auto.ptr.conv] conversions:
|
| 43 |
-
auto_ptr(auto_ptr_ref<X>) throw();
|
| 44 |
-
template<class Y> operator auto_ptr_ref<Y>() throw();
|
| 45 |
-
template<class Y> operator auto_ptr<Y>() throw();
|
| 46 |
-
};
|
| 47 |
-
|
| 48 |
-
template <> class auto_ptr<void>
|
| 49 |
-
{
|
| 50 |
-
public:
|
| 51 |
-
typedef void element_type;
|
| 52 |
-
};
|
| 53 |
-
}
|
| 54 |
-
```
|
| 55 |
-
|
| 56 |
-
The class template `auto_ptr` provides a semantics of strict ownership.
|
| 57 |
-
An `auto_ptr` owns the object it holds a pointer to. Copying an
|
| 58 |
-
`auto_ptr` copies the pointer and transfers ownership to the
|
| 59 |
-
destination. If more than one `auto_ptr` owns the same object at the
|
| 60 |
-
same time the behavior of the program is undefined. The uses of
|
| 61 |
-
`auto_ptr` include providing temporary exception-safety for dynamically
|
| 62 |
-
allocated memory, passing ownership of dynamically allocated memory to a
|
| 63 |
-
function, and returning dynamically allocated memory from a function.
|
| 64 |
-
Instances of `auto_ptr` meet the requirements of `MoveConstructible` and
|
| 65 |
-
`MoveAssignable`, but do not meet the requirements of
|
| 66 |
-
`CopyConstructible` and `CopyAssignable`.
|
| 67 |
-
|
| 68 |
-
#### `auto_ptr` constructors <a id="auto.ptr.cons">[[auto.ptr.cons]]</a>
|
| 69 |
-
|
| 70 |
-
``` cpp
|
| 71 |
-
explicit auto_ptr(X* p =0) throw();
|
| 72 |
-
```
|
| 73 |
-
|
| 74 |
-
*Postconditions:* `*this` holds the pointer `p`.
|
| 75 |
-
|
| 76 |
-
``` cpp
|
| 77 |
-
auto_ptr(auto_ptr& a) throw();
|
| 78 |
-
```
|
| 79 |
-
|
| 80 |
-
*Effects:* Calls `a.release()`.
|
| 81 |
-
|
| 82 |
-
*Postconditions:* `*this` holds the pointer returned from `a.release()`.
|
| 83 |
-
|
| 84 |
-
``` cpp
|
| 85 |
-
template<class Y> auto_ptr(auto_ptr<Y>& a) throw();
|
| 86 |
-
```
|
| 87 |
-
|
| 88 |
-
*Requires:* `Y*` can be implicitly converted to `X*`.
|
| 89 |
-
|
| 90 |
-
*Effects:* Calls `a.release()`.
|
| 91 |
-
|
| 92 |
-
*Postconditions:* `*this` holds the pointer returned from `a.release()`.
|
| 93 |
-
|
| 94 |
-
``` cpp
|
| 95 |
-
auto_ptr& operator=(auto_ptr& a) throw();
|
| 96 |
-
```
|
| 97 |
-
|
| 98 |
-
*Requires:* The expression `delete get()` is well formed.
|
| 99 |
-
|
| 100 |
-
*Effects:* `reset(a.release())`.
|
| 101 |
-
|
| 102 |
-
*Returns:* `*this`.
|
| 103 |
-
|
| 104 |
-
``` cpp
|
| 105 |
-
template<class Y> auto_ptr& operator=(auto_ptr<Y>& a) throw();
|
| 106 |
-
```
|
| 107 |
-
|
| 108 |
-
*Requires:* `Y*` can be implicitly converted to `X*`. The expression
|
| 109 |
-
`delete get()` is well formed.
|
| 110 |
-
|
| 111 |
-
*Effects:* `reset(a.release())`.
|
| 112 |
-
|
| 113 |
-
*Returns:* `*this`.
|
| 114 |
-
|
| 115 |
-
``` cpp
|
| 116 |
-
~auto_ptr() throw();
|
| 117 |
-
```
|
| 118 |
-
|
| 119 |
-
*Requires:* The expression `delete get()` is well formed.
|
| 120 |
-
|
| 121 |
-
*Effects:* `delete get()`.
|
| 122 |
-
|
| 123 |
-
#### `auto_ptr` members <a id="auto.ptr.members">[[auto.ptr.members]]</a>
|
| 124 |
-
|
| 125 |
-
``` cpp
|
| 126 |
-
X& operator*() const throw();
|
| 127 |
-
```
|
| 128 |
-
|
| 129 |
-
*Requires:* `get() != 0`
|
| 130 |
-
|
| 131 |
-
*Returns:* `*get()`
|
| 132 |
-
|
| 133 |
-
``` cpp
|
| 134 |
-
X* operator->() const throw();
|
| 135 |
-
```
|
| 136 |
-
|
| 137 |
-
*Returns:* `get()`
|
| 138 |
-
|
| 139 |
-
``` cpp
|
| 140 |
-
X* get() const throw();
|
| 141 |
-
```
|
| 142 |
-
|
| 143 |
-
*Returns:* The pointer `*this` holds.
|
| 144 |
-
|
| 145 |
-
``` cpp
|
| 146 |
-
X* release() throw();
|
| 147 |
-
```
|
| 148 |
-
|
| 149 |
-
*Returns:* `get()`
|
| 150 |
-
|
| 151 |
-
`*this` holds the null pointer.
|
| 152 |
-
|
| 153 |
-
``` cpp
|
| 154 |
-
void reset(X* p=0) throw();
|
| 155 |
-
```
|
| 156 |
-
|
| 157 |
-
*Effects:* If `get() != p` then `delete get()`.
|
| 158 |
-
|
| 159 |
-
*Postconditions:* `*this` holds the pointer `p`.
|
| 160 |
-
|
| 161 |
-
#### `auto_ptr` conversions <a id="auto.ptr.conv">[[auto.ptr.conv]]</a>
|
| 162 |
-
|
| 163 |
-
``` cpp
|
| 164 |
-
auto_ptr(auto_ptr_ref<X> r) throw();
|
| 165 |
-
```
|
| 166 |
-
|
| 167 |
-
*Effects:* Calls `p.release()` for the `auto_ptr` `p` that `r` holds.
|
| 168 |
-
|
| 169 |
-
*Postconditions:* `*this` holds the pointer returned from `release()`.
|
| 170 |
-
|
| 171 |
-
``` cpp
|
| 172 |
-
template<class Y> operator auto_ptr_ref<Y>() throw();
|
| 173 |
-
```
|
| 174 |
-
|
| 175 |
-
*Returns:* An `auto_ptr_ref<Y>` that holds `*this`.
|
| 176 |
-
|
| 177 |
-
``` cpp
|
| 178 |
-
template<class Y> operator auto_ptr<Y>() throw();
|
| 179 |
-
```
|
| 180 |
-
|
| 181 |
-
*Effects:* Calls `release()`.
|
| 182 |
-
|
| 183 |
-
*Returns:* An `auto_ptr<Y>` that holds the pointer returned from
|
| 184 |
-
`release()`.
|
| 185 |
-
|
| 186 |
-
``` cpp
|
| 187 |
-
auto_ptr& operator=(auto_ptr_ref<X> r) throw()
|
| 188 |
-
```
|
| 189 |
-
|
| 190 |
-
*Effects:* Calls `reset(p.release())` for the `auto_ptr p` that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