123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- ++++++++++++++++++++++++++++++++++
- |Boost| Pointer Container Library
- ++++++++++++++++++++++++++++++++++
-
- .. |Boost| image:: boost.png
- Class ``ptr_vector``
- --------------------
- A ``ptr_vector<T>`` is a pointer container that uses an underlying ``std::vector<void*>``
- to store the pointers.
- **Hierarchy:**
- - `reversible_ptr_container <reversible_ptr_container.html>`_
- - `ptr_sequence_adapter <ptr_sequence_adapter.html>`_
- - ``ptr_vector``
- - `ptr_list <ptr_list.html>`_
- - `ptr_deque <ptr_deque.html>`_
- - `ptr_array <ptr_array.html>`_
- **Navigate:**
- - `home <ptr_container.html>`_
- - `reference <reference.html>`_
- **Synopsis:**
- .. parsed-literal::
-
- namespace boost
- {
-
- template
- <
- class T,
- class CloneAllocator = heap_clone_allocator,
- class Allocator = std::allocator<void*>
- >
- class ptr_vector : public ptr_sequence_adapter
- <
- T,
- std::vector<void*,Allocator>,
- CloneAllocator
- >
- {
- public: // `construction`_
- explicit ptr_vector( size_type to_reserve );
-
- public: // capacity_
- size_type capacity() const;
- void reserve( size_type n );
-
- public: // `element access`_
- T& operator[]( size_type n );
- const T& operator[]( size_type n ) const;
- T& at( size_type n );
- const T& at( size_type n ) const;
- public: // `pointer container requirements`_
- auto_type replace( size_type idx, T* x );
- template< class U >
- auto_type replace( size_type idx, compatible-smart-ptr<U> x );
- bool is_null( size_type idx ) const;
-
- public: // `C-array support`_
- void transfer( iterator before, T** from, size_type size, bool delete_from = true );
- T** c_array();
- };
-
- } // namespace 'boost'
- Semantics
- ---------
- .. _`construction`:
- Semantics: construction
- ^^^^^^^^^^^^^^^^^^^^^^^
- - ``explicit ptr_vector( size_type to_reserve );``
- - constructs an empty vector with a buffer
- of size least ``to_reserve``
- .. _`capacity`:
- Semantics: capacity
- ^^^^^^^^^^^^^^^^^^^
- - ``size_type capacity() const;``
- - Effects: Returns the size of the allocated buffer
- - Throws: Nothing
- - ``void reserve( size_type n );``
- - Requirements: ``n <= max_size()``
-
- - Effects: Expands the allocated buffer
- - Postcondition: ``capacity() >= n``
- - Throws: ``std::length_error()`` if ``n > max_size()``
- .. _`element access`:
- Semantics: element access
- ^^^^^^^^^^^^^^^^^^^^^^^^^
- - ``T& operator[]( size_type n );``
- - ``const T& operator[]( size_type n ) const;``
- - Requirements: ``n < size()``
- - Effects: Returns a reference to the ``n``'th element
- - Throws: Nothing
- - ``T& at( size_type n );``
- - ``const T& at( size_type n ) const;``
- - Requirements: ``n < size()``
- - Effects: Returns a reference to the ``n``'th element
- - Throws: ``bad_index`` if ``n >= size()``
- .. _`pointer container requirements`:
- Semantics: pointer container requirements
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- - ``auto_type replace( size_type idx, T* x );``
- - Requirements: `` x != 0 and idx < size()``
- - Effects: returns the object indexed by ``idx`` and replaces it with ``x``.
- - Throws: ``bad_index`` if ``idx >= size()`` and ``bad_pointer`` if ``x == 0``.
- - Exception safety: Strong guarantee
- - ``template< class U > auto_type replace( size_type idx, compatible-smart-ptr<U> x );``
- - Effects: ``return replace( idx, x.release() );``
- - ``bool is_null( size_type idx ) const;``
- - Requirements: ``idx < size()``
- - Effects: returns whether the pointer at index ``idx`` is null
- - Exception safety: Nothrow guarantee
- .. _`C-array support`:
- Semantics: C-array support
- ^^^^^^^^^^^^^^^^^^^^^^^^^^
- - ``void transfer( iterator before, T** from, size_type size, bool delete_from = true );``
- - Requirements: ``from != 0``
-
- - Effects: Takes ownership of the dynamic array ``from``
-
- - Exception safety: Strong guarantee if ``delete_from == true``; if ``delete_from == false``,
- and an exception is thrown, the container fails to take ownership.
-
- - Remarks: Eventually calls ``delete[] from`` if ``delete_from == true``.
-
- - ``T** c_array();``
- - Returns: ``0`` if the container is empty; otherwise a pointer to the first element of the stored array
- - Throws: Nothing
-
- .. raw:: html
- <hr>
- :Copyright: Thorsten Ottosen 2004-2007. Use, modification and distribution is subject to the Boost Software License, Version 1.0 (see LICENSE_1_0.txt__).
- __ http://www.boost.org/LICENSE_1_0.txt
|