33 m_smartptr.reset(
dynamic_cast<typename T::element_type*
>(ptr->clone()));
41 dynamic_cast<typename T::element_type*
>(o.
m_smartptr->clone()));
45 if (
this == &o)
return *
this;
47 dynamic_cast<typename T::element_type*
>(o.
m_smartptr->clone()));
53 dynamic_cast<typename T::element_type*
>(o_ptr->clone()));
65 if (
this == &o)
return *
this;
71 typename T::element_type*
get()
76 throw std::runtime_error(
"dereferencing nullptr poly_ptr");
78 const typename T::element_type*
get()
const
83 throw std::runtime_error(
"dereferencing nullptr poly_ptr");
89 const typename T::element_type&
operator*(
void)
const {
return *
get(); }
90 operator bool()
const {
return m_smartptr ? true :
false; }
Wrapper to a clone smart pointer to polymorphic classes, capable of handling copy operator,...
poly_ptr_ptr< T > & operator=(const poly_ptr_ptr< T > &o)
poly_ptr_ptr(const T &ptr)
Ctor from a smart pointer; makes deep copy.
poly_ptr_ptr(const poly_ptr_ptr< T > &o)
copy ctor: makes a copy of the object via clone()
poly_ptr_ptr< T > & operator=(const T &o_ptr)
T::element_type & operator*(void)
const T::element_type * get() const
T::element_type * operator->()
poly_ptr_ptr()
Default ctor; init to nullptr.
poly_ptr_ptr< T > & operator=(poly_ptr_ptr< T > &&o)
move operator
const T::element_type & operator*(void) const
const T::element_type * operator->() const
poly_ptr_ptr(poly_ptr_ptr &&o)
move ctor
bool operator!(void) const
const T & get_ptr() const
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.