Main Page   Namespace List   Class Hierarchy   Compound List   File List   Header Files   Namespace Members   Compound Members   File Members  

arg::grin_ptr Class Reference

Pointer type to support "Cheshire Cat" idiom - only the indicated constructor requires access to the complete pointee type. More...

#include <arg_grin_ptr.h>

List of all members.


Public Members

explicit grin_ptr (p_type* pointee)
Construct owining p - p_type must be a complete type.

 grin_ptr (const grin_ptr& rhs)
Makes a copy of the object referenced by rhs.

 ~grin_ptr () throw ()
Destroys the referenced object.

const p_type* get () const
Return contents (const).

p_type* get ()
Return contents (non-const).

const p_type* operator-> () const
Indirection operator(const).

p_type* operator-> ()
Indirection operator (non-const).

const p_type& operator * () const
Dereference operator(const).

p_type& operator * ()
Dereference operator (non-const).

void swap (grin_ptr& with) throw ()
Swaps contents with "with".

grin_ptr& operator= (const grin_ptr& rhs)
Makes a copy of the object referenced by rhs (destroys old).


Detailed Description

template<typename p_type> class arg::grin_ptr

Pointer type to support "Cheshire Cat" idiom - only the indicated constructor requires access to the complete pointee type.

A const-qualified smart pointer that takes ownership of the referenced object and implements copy construction/assignment by copying the referenced object.

The correct algorithm for copying is resolved by using the arg::deep_copy() template. This means that the referenced object will be copied using the copy construction unless it is tagged by inheriting from arg::cloneable or an overload of arg::deep_copy() is provided.

All methods support the strong exception safety guarantee with the proviso that the referenced type must have a non-throwing destructor.

Author(s):
Alan Griffiths

Member Function Documentation

template<typename p_type>
explicit arg::grin_ptr<p_type>::grin_ptr<p_type> (p_type * pointee)

Construct owining p - p_type must be a complete type.

template<typename p_type>
arg::grin_ptr<p_type>::grin_ptr<p_type> (const grin_ptr<p_type> & rhs) [inline]

Makes a copy of the object referenced by rhs.

template<typename p_type>
arg::grin_ptr<p_type>::~grin_ptr<p_type> () throw () [inline]

Destroys the referenced object.

template<typename p_type>
const p_type * arg::grin_ptr<p_type>::get () const [inline]

Return contents (const).

template<typename p_type>
p_type * arg::grin_ptr<p_type>::get () [inline]

Return contents (non-const).

template<typename p_type>
const p_type * arg::grin_ptr<p_type>::operator-> () const [inline]

Indirection operator(const).

template<typename p_type>
p_type * arg::grin_ptr<p_type>::operator-> () [inline]

Indirection operator (non-const).

template<typename p_type>
const p_type & arg::grin_ptr<p_type>::operator * () const [inline]

Dereference operator(const).

template<typename p_type>
p_type & arg::grin_ptr<p_type>::operator * () [inline]

Dereference operator (non-const).

template<typename p_type>
void arg::grin_ptr<p_type>::swap (grin_ptr<p_type> & with) throw () [inline]

Swaps contents with "with".

template<typename p_type>
grin_ptr<p_type>& arg::grin_ptr<p_type>::operator= (const grin_ptr<p_type> & rhs) [inline]

Makes a copy of the object referenced by rhs (destroys old).


The documentation for this class was generated from the following file:
Copyright 1999-2000 Alan Griffiths