1 #ifndef PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
2 #define PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
4 #if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4
8 #include "yaml-cpp/noncopyable.h"
16 class ptr_vector
: private YAML::noncopyable
20 ~ptr_vector() { clear(); }
23 for(unsigned i
=0;i
<m_data
.size();i
++)
28 std::size_t size() const { return m_data
.size(); }
29 bool empty() const { return m_data
.empty(); }
31 void push_back(std::auto_ptr
<T
> t
) {
32 m_data
.push_back(NULL
);
33 m_data
.back() = t
.release();
35 T
& operator[](std::size_t i
) { return *m_data
[i
]; }
36 const T
& operator[](std::size_t i
) const { return *m_data
[i
]; }
38 T
& back() { return *m_data
.back(); }
39 const T
& back() const { return *m_data
.back(); }
42 std::vector
<T
*> m_data
;
46 #endif // PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66