manual_ptrmanual_ptr
The class template manual_ptr is a Smart Interface Pointer
which supports manual resource management. Objects managed by instances of manual_ptr are never freed automatically; instead, manual_ptr allows the programmer to delete the bound object using the member function free.
It is recommended that programmers use the other Smart Interface Pointers and Smart References most of the time. Manual resource management is appropriate somtimes, however; for example, without something like manual_ptr it would not be possible to implement release() functions for unique_ptr and unique_obj.
<boost/interfaces/manual_ptr.hpp>namespace boost { namespace interfaces { template<typename Interface> class manual_ptr { public: typedef typename fixed_view<Interface> element_type; // Constructors manual_ptr(); template<typename T> explicit manual_ptr(T* t); manual_ptr(const manual_ptr& ptr); template<typename Subinterface> manual_ptr(const manual_ptr<Subinterface>& ptr); // Assignment manual_ptr& operator=(manual_ptr ptr); template<typename Subinterface> manual_ptr& operator=(manual_ptr<Subinterface> ptr); // Smart pointer interface element_type* get() const; element_type& operator*() const; element_type* operator->() const; void reset(); template<typename T> void reset(T* t); operator unspecified-bool-type() const; void swap(manual_ptr& p); void free(); }; } } // End namespace boost::interfaces
manual_ptr| Interface | - |
An interface defined using the Interface Definition Language (IDL). |
manual_ptr::element_typetypedef typename fixed_view<T> element_type;
Used by the dereferencing operators, in place of the template parameter Interface, to help prevent resource leaks and double deletes. See Example.
manual_ptr::manual_ptrmanual_ptr();
Constructs an empty manual_ptr. Never throws.
manual_ptr::manual_ptrmanual_ptr(const manual_ptr& ptr); template<typename Subinterface> manual_ptr(const manual_ptr<Subinterface>& ptr);
Constructs a manual_ptr bound to the same object as the given manual_ptr. Never throws.
manual_ptr::manual_ptrtemplate<typename T> explicit manual_ptr(T* t);
| T | - |
A class implementing |
Constructs an instance of manual_ptr bound to the given object.
manual_ptr::operator= manual_ptr& operator=(manual_ptr ptr);
template<typename Subinterface>
manual_ptr& operator=(manual_ptr<Subinterface> ptr);
Binds this instance of manual_ptr to the same object as the given manual_ptr. Never throws.
manual_ptr::get element_type* get() const;
Returns a pointer through which member functions of the bound object can be accessed. Never throws.
manual_ptr::operator* element_type& operator*() const;
Returns a reference through which member functions of the bound object can be accessed. Never throws.
manual_ptr::operator-> element_type* operator->() const;
Returns a pointer through which member functions of the bound object can be accessed. Never throws.
manual_ptr::reset void reset();
If there is currently a bound object, this member causes it to become unbound.
manual_ptr::resettemplate<typename T> void reset(T* t);
| T | - |
A class implementing |
If there is currently a bound object, this member causes it to become unbound. Next, it binds this instance of manual_ptr to the given object. Never throws
manual_ptr::operator unspecified-bool-type()operator unspecified-bool-type() const;
Returns an unspecified value which, when used in boolean contexts, is equivalent to get() != 0. Never throws.
manual_ptr::swap void swap(manual_ptr& p);
Exchanges the content of this instance of manual_ptr with that of the given instance. Never throws.
manual_ptr::free void free();
Frees the bound object using delete. Throws only if the destructor of the bound object throws.
Revised 16 Jan, 2005
© Copyright Jonathan Turkanis, 2005
Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Sha'arei Tefila, an Orthodox Shul (Synagogue) in Salt Lake City, Utah Chabad Lubavitch of Utah