Boost  v1.57.0
doxygen for www.boost.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
boost::interprocess::scoped_ptr< T, Deleter > Class Template Reference

scoped_ptr stores a pointer to a dynamically allocated object. More...

#include <scoped_ptr.hpp>

Inheritance diagram for boost::interprocess::scoped_ptr< T, Deleter >:
Collaboration diagram for boost::interprocess::scoped_ptr< T, Deleter >:

Public Types

typedef T element_type
 
typedef Deleter deleter_type
 
typedef
ipcdetail::pointer_type< T,
Deleter >::type 
pointer
 
typedef pointer this_type::* unspecified_bool_type
 

Public Member Functions

 scoped_ptr (const pointer &p=0, const Deleter &d=Deleter())
 Constructs a scoped_ptr, storing a copy of p(which can be 0) and d. More...
 
 ~scoped_ptr ()
 If the stored pointer is not 0, destroys the object pointed to by the stored pointer. More...
 
void reset (const pointer &p=0)
 Deletes the object pointed to by the stored pointer and then stores a copy of p. More...
 
void reset (const pointer &p, const Deleter &d)
 Deletes the object pointed to by the stored pointer and then stores a copy of p and a copy of d. More...
 
pointer release ()
 Assigns internal pointer as 0 and returns previous pointer. More...
 
reference operator* () const
 Returns a reference to the object pointed to by the stored pointer. More...
 
pointeroperator-> ()
 Returns the internal stored pointer. More...
 
const pointeroperator-> () const
 Returns the internal stored pointer. More...
 
pointerget ()
 Returns the stored pointer. More...
 
const pointerget () const
 Returns the stored pointer. More...
 
 operator unspecified_bool_type () const
 Conversion to bool Never throws. More...
 
bool operator! () const
 Returns true if the stored pointer is 0. More...
 
void swap (scoped_ptr &b)
 Exchanges the internal pointer and deleter with other scoped_ptr Never throws. More...
 

Detailed Description

template<class T, class Deleter>
class boost::interprocess::scoped_ptr< T, Deleter >

scoped_ptr stores a pointer to a dynamically allocated object.

The object pointed to is guaranteed to be deleted, either on destruction of the scoped_ptr, or via an explicit reset. The user can avoid this deletion using release(). scoped_ptr is parameterized on T (the type of the object pointed to) and Deleter (the functor to be executed to delete the internal pointer). The internal pointer will be of the same pointer type as typename Deleter::pointer type (that is, if typename Deleter::pointer is offset_ptr<void>, the internal pointer will be offset_ptr<T>).

Member Typedef Documentation

template<class T, class Deleter>
typedef Deleter boost::interprocess::scoped_ptr< T, Deleter >::deleter_type
template<class T, class Deleter>
typedef T boost::interprocess::scoped_ptr< T, Deleter >::element_type
template<class T, class Deleter>
typedef ipcdetail::pointer_type<T, Deleter>::type boost::interprocess::scoped_ptr< T, Deleter >::pointer
template<class T, class Deleter>
typedef pointer this_type::* boost::interprocess::scoped_ptr< T, Deleter >::unspecified_bool_type

Constructor & Destructor Documentation

template<class T, class Deleter>
boost::interprocess::scoped_ptr< T, Deleter >::scoped_ptr ( const pointer p = 0,
const Deleter &  d = Deleter() 
)
inlineexplicit

Constructs a scoped_ptr, storing a copy of p(which can be 0) and d.

Does not throw.

template<class T, class Deleter>
boost::interprocess::scoped_ptr< T, Deleter >::~scoped_ptr ( )
inline

If the stored pointer is not 0, destroys the object pointed to by the stored pointer.

calling the operator() of the stored deleter. Never throws

References boost::python::api::del().

Member Function Documentation

template<class T, class Deleter>
pointer& boost::interprocess::scoped_ptr< T, Deleter >::get ( )
inline

Returns the stored pointer.

Never throws.

template<class T, class Deleter>
const pointer& boost::interprocess::scoped_ptr< T, Deleter >::get ( ) const
inline

Returns the stored pointer.

Never throws.

template<class T, class Deleter>
boost::interprocess::scoped_ptr< T, Deleter >::operator unspecified_bool_type ( ) const
inline

Conversion to bool Never throws.

template<class T, class Deleter>
bool boost::interprocess::scoped_ptr< T, Deleter >::operator! ( ) const
inline

Returns true if the stored pointer is 0.

Never throws.

template<class T, class Deleter>
reference boost::interprocess::scoped_ptr< T, Deleter >::operator* ( ) const
inline

Returns a reference to the object pointed to by the stored pointer.

Never throws.

References BOOST_ASSERT.

template<class T, class Deleter>
pointer& boost::interprocess::scoped_ptr< T, Deleter >::operator-> ( )
inline

Returns the internal stored pointer.

Never throws.

References BOOST_ASSERT.

template<class T, class Deleter>
const pointer& boost::interprocess::scoped_ptr< T, Deleter >::operator-> ( ) const
inline

Returns the internal stored pointer.

Never throws.

References BOOST_ASSERT.

template<class T, class Deleter>
pointer boost::interprocess::scoped_ptr< T, Deleter >::release ( )
inline

Assigns internal pointer as 0 and returns previous pointer.

This will avoid deletion on destructor

template<class T, class Deleter>
void boost::interprocess::scoped_ptr< T, Deleter >::reset ( const pointer p = 0)
inline

Deletes the object pointed to by the stored pointer and then stores a copy of p.

Never throws

References BOOST_ASSERT, and boost::multiprecision::backends::p.

template<class T, class Deleter>
void boost::interprocess::scoped_ptr< T, Deleter >::reset ( const pointer p,
const Deleter &  d 
)
inline

Deletes the object pointed to by the stored pointer and then stores a copy of p and a copy of d.

References BOOST_ASSERT.

template<class T, class Deleter>
void boost::interprocess::scoped_ptr< T, Deleter >::swap ( scoped_ptr< T, Deleter > &  b)
inline

Exchanges the internal pointer and deleter with other scoped_ptr Never throws.

References boost::asio::b.


The documentation for this class was generated from the following files: