39 T* n =
dynamic_cast<T*
>(o->clone());
40 if (!n)
throw std::runtime_error(
"error: clone() returned unexpected type");
45 template <
typename T,
typename Copier >
63 #if (__cplusplus>199711L) 71 if (
this == &o)
return *
this;
79 if (m_ptr)
return m_ptr;
80 else throw std::runtime_error(
"dereferencing NULL generic_copier_ptr");
83 if (m_ptr)
return m_ptr;
84 else throw std::runtime_error(
"dereferencing NULL generic_copier_ptr");
88 if (m_ptr)
return *m_ptr;
89 else throw std::runtime_error(
"dereferencing NULL generic_copier_ptr");
92 if (m_ptr)
return *m_ptr;
93 else throw std::runtime_error(
"dereferencing NULL generic_copier_ptr");
96 T *
get() {
return m_ptr; }
97 const T *
get()
const {
return m_ptr; }
99 operator bool()
const {
return m_ptr != NULL; }
110 if (ptr == m_ptr)
return;
111 if (m_ptr)
delete m_ptr;
bool operator!(void) const
void move_from(generic_copier_ptr &o)
generic_copier_ptr(const generic_copier_ptr< T, Copier > &o)
copy ctor: makes a copy of the object via clone()
generic_copier_ptr()
Default ctor; init to nullptr.
const T & operator*(void) const
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
T * release()
Releases the pointer (do not destroy the object)
generic_copier_ptr(T *ptr)
Ctor from a pointer; takes ownership.
const T * operator->() const