[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]
Typesafe storage of arbitrary values. More...
#include <vigra/any.hxx>
Public Member Functions | |
Any () | |
Any (Any const &other) | |
template<class T > | |
Any (T const &t) | |
void | destroy () |
bool | empty () const |
template<class T > | |
T & | get () |
template<class T > | |
T const & | get () const |
template<class T > | |
bool | is_readable () const |
template<class T > | |
bool | is_type () const |
operator bool () const | |
bool | operator!= (Any const &other) const |
Any & | operator= (Any const &other) |
template<class T > | |
Any & | operator= (T const &t) |
bool | operator== (Any const &other) const |
template<class T > | |
T | read () const |
void | swap (Any &other) |
Friends | |
void | swap (Any &l, Any &r) |
Typesafe storage of arbitrary values.
Items are always stored by value, but it is of course possible to store pointers and smart pointers.
Usage:
Assign the given value to this 'Any' object (overwrites the old value, regardless of types).
Assign a copy of other's value to this 'Any' object (overwrites the old value, regardless of types).
Check if this object contains the same type and value as other. Also true if both 'Any' objects are empty.
Check if this object differs from other by type or value.
bool empty | ( | ) | const |
Check if this object is empty (holds no value).
Check if this object's value is convertible to the given type. At present, this only succeeds if T
matches the stored type exactly or is an arithmetic type convertible from the stored type.
T & get | ( | ) |
Read-write access to the contained value. This throws an exception if the types don't match.
Read-only access to the contained value. This throws an exception if the types don't match.
T read | ( | ) | const |
By-value access to the stored value. This throws an exception if the stored type doesn't match T
and T
is not an arithmetic type.
© Ullrich Köthe (ullrich.koethe@iwr.uni-heidelberg.de) |