MADNESS  version 0.9
Public Types | Public Member Functions | List of all members
madness::detail::ReferenceWrapper< T > Class Template Reference

Reference wrapper class. More...

#include <ref.h>

Public Types

typedef T type
 The reference type. More...
 

Public Member Functions

 ReferenceWrapper ()
 Default constructor. More...
 
 ReferenceWrapper (T &t)
 Constructor. More...
 
T & get () const
 Reference accessor. More...
 
 operator T & () const
 Type conversion operator. More...
 
T * get_pointer () const
 Obect pointer accessor. More...
 
template<typename Archive >
void serialize (const Archive &)
 Serialization. More...
 

Detailed Description

template<class T>
class madness::detail::ReferenceWrapper< T >

Reference wrapper class.

Used to hold references for task functions where a copy would otherwise be used. This wrapper object is default constructable, copy constructable, assignable, and serializable, while a normal reference would not be. This object can also be used to pass arguments as a reference to a function that would otherwise be passed by value. Use the factory functions ref and cref to create ReferenceWrapper objects.

Template Parameters
TThe reference type

Member Typedef Documentation

template<class T>
typedef T madness::detail::ReferenceWrapper< T >::type

The reference type.

Constructor & Destructor Documentation

template<class T>
madness::detail::ReferenceWrapper< T >::ReferenceWrapper ( )
inline

Default constructor.

The reference references nothing

template<class T>
madness::detail::ReferenceWrapper< T >::ReferenceWrapper ( T &  t)
inlineexplicit

Constructor.

Parameters
tThe object to reference

Member Function Documentation

template<class T>
T& madness::detail::ReferenceWrapper< T >::get ( ) const
inline

Reference accessor.

Returns
A reference to the referenced object
Exceptions
madness::MadnessExceptionReference has not been set

Referenced by madness::Future< detail::ReferenceWrapper< T > >::operator T &().

template<class T>
T* madness::detail::ReferenceWrapper< T >::get_pointer ( ) const
inline

Obect pointer accessor.

Returns
A pointer to the referenced object
Exceptions
nothing

Referenced by madness::get_pointer().

template<class T>
madness::detail::ReferenceWrapper< T >::operator T & ( ) const
inline

Type conversion operator.

This has the same effect as get() .

Returns
A reference to the reference object
Exceptions
madness::MadnessExceptionReference has not been set
template<class T>
template<typename Archive >
void madness::detail::ReferenceWrapper< T >::serialize ( const Archive &  )
inline

Serialization.

This function is here for compatibility with task functions. Since serializing a reference to a local object is inheirently wrong, this function simply throws an exception.

Exceptions
madness::MadnessExceptionAlways

References MADNESS_EXCEPTION.


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