Class Template dynamic_move_ptr

Description
Headers
Reference
Synopsis
Class Template dynamic_move_ptr

Description

The class template dynamic_move_ptr is a move pointer with the following properties:

Headers

The definition of dynamic_move_ptr can be made available by including either of the following headers:

<boost/move_ptr.hpp>
<boost/move_ptr/dynamic_move_ptr.hpp>

Reference

Synopsis

namespace boost { 

template<typename T>
class dynamic_move_ptr {
public:
    typedef typename remove_bounds<T>::type element_type;

        // Constructors

    dynamic_move_ptr();

    dynamic_move_ptr(const dynamic_move_ptr& ptr);

    template<typename TT>
    dynamic_move_ptr(const dynamic_move_ptr<TT>& ptr);

    template<typename TT>
    dynamic_move_ptr(move_ptrs::move_source< dynamic_move_ptr<TT> > src);

    template<typename TT>
    explicit dynamic_move_ptr(TT* tt);

    template<typename TT, typename DD>
    dynamic_move_ptr(TT* tt, DD dd);

        // Destructor

    ~dynamic_move_ptr();

        // Assignment

    dynamic_move_ptr& operator=(dynamic_move_ptr ptr);

    template<typename TT>    
    dynamic_move_ptr& operator=(dynamic_move_ptr<TT> ptr);

        // Smart pointer interface

    element_type* get() const;

    element_type& operator*() const;

    element_type* operator->() const;

    element_type& operator[](std::size_t i) const;

    element_type* release();

    void reset();

    template<typename TT>
    void reset(TT* tt);

    template<typename TT, typename DD>
    void reset(TT* tt, DD dd);

    operator unspecified-bool-type() const;

    void swap(dynamic_move_ptr& p);
};

} // End namespace boost

Class Template dynamic_move_ptr

Template parameters

T-

A type which either is not an array type or is an array type of incomplete bounds, i.e., a type of the form U[] for some U. There are two cases to distinguish:

  • If T is not an array type, then instances of dynamic_move_ptr manage pointers of type T*.
  • Otherwise, if T is of the form U[], instances of dynamic_move_ptr manage pointers of type U*.

If T is of the form U[N], for some N, a compile-time error occurs.

dynamic_move_ptr::element_type

    typedef typename remove_bounds<T>::type  element_type;

The type of object pointer to by an instance of dynamic_move_ptr<T>. If T is not an array type, element_type is just T. If T is of the form U[], for some type U, element_type is U.

dynamic_move_ptr::dynamic_move_ptr

    dynamic_move_ptr();

Constructs a an empty dynamic_move_ptr. Never throws.

dynamic_move_ptr::dynamic_move_ptr

    dynamic_move_ptr(const dynamic_move_ptr& ptr);

    template<typename TT>
    dynamic_move_ptr(const dynamic_move_ptr<TT>& ptr);

Both members constructs a copy of the given dynamic_move_ptr, taking ownership of the managed pointer. Neither member throws.

dynamic_move_ptr::dynamic_move_ptr

    template<typename TT>
    dynamic_move_ptr(move_ptrs::move_source< dynamic_move_ptr<TT> > src);

This member constructs an instance of dynamic_move_ptr from the return value of the function move, taking ownership of the pointer managed by the instance of dynamic_move_ptr on which move was invoked. This allows explicit transfer of ownership from an lvalue of type dynamic_move_ptr, when implicit tranfer is forbidden.

Never throws.

dynamic_move_ptr::dynamic_move_ptr

    template<typename TT>
    explicit dynamic_move_ptr(TT* tt);

    template<typename TT, typename DD>
    dynamic_move_ptr(TT* tt, DD dd);

The first member constructs an instance of dynamic_move_ptr which takes ownership of the given pointer. Unless, after zero or more transfers of ownership, the pointer is released using dynamic_move_ptr::release, it will eventually be freed correctly using delete or delete [], as appropriate. The type T need not be complete at the point of freeing.

The second member constructs an instance of dynamic_move_ptr which takes ownership of the given pointer. Unless, after zero or more transfers of ownership, the pointer is released using dynamic_move_ptr::release, it will eventually be freed as if by executing D()(tt). The type T need not be complete at the point of freeing. This member can throw only if the copy constructor of D can throw.

Both members require that TT be complete.

dynamic_move_ptr::dynamic_move_ptr

    ~dynamic_move_ptr();

If the stored pointer is non-null, this member frees it in one of two ways:

This member can throw only if either D::operator() or the destructor of element_type can throw.

dynamic_move_ptr::operator=

    dynamic_move_ptr& operator=(dynamic_move_ptr ptr);

    template<typename TT>    
    dynamic_move_ptr& operator=(dynamic_move_ptr<TT> ptr);

Both members take ownership of the pointers managed by the given instances of dynamic_move_ptr. Neither throws.

dynamic_move_ptr::get

    element_type* get() const;

Return a copy of the managed pointer, without relinquishing ownsership. Never throws.

dynamic_move_ptr::operator*

    element_type& operator*() const;

Returns the result of dereferencing the managed pointer, which must be non-null. Never throws.

This member is available only if the template parameter T is not an array type.

dynamic_move_ptr::operator->

    element_type* operator->() const;

Return a copy of the managed pointer, which must be non-null. Never throws.

This member is available only if the template parameter T is not an array type.

dynamic_move_ptr::operator[]

    element_type& operator[](std::size_t i) const;

Returns a reference to the i-th element of the array of T whose first element is the managed pointer, and which must have length at least i + 1. Never throws.

This member is available only if the template parameter T is an array type.

dynamic_move_ptr::release

    element_type* release();

Returns a copy of the managed pointer, and relinquishes ownership. Never throws.

dynamic_move_ptr::reset

    void reset();

If the stored pointer is non-null, this member frees it in one of two ways:

The stored pointer is replaced by the value 0.

dynamic_move_ptr::reset

    template<typename TT>
    void reset(TT* tt);

If the stored pointer is non-null, it is freed as ig by calling reset(). Next, this instance of dynamic_move_ptr takes ownership of the given pointer. Never throws

The type TT must be complete. However, unless the pointer is released using dynamic_move_ptr::release (possibly after one or more transfers of ownership), it will be freed correctly using delete or delete [], even if T is incomplete at the point of freeing.

dynamic_move_ptr::reset

    template<typename TT, typename DD>
    void reset(TT* tt, DD dd);

If the stored pointer is non-null, it is freed as ig by calling reset(). Next, this instance of dynamic_move_ptr takes ownership of the given pointer. Never throws.

The type TT must be complete. However, unless the pointer is released using dynamic_move_ptr::release (possibly after one or more transfers of ownership), it will be freed as if by executing D()(tt), even if T is incomplete at the point of freeing.

dynamic_move_ptr::operator unspecified-bool-type()

    operator unspecified-bool-type() const;

Returns an unspecified value that, when used in boolean contexts, is equivalent to get() != 0. Never throws.

dynamic_move_ptr::swap

    void swap(dynamic_move_ptr& p);

Exchanges the content of this instance of dynamic_move_ptr with that of the given instance. Never throws.


Sha'arei Tefila, an Orthodox Shul (Synagogue) in Salt Lake City, Utah Chabad Lubavitch of Utah