template class mrpt::containers::deepcopy_poly_ptr


Wrapper to a std::shared_ptr<>, adding deep-copy semantics to copy ctor and copy operator, suitable for polymorphic classes with a clone() method.

Example use: deepcopy_poly_ptr<mrpt::poses::CPosePDF::Ptr>

See also:

for non-virtual classes, see copy_ptr<T>

#include <mrpt/containers/deepcopy_poly_ptr.h>

template <typename T>
class deepcopy_poly_ptr
    // construction

    deepcopy_poly_ptr(const T& ptr);
    deepcopy_poly_ptr(const deepcopy_poly_ptr<T>& o);
    deepcopy_poly_ptr(deepcopy_poly_ptr&& o);

    // methods

    deepcopy_poly_ptr<T>& operator = (const deepcopy_poly_ptr<T>& o);
    deepcopy_poly_ptr<T>& operator = (const T& o_ptr);
    deepcopy_poly_ptr<T>& operator = (deepcopy_poly_ptr<T>&& o);
    T::element_type* get();
    const T::element_type* get() const;
    T::element_type* operator -> ();
    const T::element_type* operator -> () const;
    T::element_type& operator * (void);
    const T::element_type& operator * () const;
    operator bool () const;
    bool operator ! (void) const;
    const T& get_ptr() const;
    T& get_ptr();
    void reset();


deepcopy_poly_ptr(const T& ptr)

Ctor from a smart pointer; makes deep copy.


Default ctor; init to nullptr.

deepcopy_poly_ptr(const deepcopy_poly_ptr<T>& o)

copy ctor: makes a copy of the object via clone()

deepcopy_poly_ptr(deepcopy_poly_ptr&& o)

move ctor


deepcopy_poly_ptr<T>& operator = (deepcopy_poly_ptr<T>&& o)

move operator