Type-erased class holding any value. More...
Public Member Functions | |
| Any () | |
| Construct empty value. | |
| template<typename T > | |
| Any (const T &value) | |
| Construct from arbitrary value. | |
| Any (const Any &origin) | |
| Copy constructor. | |
| Any (Any &&source) | |
| Move constructor. | |
| template<typename T > | |
| Any & | operator= (const T &value) |
| Assignment operator from value. | |
| Any & | operator= (const Any &origin) |
| Copy assignment operator. | |
| Any & | operator= (Any &&source) |
| Move assignment operator. | |
| ~Any () | |
| Destructor. | |
| void | swap (Any &other) |
| Swaps the Any with another Any of the same type. | |
| template<typename T > | |
| T & | get () |
| Returns a reference to the contained value. More... | |
| template<typename T > | |
| T * | check () |
| Returns a pointer to the contained value. More... | |
| operator SafeBool () const | |
| Check if the object is not empty. | |
Type-erased class holding any value.
This class can either hold a single value of arbitrary type, or it can be empty. Any erases the contained type at compile time while preserving value semantics. It is thus a type-safe and RAII-managed alternative to void* pointers.
Usage examples:
| T* aurora::Any::check | ( | ) |
Returns a pointer to the contained value.
| T& aurora::Any::get | ( | ) |
Returns a reference to the contained value.