From Jason Turner

[auto.ptr]

Diff to HTML by rtfpessoa

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