template struct mrpt::ignored_copy_ptr

A wrapper class for pointers whose copy operations from other objects of the same type are ignored, that is, doing “a=b;” has no effect neiter on “a” or “b”.

In turn, assigning a pointer with a direct “=” operation from a plain “T*” type is permited.

See also:

safe_ptr, non_copiable_ptr, copiable_NULL_ptr

#include <mrpt/core/safe_pointers.h>

template <class T>
struct ignored_copy_ptr
{
    // construction

    ignored_copy_ptr();
    ignored_copy_ptr(const ignored_copy_ptr<T>&);
    ignored_copy_ptr(const T* p);

    //
methods

    ignored_copy_ptr<T>& operator = (T* p);
    ignored_copy_ptr<T>& operator = (const ignored_copy_ptr<T>&);
    void set(const T* p);
    bool operator == (const T* o) const;
    bool operator == (const ignored_copy_ptr<T>& o) const;
    bool operator != (const T* o) const;
    bool operator != (const ignored_copy_ptr<T>& o) const;
    T*& get();
    const T* get() const;
    T** getPtrToPtr();
    T*& operator -> ();
    const T* operator -> () const;
};

Methods

void set(const T* p)

This method can change the pointer, since the change is made explicitly, not through copy operators transparent to the user.