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


mp2p_icp
Author(s):
autogenerated on Fri Dec 20 2024 03:45:59