25 #ifndef COMMON_PTRLIST_H 26 #define COMMON_PTRLIST_H 30 #include <boost/noncopyable.hpp> 40 template<
typename T,
class Deallocator = DeallocatorDefault>
41 class PtrList : boost::noncopyable,
public std::list<T *> {
48 for (
typename std::list<T *>::iterator it = std::list<T *>::begin(); it != std::list<T *>::end(); ++it)
49 Deallocator::destroy(*it);
51 std::list<T *>::clear();
55 Deallocator::destroy(std::list<T *>::front());
56 std::list<T *>::pop_front();
60 Deallocator::destroy(std::list<T *>::back());
61 std::list<T *>::pop_back();
64 typename std::list<T *>::iterator
erase(
typename std::list<T *>::iterator position) {
65 Deallocator::destroy(*position);
66 return std::list<T *>::erase(position);
69 typename std::list<T *>::iterator
erase(
typename std::list<T *>::iterator first,
70 typename std::list<T *>::iterator last) {
72 for (
typename std::list<T *>::iterator it = std::list<T *>::begin(); it != std::list<T *>::end(); ++it)
73 Deallocator::destroy(*it);
75 return std::list<T *>::erase(first, last);
78 void resize(
typename std::list<T *>::size_type n,
79 typename std::list<T *>::value_type val =
typename std::list<T *>::value_type()) {
81 typename std::list<T *>::size_type s = std::list<T *>::size();
85 std::list<T *>::push_back(val);
94 void remove(
const typename std::list<T *>::value_type &val) {
95 for (
typename std::list<T *>::iterator it = std::list<T *>::begin(); it != std::list<T *>::end(); ) {
103 template<
class Predicate>
105 for (
typename std::list<T *>::iterator it = std::list<T *>::begin(); it != std::list<T *>::end(); ) {
113 template<
class InputIterator>
114 void assign(InputIterator first, InputIterator last) {
116 std::list<T *>::assign(first, last);
119 void assign(
typename std::list<T *>::size_type n,
const typename std::list<T *>::value_type &val) {
121 std::list<T *>::assign(n, val);
127 #endif // COMMON_PTRLIST_H std::list< T * >::iterator erase(typename std::list< T *>::iterator first, typename std::list< T *>::iterator last)
void assign(typename std::list< T *>::size_type n, const typename std::list< T *>::value_type &val)
void resize(typename std::list< T *>::size_type n, typename std::list< T *>::value_type val=typename std::list< T *>::value_type())
A list of pointer to objects, with automatic deletion.
void remove_if(Predicate pred)
std::list< T * >::iterator erase(typename std::list< T *>::iterator position)
void assign(InputIterator first, InputIterator last)
Simple deallocator concept.