Rosetta 3.3
Public Types | Public Member Functions | Friends
utility::pointer::owning_ptr< T > Class Template Reference

Shared-ownership intrusive reference-counted smart pointer. More...

#include <owning_ptr.hh>

Collaboration diagram for utility::pointer::owning_ptr< T >:
Collaboration graph
[legend]

List of all members.

Public Types

typedefValue
typedef T & Reference
typedef T const & ConstReference
typedef T * Pointer
typedef T const * ConstPointer
typedefvalue_type
typedefelement_type
typedef T & reference
typedef T const & const_reference
typedef T * pointer
typedef T const * const_pointer

Public Member Functions

 owning_ptr ()
 Default constructor.
 owning_ptr (owning_ptr const &a)
 Copy constructor (implicit)
template<typename Assignable >
 owning_ptr (owning_ptr< Assignable > const &a)
 Assignable copy constructor (implicit)
 owning_ptr (pointer object_p)
 Object pointer constructor (implicit)
 owning_ptr (reference object)
 Object constructor.
 ~owning_ptr ()
 Destructor.
owning_ptroperator= (owning_ptr const &a)
 Copy assignment.
template<typename Assignable >
owning_ptroperator= (owning_ptr< Assignable > const &a)
 Assignable copy assignment.
owning_ptroperator= (pointer object_p)
 Object pointer assignment.
owning_ptroperator= (reference object)
 Object assignment.
 operator bool () const
 bool conversion: points to something?
reference operator* () const
 Dereference.
pointer operator-> () const
 Indirection.
pointer operator() () const
 Raw pointer.
pointer get () const
 Raw pointer.
bool operator! () const
 Points to nothing? (some compilers need this)
void reset_to_null ()
 Release ownership and reset.
void swap (owning_ptr &a)
 Swap.

Friends

class owning_ptr

Detailed Description

template<typename T>
class utility::pointer::owning_ptr< T >

Shared-ownership intrusive reference-counted smart pointer.

owning_ptr is designed to be a shared-ownership intrusive reference counted smart pointer much like boost::intrusive_ptr but with a few modifications.

Differences from intrusive_ptr:

Remarks:

Ownership of the pointee object can be shared with intrusive_ptr or other smart pointers that use the same reference counting mechanism in the object.

Pointers to const objects: owning_ptr< Type const >

Virtual functions shouldn't return owning_ptr because, like all template-based smart pointers, it doesn't support covariant return types but raw pointer return values can be assigned to owning_ptr.

Casts: The cast functions are merely a convenience for owning_ptr (unlike for non-intrusive shared ownership pointers) so for:

owning_ptr< Base > pB( new Derived() );

the cast:

dynamic_pointer_cast< Derived >( pB );

is equivalent to:

owning_ptr< Derived >( dynamic_cast< Derived * >( pB() ) );


Member Typedef Documentation

template<typename T>
typedef T const* utility::pointer::owning_ptr< T >::const_pointer
template<typename T>
typedef T const& utility::pointer::owning_ptr< T >::const_reference
template<typename T>
typedef T const* utility::pointer::owning_ptr< T >::ConstPointer
template<typename T>
typedef T const& utility::pointer::owning_ptr< T >::ConstReference
template<typename T>
typedef T utility::pointer::owning_ptr< T >::element_type
template<typename T>
typedef T* utility::pointer::owning_ptr< T >::pointer
template<typename T>
typedef T* utility::pointer::owning_ptr< T >::Pointer
template<typename T>
typedef T& utility::pointer::owning_ptr< T >::reference
template<typename T>
typedef T& utility::pointer::owning_ptr< T >::Reference
template<typename T>
typedef T utility::pointer::owning_ptr< T >::Value
template<typename T>
typedef T utility::pointer::owning_ptr< T >::value_type

Constructor & Destructor Documentation

template<typename T>
utility::pointer::owning_ptr< T >::owning_ptr ( ) [inline]

Default constructor.

template<typename T>
utility::pointer::owning_ptr< T >::owning_ptr ( owning_ptr< T > const &  a) [inline]

Copy constructor (implicit)

template<typename T>
template<typename Assignable >
utility::pointer::owning_ptr< T >::owning_ptr ( owning_ptr< Assignable > const &  a) [inline]

Assignable copy constructor (implicit)

template<typename T>
utility::pointer::owning_ptr< T >::owning_ptr ( pointer  object_p) [inline]

Object pointer constructor (implicit)

template<typename T>
utility::pointer::owning_ptr< T >::owning_ptr ( reference  object) [inline, explicit]

Object constructor.

template<typename T>
utility::pointer::owning_ptr< T >::~owning_ptr ( ) [inline]

Destructor.


Member Function Documentation

template<typename T>
pointer utility::pointer::owning_ptr< T >::get ( ) const [inline]
template<typename T>
utility::pointer::owning_ptr< T >::operator bool ( ) const [inline]

bool conversion: points to something?

Note:
Enables unwanted conversions but work-around has compiler-dependencies
template<typename T>
bool utility::pointer::owning_ptr< T >::operator! ( ) const [inline]

Points to nothing? (some compilers need this)

template<typename T>
pointer utility::pointer::owning_ptr< T >::operator() ( ) const [inline]

Raw pointer.

template<typename T>
reference utility::pointer::owning_ptr< T >::operator* ( ) const [inline]

Dereference.

template<typename T>
pointer utility::pointer::owning_ptr< T >::operator-> ( ) const [inline]

Indirection.

template<typename T>
owning_ptr& utility::pointer::owning_ptr< T >::operator= ( reference  object) [inline]

Object assignment.

template<typename T>
owning_ptr& utility::pointer::owning_ptr< T >::operator= ( owning_ptr< T > const &  a) [inline]

Copy assignment.

template<typename T>
template<typename Assignable >
owning_ptr& utility::pointer::owning_ptr< T >::operator= ( owning_ptr< Assignable > const &  a) [inline]

Assignable copy assignment.

template<typename T>
owning_ptr& utility::pointer::owning_ptr< T >::operator= ( pointer  object_p) [inline]

Object pointer assignment.

template<typename T>
void utility::pointer::owning_ptr< T >::reset_to_null ( ) [inline]

Release ownership and reset.

template<typename T>
void utility::pointer::owning_ptr< T >::swap ( owning_ptr< T > &  a) [inline]

Swap.

Referenced by utility::pointer::swap().


Friends And Related Function Documentation

template<typename T>
friend class owning_ptr [friend]

The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines