1 | <?xml version="1.0" encoding="utf-8" ?> |
---|
2 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
---|
3 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
---|
4 | <head> |
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
---|
6 | <meta name="generator" content="Docutils 0.3.9: http://docutils.sourceforge.net/" /> |
---|
7 | <title>Boost Pointer Container Library</title> |
---|
8 | <link rel="stylesheet" href="default.css" type="text/css" /> |
---|
9 | </head> |
---|
10 | <body> |
---|
11 | <div class="document" id="boost-pointer-container-library"> |
---|
12 | <h1 class="title"><img alt="Boost" src="boost.png" /> Pointer Container Library</h1> |
---|
13 | <div class="section" id="class-ptr-array"> |
---|
14 | <h1><a name="class-ptr-array">Class <tt class="docutils literal"><span class="pre">ptr_array</span></tt></a></h1> |
---|
15 | <p>A <tt class="docutils literal"><span class="pre">ptr_array<T,size></span></tt> is a pointer container that uses an underlying <tt class="docutils literal"><span class="pre">boost::array<void*,size></span></tt> |
---|
16 | to store the pointers. The class is useful when there is no requirement |
---|
17 | of dynamic expansion and when absolute no overhead is tolerable.</p> |
---|
18 | <p><strong>See also:</strong></p> |
---|
19 | <ul class="simple"> |
---|
20 | <li><a class="reference" href="reversible_ptr_container.html">reversible_ptr_container</a></li> |
---|
21 | <li><a class="reference" href="ptr_sequence_adapter.html">ptr_sequence_adapter</a></li> |
---|
22 | <li><a class="reference" href="ptr_vector.html">ptr_vector</a></li> |
---|
23 | </ul> |
---|
24 | <p><strong>Navigate:</strong></p> |
---|
25 | <ul class="simple"> |
---|
26 | <li><a class="reference" href="ptr_container.html">home</a></li> |
---|
27 | <li><a class="reference" href="reference.html">reference</a></li> |
---|
28 | </ul> |
---|
29 | <p><strong>Synopsis:</strong></p> |
---|
30 | <pre class="literal-block"> |
---|
31 | namespace boost |
---|
32 | { |
---|
33 | |
---|
34 | template |
---|
35 | < |
---|
36 | class T, |
---|
37 | size_t N, |
---|
38 | CloneAllocator = heap_clone_allocator |
---|
39 | > |
---|
40 | class ptr_array : public <em>implementation-defined</em> |
---|
41 | { |
---|
42 | public: // <a class="reference" href="#construct-copy-destroy">construct/copy/destroy</a> |
---|
43 | ptr_array(); |
---|
44 | ptr_array( std::auto_ptr<ptr_array>& r ); |
---|
45 | |
---|
46 | public: // <a class="reference" href="reversible_ptr_container.html#iterators">iterators</a> |
---|
47 | |
---|
48 | public: // <a class="reference" href="reversible_ptr_container.html#capacity">capacity</a> |
---|
49 | |
---|
50 | public: // <a class="reference" href="#element-access">element access</a> |
---|
51 | T& front(); |
---|
52 | const T& front() const; |
---|
53 | T& back(); |
---|
54 | const T& back() const; |
---|
55 | |
---|
56 | template< size_t idx > |
---|
57 | T& at(); |
---|
58 | template< size_t idx > |
---|
59 | const T& at() const; |
---|
60 | T& at( size_t ); |
---|
61 | const T& at( size_t ); |
---|
62 | |
---|
63 | T& operator[]( size_t ); |
---|
64 | const T& operator[]( size_t ) const; |
---|
65 | |
---|
66 | public: // <a class="reference" href="#modifiers">modifiers</a> |
---|
67 | void swap( ptr_array& r ); |
---|
68 | |
---|
69 | template< size_t idx > |
---|
70 | auto_type replace( T* r ); |
---|
71 | auto_type replace( size_t idx, T* r ); |
---|
72 | |
---|
73 | public: // <a class="reference" href="#pointer-container-requirements">pointer container requirements</a> |
---|
74 | std::auto_ptr<ptr_array> clone() const; |
---|
75 | std::auto_ptr<ptr_array> release(); |
---|
76 | template< size_t idx > |
---|
77 | bool is_null() const; |
---|
78 | bool is_null( size_t idx ) const; |
---|
79 | |
---|
80 | }; // class 'ptr_sequence_adapter' |
---|
81 | |
---|
82 | } // namespace 'boost' |
---|
83 | </pre> |
---|
84 | </div> |
---|
85 | <div class="section" id="semantics"> |
---|
86 | <h1><a name="semantics">Semantics</a></h1> |
---|
87 | <span id="construct-copy-destroy"></span><div class="section" id="semantics-construct-copy-destroy"> |
---|
88 | <h2><a name="semantics-construct-copy-destroy">Semantics: construct/copy/destroy</a></h2> |
---|
89 | <ul> |
---|
90 | <li><p class="first"><tt class="docutils literal"><span class="pre">ptr_array();</span></tt></p> |
---|
91 | <blockquote> |
---|
92 | <ul class="simple"> |
---|
93 | <li>Effects: construct array where each element is null</li> |
---|
94 | </ul> |
---|
95 | </blockquote> |
---|
96 | </li> |
---|
97 | <li><p class="first"><tt class="docutils literal"><span class="pre">ptr_array(</span> <span class="pre">std::auto_ptr<ptr_array>&</span> <span class="pre">r</span> <span class="pre">);</span></tt></p> |
---|
98 | <blockquote> |
---|
99 | <ul class="simple"> |
---|
100 | <li>Effects: take ownership of the supplied pointers</li> |
---|
101 | </ul> |
---|
102 | </blockquote> |
---|
103 | </li> |
---|
104 | </ul> |
---|
105 | </div> |
---|
106 | <span id="element-access"></span><div class="section" id="semantics-element-access"> |
---|
107 | <h2><a name="semantics-element-access">Semantics: element access</a></h2> |
---|
108 | <ul> |
---|
109 | <li><p class="first"><tt class="docutils literal"><span class="pre">T&</span> <span class="pre">front();</span></tt></p> |
---|
110 | </li> |
---|
111 | <li><p class="first"><tt class="docutils literal"><span class="pre">const</span> <span class="pre">T&</span> <span class="pre">front()</span> <span class="pre">const;</span></tt></p> |
---|
112 | <blockquote> |
---|
113 | <ul class="simple"> |
---|
114 | <li>Requirements: <tt class="docutils literal"><span class="pre">not</span> <span class="pre">empty();</span></tt></li> |
---|
115 | <li>Effects: <tt class="docutils literal"><span class="pre">return</span> <span class="pre">*begin();</span></tt></li> |
---|
116 | <li>Throws: <tt class="docutils literal"><span class="pre">bad_ptr_container_operation</span></tt> if <tt class="docutils literal"><span class="pre">empty()</span> <span class="pre">==</span> <span class="pre">true</span></tt></li> |
---|
117 | </ul> |
---|
118 | </blockquote> |
---|
119 | </li> |
---|
120 | <li><p class="first"><tt class="docutils literal"><span class="pre">T&</span> <span class="pre">back();</span></tt></p> |
---|
121 | </li> |
---|
122 | <li><p class="first"><tt class="docutils literal"><span class="pre">const</span> <span class="pre">T&</span> <span class="pre">back()</span> <span class="pre">const;</span></tt></p> |
---|
123 | <blockquote> |
---|
124 | <ul class="simple"> |
---|
125 | <li>Requirements: <tt class="docutils literal"><span class="pre">not</span> <span class="pre">empty();</span></tt></li> |
---|
126 | <li>Effects: <tt class="docutils literal"><span class="pre">return</span> <span class="pre">*--end();</span></tt></li> |
---|
127 | <li>Throws: <tt class="docutils literal"><span class="pre">bad_ptr_container_operation</span></tt> if <tt class="docutils literal"><span class="pre">empty()</span> <span class="pre">==</span> <span class="pre">true</span></tt></li> |
---|
128 | </ul> |
---|
129 | </blockquote> |
---|
130 | </li> |
---|
131 | <li><p class="first"><tt class="docutils literal"><span class="pre">template<</span> <span class="pre">size_t</span> <span class="pre">idx</span> <span class="pre">></span> <span class="pre">T&</span> <span class="pre">at(</span> <span class="pre">size_type</span> <span class="pre">n</span> <span class="pre">);</span></tt></p> |
---|
132 | </li> |
---|
133 | <li><p class="first"><tt class="docutils literal"><span class="pre">template<</span> <span class="pre">size_t</span> <span class="pre">idx</span> <span class="pre">></span> <span class="pre">const</span> <span class="pre">T&</span> <span class="pre">at(</span> <span class="pre">size_type</span> <span class="pre">n</span> <span class="pre">)</span> <span class="pre">const;</span></tt></p> |
---|
134 | <blockquote> |
---|
135 | <ul class="simple"> |
---|
136 | <li>Requirements: <tt class="docutils literal"><span class="pre">idx</span> <span class="pre"><</span> <span class="pre">size()</span></tt> (compile-time enforced)</li> |
---|
137 | <li>Effects: Returns a reference to the <tt class="docutils literal"><span class="pre">n</span></tt>'th element</li> |
---|
138 | <li>Throws: nothing</li> |
---|
139 | </ul> |
---|
140 | </blockquote> |
---|
141 | </li> |
---|
142 | <li><p class="first"><tt class="docutils literal"><span class="pre">T&</span> <span class="pre">at(</span> <span class="pre">size_type</span> <span class="pre">n</span> <span class="pre">);</span></tt></p> |
---|
143 | </li> |
---|
144 | <li><p class="first"><tt class="docutils literal"><span class="pre">const</span> <span class="pre">T&</span> <span class="pre">at(</span> <span class="pre">size_type</span> <span class="pre">n</span> <span class="pre">)</span> <span class="pre">const;</span></tt></p> |
---|
145 | <blockquote> |
---|
146 | <ul class="simple"> |
---|
147 | <li>Requirements: <tt class="docutils literal"><span class="pre">n</span> <span class="pre"><</span> <span class="pre">size()</span></tt></li> |
---|
148 | <li>Effects: Returns a reference to the <tt class="docutils literal"><span class="pre">n</span></tt>'th element</li> |
---|
149 | <li>Throws: <tt class="docutils literal"><span class="pre">bad_index</span></tt> if <tt class="docutils literal"><span class="pre">n</span> <span class="pre">>=size()</span></tt></li> |
---|
150 | </ul> |
---|
151 | </blockquote> |
---|
152 | </li> |
---|
153 | <li><p class="first"><tt class="docutils literal"><span class="pre">T&</span> <span class="pre">operator[](</span> <span class="pre">size_type</span> <span class="pre">n</span> <span class="pre">);</span></tt></p> |
---|
154 | </li> |
---|
155 | <li><p class="first"><tt class="docutils literal"><span class="pre">const</span> <span class="pre">T&</span> <span class="pre">operator[](</span> <span class="pre">size_type</span> <span class="pre">n</span> <span class="pre">)</span> <span class="pre">const;</span></tt></p> |
---|
156 | <blockquote> |
---|
157 | <ul class="simple"> |
---|
158 | <li>Requirements: <tt class="docutils literal"><span class="pre">n</span> <span class="pre"><</span> <span class="pre">size()</span></tt></li> |
---|
159 | <li>Effects: Returns a reference to the <tt class="docutils literal"><span class="pre">n</span></tt>'th element</li> |
---|
160 | <li>Throws: Nothing</li> |
---|
161 | </ul> |
---|
162 | </blockquote> |
---|
163 | </li> |
---|
164 | </ul> |
---|
165 | </div> |
---|
166 | <span id="modifiers"></span><div class="section" id="semantics-modifiers"> |
---|
167 | <h2><a name="semantics-modifiers">Semantics: modifiers</a></h2> |
---|
168 | <ul> |
---|
169 | <li><p class="first"><tt class="docutils literal"><span class="pre">void</span> <span class="pre">swap(</span> <span class="pre">ptr_array&</span> <span class="pre">r</span> <span class="pre">);</span></tt></p> |
---|
170 | <blockquote> |
---|
171 | <ul class="simple"> |
---|
172 | <li>Effects: swaps the two arrays</li> |
---|
173 | <li>Complexity: Linear</li> |
---|
174 | <li>Throws: nothing</li> |
---|
175 | </ul> |
---|
176 | </blockquote> |
---|
177 | </li> |
---|
178 | <li><p class="first"><tt class="docutils literal"><span class="pre">template<</span> <span class="pre">size_t</span> <span class="pre">idx</span> <span class="pre">></span> <span class="pre">auto_type</span> <span class="pre">replace(</span> <span class="pre">T*</span> <span class="pre">r</span> <span class="pre">);</span></tt></p> |
---|
179 | <blockquote> |
---|
180 | <ul> |
---|
181 | <li><p class="first">Requirements:</p> |
---|
182 | <blockquote> |
---|
183 | <ul class="simple"> |
---|
184 | <li><tt class="docutils literal"><span class="pre">idx</span> <span class="pre"><</span> <span class="pre">size()</span></tt> (compile-time enforced)</li> |
---|
185 | <li><tt class="docutils literal"><span class="pre">r</span> <span class="pre">!=</span> <span class="pre">0</span></tt></li> |
---|
186 | </ul> |
---|
187 | </blockquote> |
---|
188 | </li> |
---|
189 | <li><p class="first">Effects: returns the object indexed by <tt class="docutils literal"><span class="pre">idx</span></tt> and replaces it with <tt class="docutils literal"><span class="pre">r</span></tt>.</p> |
---|
190 | </li> |
---|
191 | <li><p class="first">Throws: <tt class="docutils literal"><span class="pre">bad_pointer</span></tt> if <tt class="docutils literal"><span class="pre">x</span> <span class="pre">==</span> <span class="pre">0</span></tt>.</p> |
---|
192 | </li> |
---|
193 | <li><p class="first">Exception safety: Strong guarantee</p> |
---|
194 | </li> |
---|
195 | </ul> |
---|
196 | </blockquote> |
---|
197 | </li> |
---|
198 | <li><p class="first"><tt class="docutils literal"><span class="pre">auto_type</span> <span class="pre">replace(</span> <span class="pre">size_t</span> <span class="pre">idx,</span> <span class="pre">T*</span> <span class="pre">r</span> <span class="pre">);</span></tt></p> |
---|
199 | <blockquote> |
---|
200 | <ul class="simple"> |
---|
201 | <li>Requirements: `` x != 0 and idx < size()``</li> |
---|
202 | <li>Effects: returns the object indexed by <tt class="docutils literal"><span class="pre">idx</span></tt> and replaces it with <tt class="docutils literal"><span class="pre">x</span></tt>.</li> |
---|
203 | <li>Throws: <tt class="docutils literal"><span class="pre">bad_index</span></tt> if <tt class="docutils literal"><span class="pre">idx</span> <span class="pre">>=</span> <span class="pre">size()</span></tt> and <tt class="docutils literal"><span class="pre">bad_pointer</span></tt> if <tt class="docutils literal"><span class="pre">x</span> <span class="pre">==</span> <span class="pre">0</span></tt>.</li> |
---|
204 | <li>Exception safety: Strong guarantee</li> |
---|
205 | </ul> |
---|
206 | </blockquote> |
---|
207 | </li> |
---|
208 | </ul> |
---|
209 | </div> |
---|
210 | <span id="pointer-container-requirements"></span><div class="section" id="semantics-pointer-container-requirements"> |
---|
211 | <h2><a name="semantics-pointer-container-requirements">Semantics: pointer container requirements</a></h2> |
---|
212 | <ul> |
---|
213 | <li><p class="first"><tt class="docutils literal"><span class="pre">std::auto_ptr<ptr_array></span> <span class="pre">clone()</span> <span class="pre">const;</span></tt></p> |
---|
214 | <blockquote> |
---|
215 | <ul class="simple"> |
---|
216 | <li>Effects: Returns a deep copy of the container</li> |
---|
217 | <li>Throws: <tt class="docutils literal"><span class="pre">std::bad_alloc</span></tt> if there is not enough memory to make a clone of the container</li> |
---|
218 | <li>Complexity: Linear</li> |
---|
219 | </ul> |
---|
220 | </blockquote> |
---|
221 | </li> |
---|
222 | <li><p class="first"><tt class="docutils literal"><span class="pre">std::auto_ptr<ptr_array></span> <span class="pre">release();</span></tt></p> |
---|
223 | <blockquote> |
---|
224 | <ul class="simple"> |
---|
225 | <li>Effects: Releases ownership of the container. This is a useful way of returning a container from a function.</li> |
---|
226 | <li>Postconditions: <tt class="docutils literal"><span class="pre">empty()</span> <span class="pre">==</span> <span class="pre">true</span></tt> and all pointers are null</li> |
---|
227 | <li>Throws: <tt class="docutils literal"><span class="pre">std::bad_alloc</span></tt> if the return value cannot be allocated</li> |
---|
228 | <li>Exception safety: Strong guarantee</li> |
---|
229 | </ul> |
---|
230 | </blockquote> |
---|
231 | </li> |
---|
232 | <li><p class="first"><tt class="docutils literal"><span class="pre">template<</span> <span class="pre">size_t</span> <span class="pre">idx</span> <span class="pre">></span> <span class="pre">bool</span> <span class="pre">is_null()</span> <span class="pre">const;</span></tt></p> |
---|
233 | <blockquote> |
---|
234 | <ul class="simple"> |
---|
235 | <li>Requirements: <tt class="docutils literal"><span class="pre">idx</span> <span class="pre"><</span> <span class="pre">size()</span></tt> (compile-time enforced)</li> |
---|
236 | <li>Effects: returns whether the pointer at index <tt class="docutils literal"><span class="pre">idx</span></tt> is null</li> |
---|
237 | <li>Exception safety: Nothrow guarantee</li> |
---|
238 | </ul> |
---|
239 | </blockquote> |
---|
240 | </li> |
---|
241 | <li><p class="first"><tt class="docutils literal"><span class="pre">bool</span> <span class="pre">is_null(</span> <span class="pre">size_type</span> <span class="pre">idx</span> <span class="pre">)</span> <span class="pre">const;</span></tt></p> |
---|
242 | <blockquote> |
---|
243 | <ul class="simple"> |
---|
244 | <li>Requirements: <tt class="docutils literal"><span class="pre">idx</span> <span class="pre"><</span> <span class="pre">size()</span></tt></li> |
---|
245 | <li>Effects: returns whether the pointer at index <tt class="docutils literal"><span class="pre">idx</span></tt> is null</li> |
---|
246 | <li>Exception safety: Nothrow guarantee</li> |
---|
247 | </ul> |
---|
248 | </blockquote> |
---|
249 | </li> |
---|
250 | </ul> |
---|
251 | <table class="docutils field-list" frame="void" rules="none"> |
---|
252 | <col class="field-name" /> |
---|
253 | <col class="field-body" /> |
---|
254 | <tbody valign="top"> |
---|
255 | <tr class="field"><th class="field-name">copyright:</th><td class="field-body">Thorsten Ottosen 2004-2005.</td> |
---|
256 | </tr> |
---|
257 | </tbody> |
---|
258 | </table> |
---|
259 | </div> |
---|
260 | </div> |
---|
261 | </div> |
---|
262 | </body> |
---|
263 | </html> |
---|