Any container class. More...
#include <any.h>
Public Member Functions | |
| any () | |
| Constructor. | |
| any (const any &other) | |
| Copy constructor. | |
| template<class T > | |
| any (const T &other) | |
| Copy constructor for template value type. | |
| const any & | operator= (const any &other) |
| Assignment operator. | |
| virtual | ~any () |
| Destructor. | |
| void | clear () |
| Clear value. | |
| bool | empty () const |
| Check for empty value. | |
| const std::type_info & | type () const |
| Determine the value type. | |
| std::string | str () const |
| Convert value to a string. | |
| template<typename T > | |
| const T | cast () |
| Cast to another type. | |
| bool | operator== (const any &rhs) const |
| Equality operator. | |
Friends | |
| std::ostream & | operator<< (std::ostream &str, const any &value) |
| Convert value to a string and put it into a stream. | |
Any container class.
The any container class is a holder for value of any type. It is useful to store objects of different types in the single STL container, for example. Moreover, you can cast one type to another with this class.
| const T dbp::any::cast | ( | ) | [inline] |
Cast to another type.
The cast() template method helps to cast value to the other type. If the native value type and the type requested are differs the safe conversion via string representation is occured. The first cast to the different type is a slow operation (3200 double/int casts per second @ one core of Athlon 64 X2 5200+), but future calls are ~300 times faster.
| bool dbp::any::empty | ( | ) | const [inline] |
Check for empty value.
| std::string dbp::any::str | ( | ) | const [inline] |
Convert value to a string.
| const std::type_info& dbp::any::type | ( | ) | const [inline] |
Determine the value type.