1 #ifndef PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
2 #define PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66
4 #if defined(_MSC_VER) || (defined(__GNUC__) && (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4)) // GCC supports "pragma once" correctly since 3.4
8 #include "yaml-cpp/noncopyable.h"
17 class ptr_vector
: private YAML::noncopyable
21 ~ptr_vector() { clear(); }
24 for(unsigned i
=0;i
<m_data
.size();i
++)
29 std::size_t size() const { return m_data
.size(); }
30 bool empty() const { return m_data
.empty(); }
32 void push_back(std::auto_ptr
<T
> t
) {
33 m_data
.push_back(NULL
);
34 m_data
.back() = t
.release();
36 T
& operator[](std::size_t i
) { return *m_data
[i
]; }
37 const T
& operator[](std::size_t i
) const { return *m_data
[i
]; }
39 T
& back() { return *m_data
.back(); }
40 const T
& back() const { return *m_data
.back(); }
43 std::vector
<T
*> m_data
;
47 #endif // PTR_VECTOR_H_62B23520_7C8E_11DE_8A39_0800200C9A66