rwlogo
SourcePro 11.1

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWAny Struct Reference
[Miscellaneous]

Encapsulates an object of an arbitrary type. More...

#include <rw/any.h>

List of all members.

Public Member Functions

 RWAny ()
template<class T >
 RWAny (const T &ref)
 RWAny (const RWAny &rhs)
RWAnyoperator= (const RWAny &ref)
RWAnyswap (RWAny &ref)
const std::type_info * type () const
template<class T >
T & get ()
template<class T >
const T & get () const
template<class T >
T * address ()
template<class T >
const T * address () const

Detailed Description

RWAny encapsulates an object of an arbitrary type; it can:

Requirements for types held by RWAny are:

Synopsis

 #include <rw/any.h>
 RWAny a;

Persistence

None


Constructor & Destructor Documentation

RWAny::RWAny (  )  [inline]

Default constructor. Creates an empty object. Post-condition: for any T, (address<T>() == 0).

template<class T >
RWAny::RWAny ( const T &  ref  )  [inline]

Template constructor for type any holding T. Creates RWAny object holding a deep copy of argument ref.

RWAny::RWAny ( const RWAny rhs  )  [inline]

Copy constructor. Creates a deep copy of rhs.


Member Function Documentation

template<class T >
const T* RWAny::address (  )  const [inline]

Implements address retrieval. Returns the address of the object held in any or 0 if the object is not of the type requested.

template<class T >
T* RWAny::address (  )  [inline]

Implements address retrieval. Returns the address of the object held in any or 0 if the object is not of the type requested.

template<class T >
const T& RWAny::get (  )  const [inline]

Implements value retrieval. Returns *address<T>() if T is the type of the object stored in self, or throws an exception of type (or a type derived from) std::bad_cast otherwise.

template<class T >
T& RWAny::get (  )  [inline]

Implements value retrieval. Returns *address<T>() if T is the type of the object stored in self, or throws an exception of type (or a type derived from) std::bad_cast otherwise.

RWAny& RWAny::operator= ( const RWAny ref  )  [inline]

Assignment operator. Deep-copies ref. Returns a reference to self.

RWAny& RWAny::swap ( RWAny ref  )  [inline]

Implements a swap operation. After the swap, this object contains the old content of the argument and vice versa.

const std::type_info* RWAny::type (  )  const [inline]

Implements type retrieval. Returns &typeid (T) if any holds an object of type T, or 0 otherwise.


© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.