|
|
LUNCHBOX_API | Any () |
| Construct a new, empty Any. More...
|
|
template<typename ValueType > |
| Any (const ValueType &value) |
| Construct a new Any with the given value. More...
|
|
LUNCHBOX_API | Any (const Any &other) |
| Copy-construct a new Any with copying content of other. More...
|
|
LUNCHBOX_API | ~Any () |
| Destruct this Any. More...
|
|
|
LUNCHBOX_API Any & | swap (Any &rhs) |
| Exchange the content of this and rhs. More...
|
|
template<typename ValueType > |
Any & | operator= (const ValueType &rhs) |
| Assign a new value to this Any. More...
|
|
LUNCHBOX_API Any & | operator= (Any rhs) |
| Exchange the content of this and rhs. More...
|
|
|
LUNCHBOX_API bool | empty () const |
|
LUNCHBOX_API const std::type_info & | type () const |
|
LUNCHBOX_API bool | operator== (const Any &rhs) const |
|
bool | operator!= (const Any &rhs) const |
|
A class which can hold instances of any type.
This class is based on boost.any with the extension to support serialization if the ValueType supports boost.serialization.
Example:
#include "test.h"
#include <lunchbox/any.h>
int main( int, char** )
{
TEST( any.
type() ==
typeid(void));
TEST( any == otherAny );
any = 5;
otherAny = any;
TEST( lunchbox::any_cast< int >( any ) == 5 );
TEST( any.
type() ==
typeid(int));
TEST( any == otherAny );
any = 42;
otherAny = 42;
TEST( lunchbox::any_cast< int >( any ) == 42 );
TEST( any == otherAny );
any = std::string( "blablub" );
TEST( lunchbox::any_cast< std::string >( any ) == "blablub" );
TEST( any.
type() ==
typeid(std::string));
TEST( any != otherAny );
try { TEST( lunchbox::any_cast< int >( any ) != 42 ); }
return EXIT_SUCCESS;
}
Definition at line 66 of file any.h.