[ VIGRA Homepage | Function Index | Class Index | Namespaces | File List | Main Page ]
|
Any Class Reference | ![]() |
Typesafe storage of arbitrary values. More...
#include <vigra/any.hxx>
Public Member Functions | |
| Any () | |
| template<class T > | |
| Any (T const &t) | |
| Any (Any const &other) | |
| 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 |
| template<class T > | |
| Any & | operator= (T const &t) |
| Any & | operator= (Any const &other) |
| 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:
| Any& operator= | ( | T const & | t | ) |
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).
| void destroy | ( | ) |
Delete the contained object (make this 'Any' object empty).
| void swap | ( | Any & | other | ) |
Exchange the value of this object with other's.
| bool operator== | ( | Any const & | other | ) | const |
Check if this object contains the same type and value as other. Also true if both 'Any' objects are empty.
| bool operator!= | ( | Any const & | other | ) | const |
Check if this object differs from other by type or value.
| operator bool | ( | ) | const |
Convert 'Any' to false if this object is empty, true otherwise.
| bool empty | ( | ) | const |
Check if this object is empty (holds no value).
| bool is_type | ( | ) | const |
Check if this object holds a value of the given type.
| bool is_readable | ( | ) | const |
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.
| T const& get | ( | ) | const |
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) |
html generated using doxygen and Python
|