1 ++++++++++++++++++++++++++++++++++
2 |Boost| Pointer Container Library
3 ++++++++++++++++++++++++++++++++++
5 .. |Boost| image:: boost.png
10 A ``ptr_array<T,size>`` is a pointer container that uses an underlying ``boost::array<void*,size>``
11 to store the pointers. The class is useful when there is no requirement
12 of dynamic expansion and when no overhead is tolerable.
16 - `reversible_ptr_container <reversible_ptr_container.html>`_
18 - `ptr_sequence_adapter <ptr_sequence_adapter.html>`_
20 - `ptr_vector <ptr_vector.html>`_
21 - `ptr_list <ptr_list.html>`_
22 - `ptr_deque <ptr_deque.html>`_
27 - `home <ptr_container.html>`_
28 - `reference <reference.html>`_
43 CloneAllocator = heap_clone_allocator
45 class ptr_array : public *implementation-defined*
47 public: // `construct/copy/destroy`_
49 explicit ptr_array( const ptr_array& r );
51 explicit ptr_array( const ptr_array<U,N>& r );
52 explicit ptr_array( std::auto_ptr<ptr_array>& r );
54 ptr_array& operator=( const ptr_array& r );
56 ptr_array& operator=( const ptr_array<U,N>& r );
57 ptr_array& operator=( std::auto_ptr<this_type> r );
59 public: // `iterators`_
61 public: // `capacity`_
63 public: // `element access`_
65 const T& front() const;
67 const T& back() const;
69 template< size_t idx >
71 template< size_t idx >
74 const T& at( size_t );
76 T& operator[]( size_t );
77 const T& operator[]( size_t ) const;
79 public: // `modifiers`_
80 void swap( ptr_array& r );
82 template< size_t idx >
83 auto_type replace( T* r );
84 template< size_t idx, class U >
85 auto_type replace( std::auto_ptr<U> r );
86 auto_type replace( size_t idx, T* r );
88 auto_type replace( size_t idx, std::auto_ptr<U> r );
90 public: // `pointer container requirements`_
91 std::auto_ptr<ptr_array> clone() const;
92 std::auto_ptr<ptr_array> release();
93 template< size_t idx >
95 bool is_null( size_t idx ) const;
97 }; // class 'ptr_sequence_adapter'
99 } // namespace 'boost'
101 .. _iterators: reversible_ptr_container.html#iterators
103 .. _capacity: reversible_ptr_container.html#capacity
105 .. _`inherited element access`: reversible_ptr_container.html#element-access
110 .. _`construct/copy/destroy`:
112 Semantics: construct/copy/destroy
113 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
117 - Effects: constructs array where each element is null
119 - ``explicit ptr_array( const ptr_array& r );``
120 - ``template< class U >
121 explicit ptr_array( const ptr_array<U,N>& r );``
123 - Effects: Constructs array by cloning ``r``
125 - ``ptr_array( std::auto_ptr<ptr_array>& r );``
127 - Effects: take ownership of the supplied pointers
129 - ``ptr_array& operator=( const ptr_array& r );``
131 - ``template< class U > ptr_array& operator=( const ptr_array<U,N>& r );``
133 - Effects: Assigns a clone of ``r``
135 - Exception safety: Strong guarantee
137 - ``ptr_array& operator=( std::auto_ptr<this_type> r );``
139 - Effects: take ownership of the supplied pointers
143 .. _`element access`:
145 Semantics: element access
146 ^^^^^^^^^^^^^^^^^^^^^^^^^
150 - ``const T& front() const;``
152 - Requirements: ``not empty();``
154 - Effects: ``return *begin();``
156 - Throws: ``bad_ptr_container_operation`` if ``empty() == true``
160 - ``const T& back() const;``
162 - Requirements: ``not empty();``
164 - Effects: ``return *--end();``
166 - Throws: ``bad_ptr_container_operation`` if ``empty() == true``
168 - ``template< size_t idx > T& at( size_type n );``
169 - ``template< size_t idx > const T& at( size_type n ) const;``
171 - Requirements: ``idx < size()`` (compile-time enforced)
173 - Effects: Returns a reference to the ``n``'th element
177 - ``T& at( size_type n );``
178 - ``const T& at( size_type n ) const;``
180 - Requirements: ``n < size()``
182 - Effects: Returns a reference to the ``n``'th element
184 - Throws: ``bad_index`` if ``n >=size()``
187 - ``T& operator[]( size_type n );``
188 - ``const T& operator[]( size_type n ) const;``
190 - Requirements: ``n < size()``
192 - Effects: Returns a reference to the ``n``'th element
202 - ``void swap( ptr_array& r );``
204 - Effects: swaps the two arrays
210 - ``template< size_t idx > auto_type replace( T* r );``
214 - ``idx < size()`` (compile-time enforced)
217 - Effects: returns the object indexed by ``idx`` and replaces it with ``r``.
219 - Throws: ``bad_pointer`` if ``x == 0``.
221 - Exception safety: Strong guarantee
223 - ``template< size_t idx, class U > auto_type replace( std::auto_ptr<U> r );``
225 - Effects: ``return replace<idx>( r.release() );``
227 - ``auto_type replace( size_t idx, T* r );``
229 - Requirements: `` x != 0 and idx < size()``
231 - Effects: returns the object indexed by ``idx`` and replaces it with ``x``.
233 - Throws: ``bad_index`` if ``idx >= size()`` and ``bad_pointer`` if ``x == 0``.
235 - Exception safety: Strong guarantee
237 - ``template< class U > auto_type replace( size_t idx, std::auto_ptr<U> r );``
239 - Effects: ``return replace( idx, r.release() );``
241 .. _`pointer container requirements`:
243 Semantics: pointer container requirements
244 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
246 - ``std::auto_ptr<ptr_array> clone() const;``
248 - Effects: Returns a deep copy of the container
250 - Throws: ``std::bad_alloc`` if there is not enough memory to make a clone of the container
255 - ``std::auto_ptr<ptr_array> release();``
257 - Effects: Releases ownership of the container. This is a useful way of returning a container from a function.
259 - Postconditions: ``empty() == true`` and all pointers are null
261 - Throws: ``std::bad_alloc`` if the return value cannot be allocated
263 - Exception safety: Strong guarantee
266 - ``template< size_t idx > bool is_null() const;``
268 - Requirements: ``idx < size()`` (compile-time enforced)
270 - Effects: returns whether the pointer at index ``idx`` is null
272 - Exception safety: Nothrow guarantee
274 - ``bool is_null( size_type idx ) const;``
276 - Requirements: ``idx < size()``
278 - Effects: returns whether the pointer at index ``idx`` is null
280 - Exception safety: Nothrow guarantee
286 :Copyright: Thorsten Ottosen 2004-2006. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see LICENSE_1_0.txt__).
288 __ http://www.boost.org/LICENSE_1_0.txt