1 #ifndef PTR_STACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66
2 #define PTR_STACK_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"
15 class ptr_stack
: private YAML::noncopyable
19 ~ptr_stack() { clear(); }
22 for(unsigned i
=0;i
<m_data
.size();i
++)
27 std::size_t size() const { return m_data
.size(); }
28 bool empty() const { return m_data
.empty(); }
30 void push(std::auto_ptr
<T
> t
) {
31 m_data
.push_back(NULL
);
32 m_data
.back() = t
.release();
34 std::auto_ptr
<T
> pop() {
35 std::auto_ptr
<T
> t(m_data
.back());
39 T
& top() { return *m_data
.back(); }
40 const T
& top() const { return *m_data
.back(); }
43 std::vector
<T
*> m_data
;
46 #endif // PTR_STACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66