SourcePro® 2024.1 |
SourcePro® API Reference Guide |
Encapsulates an object of an arbitrary type. More...
#include <rw/any.h>
Public Member Functions | |
RWAny () | |
RWAny (const RWAny &ref) | |
template<class T > | |
RWAny (const T &ref) | |
RWAny (RWAny &&ref) | |
template<class T > | |
T * | address () |
template<class T > | |
const T * | address () const |
template<class T > | |
T & | get () |
template<class T > | |
const T & | get () const |
RWAny & | operator= (const RWAny &ref) |
template<typename T > | |
RWAny & | operator= (const T &ref) |
RWAny & | operator= (RWAny &&ref) |
RWAny & | swap (RWAny &ref) |
const std::type_info * | type () const |
RWAny encapsulates an object of an arbitrary type; it can:
Requirements for types held by RWAny are:
|
inline |
Default constructor. Creates an empty object. Post-condition: for any T
, (address<T>() == 0)
.
|
inline |
Template constructor for type any
holding T
. Creates RWAny object holding a copy of argument ref.
|
inline |
Copy constructor. Creates a copy of ref.
|
inline |
Move constructor. The constructed instance takes ownership of the data owned by ref.
|
inline |
Implements address retrieval. Returns the address of the object held in any
or 0
if the object is not of the type requested.
|
inline |
Implements address retrieval. Returns the address of the object held in any
or 0
if the object is not of the type requested.
|
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.
|
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.
Assignment operator. Deep-copies ref. Returns a reference to self.
|
inline |
Template assignment operator for type any
holding T
. Assigns self to hold copy of argument ref.
Move assignment. Self takes ownership of the data owned by ref.
Implements a swap operation. After the swap, this
object contains the old content of the argument and vice versa.
|
inline |
Implements type retrieval. Returns &typeid (T)
if any
holds an object of type T
, or 0
otherwise.
Copyright © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved. |