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");
87 const typename T::element_type*
operator->()
const {
return get(); }
88 typename T::element_type&
operator*(
void) {
return *
get(); }
89 const typename T::element_type&
operator*(
void)
const {
return *
get(); }
90 operator bool()
const {
return m_smartptr ? true :
false; }
poly_ptr_ptr(poly_ptr_ptr &&o)
move ctor
Wrapper to a clone smart pointer to polymorphic classes, capable of handling copy operator...
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)
const T::element_type * operator->() const
T::element_type & operator*(void)
poly_ptr_ptr(const T &ptr)
Ctor from a smart pointer; makes deep copy.
T::element_type * operator->()
poly_ptr_ptr< T > & operator=(poly_ptr_ptr< T > &&o)
move operator
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
poly_ptr_ptr< T > & operator=(const poly_ptr_ptr< T > &o)
const T & get_ptr() const
bool operator!(void) const
const T::element_type & operator*(void) const
poly_ptr_ptr()
Default ctor; init to nullptr.