25 #ifndef COMMON_PTRVECTOR_H 26 #define COMMON_PTRVECTOR_H 30 #include <boost/noncopyable.hpp> 43 template<
typename T,
class Deallocator = DeallocatorDefault>
44 class PtrVector : boost::noncopyable,
public std::vector<T *> {
51 for (
typename std::vector<T *>::iterator it = std::vector<T *>::begin(); it != std::vector<T *>::end(); ++it)
52 Deallocator::destroy(*it);
54 std::vector<T *>::clear();
58 Deallocator::destroy(std::vector<T *>::back());
59 std::vector<T *>::pop_back();
62 typename std::vector<T *>::iterator
erase(
typename std::vector<T *>::iterator position) {
63 Deallocator::destroy(*position);
64 return std::vector<T *>::erase(position);
67 typename std::vector<T *>::iterator
erase(
typename std::vector<T *>::iterator first,
68 typename std::vector<T *>::iterator last) {
70 for (
typename std::vector<T *>::iterator it = std::vector<T *>::begin(); it != std::vector<T *>::end(); ++it)
71 Deallocator::destroy(*it);
73 return std::vector<T *>::erase(first, last);
76 void resize(
typename std::vector<T *>::size_type n,
77 typename std::vector<T *>::value_type val =
typename std::vector<T *>::value_type()) {
79 typename std::vector<T *>::size_type s = std::vector<T *>::size();
83 std::vector<T *>::push_back(val);
92 template<
class InputIterator>
93 void assign(InputIterator first, InputIterator last) {
95 std::vector<T *>::assign(first, last);
98 void assign(
typename std::vector<T *>::size_type n,
const typename std::vector<T *>::value_type &val) {
100 std::vector<T *>::assign(n, val);
106 #endif // COMMON_PTRVECTOR_H
void resize(typename std::vector< T *>::size_type n, typename std::vector< T *>::value_type val=typename std::vector< T *>::value_type())
A vector of pointer to objects, with automatic deletion.
void assign(typename std::vector< T *>::size_type n, const typename std::vector< T *>::value_type &val)
Simple deallocator concept.
void assign(InputIterator first, InputIterator last)
std::vector< T * >::iterator erase(typename std::vector< T *>::iterator first, typename std::vector< T *>::iterator last)
std::vector< T * >::iterator erase(typename std::vector< T *>::iterator position)