ptr_stack.h
Go to the documentation of this file.
1 #ifndef PTR_STACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM
2 #define PTR_STACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM
3 
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
7 
9 #include <cstddef>
10 #include <cstdlib>
11 #include <memory>
12 #include <vector>
13 
14 template <typename T>
16 {
17 public:
18  ptr_stack() {}
19  ~ptr_stack() { clear(); }
20 
21  void clear() {
22  for(unsigned i=0;i<m_data.size();i++)
23  delete m_data[i];
24  m_data.clear();
25  }
26 
27  std::size_t size() const { return m_data.size(); }
28  bool empty() const { return m_data.empty(); }
29 
30  void push(std::auto_ptr<T> t) {
31  m_data.push_back(NULL);
32  m_data.back() = t.release();
33  }
34  std::auto_ptr<T> pop() {
35  std::auto_ptr<T> t(m_data.back());
36  m_data.pop_back();
37  return t;
38  }
39  T& top() { return *m_data.back(); }
40  const T& top() const { return *m_data.back(); }
41 
42 private:
43  std::vector<T*> m_data;
44 };
45 
46 #endif // PTR_STACK_H_62B23520_7C8E_11DE_8A39_0800200C9A66_PM
ptr_stack::~ptr_stack
~ptr_stack()
Definition: ptr_stack.h:19
ptr_stack::ptr_stack
ptr_stack()
Definition: ptr_stack.h:18
ptr_stack::clear
void clear()
Definition: ptr_stack.h:21
ptr_stack::pop
std::auto_ptr< T > pop()
Definition: ptr_stack.h:34
ptr_stack::m_data
std::vector< T * > m_data
Definition: ptr_stack.h:43
ptr_stack
Definition: ptr_stack.h:15
ptr_stack::size
std::size_t size() const
Definition: ptr_stack.h:27
ptr_stack::push
void push(std::auto_ptr< T > t)
Definition: ptr_stack.h:30
noncopyable.h
ptr_stack::empty
bool empty() const
Definition: ptr_stack.h:28
ptr_stack::top
T & top()
Definition: ptr_stack.h:39
ptr_stack::top
const T & top() const
Definition: ptr_stack.h:40
t
geometry_msgs::TransformStamped t
YAML_PM::noncopyable
Definition: noncopyable.h:13


mp2p_icp
Author(s):
autogenerated on Wed Oct 23 2024 02:45:40