| 1 | // | 
|---|
| 2 | // Boost.Pointer Container | 
|---|
| 3 | // | 
|---|
| 4 | //  Copyright Thorsten Ottosen 2003-2005. Use, modification and | 
|---|
| 5 | //  distribution is subject to the Boost Software License, Version | 
|---|
| 6 | //  1.0. (See accompanying file LICENSE_1_0.txt or copy at | 
|---|
| 7 | //  http://www.boost.org/LICENSE_1_0.txt) | 
|---|
| 8 | // | 
|---|
| 9 | // For more information, see http://www.boost.org/libs/ptr_container/ | 
|---|
| 10 | // | 
|---|
| 11 |  | 
|---|
| 12 | #ifndef BOOST_PTR_CONTAINER_PTR_VECTOR_HPP | 
|---|
| 13 | #define BOOST_PTR_CONTAINER_PTR_VECTOR_HPP | 
|---|
| 14 |  | 
|---|
| 15 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) | 
|---|
| 16 | # pragma once | 
|---|
| 17 | #endif | 
|---|
| 18 |  | 
|---|
| 19 | #include <vector> | 
|---|
| 20 | #include <boost/ptr_container/ptr_sequence_adapter.hpp> | 
|---|
| 21 |  | 
|---|
| 22 | namespace boost | 
|---|
| 23 | { | 
|---|
| 24 |  | 
|---|
| 25 |     template | 
|---|
| 26 |     <  | 
|---|
| 27 |         class T,  | 
|---|
| 28 |         class CloneAllocator = heap_clone_allocator, | 
|---|
| 29 |         class Allocator      = std::allocator<void*> | 
|---|
| 30 |     > | 
|---|
| 31 |     class ptr_vector : public  | 
|---|
| 32 |         ptr_sequence_adapter< T,  | 
|---|
| 33 |                               std::vector<void*,Allocator>,  | 
|---|
| 34 |                               CloneAllocator > | 
|---|
| 35 |     {   | 
|---|
| 36 |         typedef ptr_sequence_adapter< T,  | 
|---|
| 37 |                                       std::vector<void*,Allocator>,  | 
|---|
| 38 |                                       CloneAllocator >  | 
|---|
| 39 |             base_class; | 
|---|
| 40 |  | 
|---|
| 41 |         typedef ptr_vector<T,CloneAllocator,Allocator> this_type; | 
|---|
| 42 |          | 
|---|
| 43 |     public: | 
|---|
| 44 |  | 
|---|
| 45 |         BOOST_PTR_CONTAINER_DEFINE_NON_INHERITED_MEMBERS( ptr_vector,  | 
|---|
| 46 |                                                           base_class, | 
|---|
| 47 |                                                           this_type ); | 
|---|
| 48 |  | 
|---|
| 49 |         ptr_vector( BOOST_DEDUCED_TYPENAME base_class::size_type n, | 
|---|
| 50 |                     const allocator_type& alloc = allocator_type() ) | 
|---|
| 51 |           : base_class(alloc) | 
|---|
| 52 |         { | 
|---|
| 53 |             this->c_private().reserve( n ); | 
|---|
| 54 |         } | 
|---|
| 55 |  | 
|---|
| 56 |  | 
|---|
| 57 |     }; | 
|---|
| 58 |  | 
|---|
| 59 |     ////////////////////////////////////////////////////////////////////////////// | 
|---|
| 60 |     // clonability | 
|---|
| 61 |  | 
|---|
| 62 |     template< typename T, typename CA, typename A > | 
|---|
| 63 |     inline ptr_vector<T,CA,A>* new_clone( const ptr_vector<T,CA,A>& r ) | 
|---|
| 64 |     { | 
|---|
| 65 |         return r.clone().release(); | 
|---|
| 66 |     } | 
|---|
| 67 |  | 
|---|
| 68 |     ///////////////////////////////////////////////////////////////////////// | 
|---|
| 69 |     // swap | 
|---|
| 70 |  | 
|---|
| 71 |     template< typename T, typename CA, typename A > | 
|---|
| 72 |     inline void swap( ptr_vector<T,CA,A>& l, ptr_vector<T,CA,A>& r ) | 
|---|
| 73 |     { | 
|---|
| 74 |         l.swap(r); | 
|---|
| 75 |     } | 
|---|
| 76 |      | 
|---|
| 77 | } | 
|---|
| 78 |  | 
|---|
| 79 | #endif | 
|---|