Name

OwnerPtr — A pointer that owns the object pointed to.

Synopsis

template<typename T> 
class OwnerPtr : public PtrBaseSernaApi::PtrBase< T > {
public:

  // Allows correct passing of OwnerPtr by value as a temporary object. 
  template<typename T1> 
  struct OwnerPtrRef {
    // construct/copy/destruct
    OwnerPtrRef(T1 *);

    // public member functions


    T1 * p_;
  };
  // construct/copy/destruct
  OwnerPtr();
  OwnerPtr(T *);
  template<class T1 > OwnerPtr(OwnerPtr< T1 > &);
  OwnerPtr(OwnerPtrRef< T >);
  OwnerPtr& operator=(T *);
  template<class T1 > OwnerPtr& operator=(OwnerPtr< T1 > &);
  ~OwnerPtr();

  // public member functions

  void reset(T *) ;
  void clear() ;
  template<class T1 > operator OwnerPtrRef< T1 >() ;
  template<class T1 > operator OwnerPtr< T1 >() ;
};

Description

Destroys the owned object when being destroyed by itself. T must not be of array type. Behaviour of this class mimics std::auto_ptr, the main difference is common interface of PtrBase<T>.

OwnerPtr construct/copy/destruct

  1. OwnerPtr();


  2. OwnerPtr(T * p);


  3. template<class T1 > OwnerPtr(OwnerPtr< T1 > & other);


  4. OwnerPtr(OwnerPtrRef< T > ref);


  5. OwnerPtr& operator=(T * p);


  6. template<class T1 > OwnerPtr& operator=(OwnerPtr< T1 > & other);


  7. ~OwnerPtr();


OwnerPtr public member functions

  1. void reset(T * p) ;


  2. void clear() ;

    Implicitly destroy object.


  3. template<class T1 > operator OwnerPtrRef< T1 >() ;


  4. template<class T1 > operator OwnerPtr< T1 >() ;