Class Template static_move_ptr

Description
Headers
Reference
Synopsis
Class Template default_deleter
Class Template static_move_ptr

Description

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

Headers

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

<boost/move_ptr.hpp>
<boost/move_ptr/static_move_ptr.hpp>

Reference

Synopsis

namespace boost { 

namespace move_ptrs {

template<typename T>
struct default_deleter {
    typedef typename remove_bounds<T>::type element_type;

    void operator() (element_type*) const;

    default_deleter() { }

    template<typename TT>
    default_deleter(default_deleter<TT> tt) { }
};

} // End namespace move_ptrs

template< typename T, 
          typename Deleter = 
              move_ptrs::default_deleter<T> >
class static_move_ptr {
public:

        // Member types

    typedef typename remove_bounds<T>::type  element_type;
    typedef Deleter                          deleter_type;
    typedef implementation-defined           deleter_reference;
    typedef implementation-defined           deleter_const_reference;

        // Constructors

    static_move_ptr();

    static_move_ptr(const static_move_ptr& ptr);

    template<typename TT, typename DD>
    static_move_ptr(const static_move_ptr<TT, DD>& ptr);

    template<typename TT, typename DD>
    static_move_ptr(move_ptrs::move_source< static_move_ptr<TT, DD> > src);

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

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

        // Destructor

    ~static_move_ptr();

        // Assignment

    static_move_ptr& operator=(static_move_ptr ptr);

    template<typename TT, typename DD>    
    static_move_ptr& operator=(static_move_ptr<TT, DD> 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(static_move_ptr& p);

        // Deleter access

    deleter_reference get_deleter();

    deleter_const_reference get_deleter() const;
};

} // End namespace boost

Class Template default_deleter

Description

The default value of the second template parameter of static_move_ptr. Specializations of default_deleter are empty and have no-throw default constructors, copy-constructors, destructors and assignment operators.

Template parameters

T- Same as the first template argument to static_move_ptr.

default_deleter::element_type

    typedef typename remove_bounds<T>::type element_type;

The type of object pointer to by an instance of static_move_ptr<T>.

default_deleter::operator()

    void operator()(element_type* t) const;

Invokes delete [] t if T is an array type; otherwise invokes delete t. Note that element_type may be incomplete at the point operator() is invoked.

Class Template static_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 static_move_ptr manage pointers of type T*.
  • Otherwise, if T is of the form U[], instances of static_move_ptr manage pointers of type U*.

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

Deleter- A CopyConstructible and Assignable type — or a reference to such a type — such that the expression d(t) is valid, where d is an instance of D and t is of type static_move_ptr::element_type*.

static_move_ptr::element_type

    typedef typename remove_bounds<T>::type  element_type;

The type of object pointer to by an instance of static_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.

static_move_ptr::deleter_type

    typedef Deleter                          deleter_type;

A synonym for the template parameter Deleter.

static_move_ptr::deleter_reference

    typedef implementation-defined           deleter_reference;

A type suitable for representing a reference to an instance of Deleter.

static_move_ptr::deleter_const_reference

    typedef implementation-defined           deleter_const_reference;

A type suitable for representing a const reference to an instance of Deleter.

static_move_ptr::static_move_ptr

    static_move_ptr();

Constructs a an empty static_move_ptr. Never throws.

static_move_ptr::static_move_ptr

    static_move_ptr(const static_move_ptr& ptr);

    template<typename TT, typename DD>
    static_move_ptr(const static_move_ptr<TT, DD>& ptr);

The first member constructs a copy of ptr, taking ownership of the managed pointer. The second member constructs an instance of static_move_ptr which takes ownership of the pointer managed by ptr and stores an instance of Deleter which results from converting the instance of DD stored by ptr to type Deleter.

The first member can throw only if the copy constructor of Deleter can throw. The second member can throw only if the user-defined conversion from DD to Deleter can throw.

static_move_ptr::static_move_ptr

    template<typename TT, typename DD>
    static_move_ptr(move_ptrs::move_source< static_move_ptr<TT, DD> > src);

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

This member can throw only if the user-defined conversion from DD to Deleter can throw.

static_move_ptr::static_move_ptr

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

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

The first member constructs an instance of static_move_ptr which takes ownership of the given pointer and stores a default-constructed instance of Deleter. The second member constructs an instance of static_move_ptr which takes ownership of the given pointer and stores an instance of Deleter which results from converting the given instance of DD to type Deleter.

Both members require that TT be complete.

The first member can throw only if the default constructor of Deleter can throw. The second member can throw only if the user-defined conversion from DD to Deleter can throw.

static_move_ptr::static_move_ptr

    ~static_move_ptr();

If the stored pointer is null, it is freed as if by invoking get_deleter()(get()).

The first member can throw only if the default constructor of Deleter can throw. The second member can throw only if the copy constructor of Deleter can throw.

static_move_ptr::operator=

    static_move_ptr& operator=(static_move_ptr ptr);

    template<typename TT, typename DD>    
    static_move_ptr& operator=(static_move_ptr<TT, DD> ptr);

The first member takes ownership of the pointer managed by ptr and stores a copy of the instance of Deleter stored by ptr. The second member takes ownership of the pointer managed by ptr and assigns to the stored instance of Deleter the result of converting the instance of DD stored by ptr to type Deleter.

These members can throw only if the appropriate assignment operators of Deleter can throw.

static_move_ptr::get

    element_type* get() const;

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

static_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.

static_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.

static_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.

static_move_ptr::release

    element_type* release();

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

static_move_ptr::reset

    void reset();

If the stored pointer is non-null, this member frees as if by invoking get_deleter()(get()), and stores 0 in its place.

static_move_ptr::reset

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

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

Both members free the managed pointer if it is non-null, as if by invoking reset(), then take ownership of the given pointer. The first member assigns a default constructed instance of Deleter to its stored instance of Deleter. The second member assigns dd to its stored instance of Deleter

Both members require that TT be complete.

These members can throw only if the appropriate assignment operators of Deleter can throw.

static_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.

static_move_ptr::swap

    void swap(static_move_ptr& p);

Exchanges the content of this instance of static_move_ptr with that of the given instance. May throw if the assignment operator of the template parameter Deleter can throw.

static_move_ptr::get_deleter

    deleter_reference get_deleter();
    deleter_const_reference get_deleter() const

Both members return references to the stored instance of Deleter, and require that the managed pointer by non-null. Neither throws.


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