scide: implement selectionLength for openDocument
[supercollider.git] / external_libraries / yaml-cpp-0.3.0 / src / ptr_stack.h
blobbf454fb3bc9665e6dd193f7a718ac23974ad3443
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
5 #pragma once
6 #endif
8 #include "yaml-cpp/noncopyable.h"
9 #include <cstddef>
10 #include <cstdlib>
11 #include <memory>
12 #include <vector>
14 template <typename T>
15 class ptr_stack: private YAML::noncopyable
17 public:
18 ptr_stack() {}
19 ~ptr_stack() { clear(); }
21 void clear() {
22 for(unsigned i=0;i<m_data.size();i++)
23 delete m_data[i];
24 m_data.clear();
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());
36 m_data.pop_back();
37 return t;
39 T& top() { return *m_data.back(); }
40 const T& top() const { return *m_data.back(); }
42 private:
43 std::vector<T*> m_data;
46 #endif // PTR_STACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66