Lunchbox  1.6.0
Classes | Friends
lunchbox::Any Class Reference

A class which can hold instances of any type. More...

#include <any.h>

List of all members.

Classes

class  holder
class  placeholder

Public Member Functions

Construction/Destruction
 Any ()
 Construct a new, empty Any.
template<typename ValueType >
 Any (const ValueType &value)
 Construct a new Any with the given value.
 Any (const Any &other)
 Copy-construct a new Any with copying content of other.
 ~Any ()
 Destruct this Any.
Modifiers
Anyswap (Any &rhs)
 Exchange the content of this and rhs.
template<typename ValueType >
Anyoperator= (const ValueType &rhs)
 Assign a new value to this Any.
Anyoperator= (Any rhs)
 Exchange the content of this and rhs.
Queries
bool empty () const
const std::type_info & type () const
bool operator== (const Any &rhs) const
bool operator!= (const Any &rhs) const

Friends

class boost::serialization::access
template<typename ValueType >
ValueType * any_cast (Any *)
 Retrieve the value stored in an Any including type checking.
template<typename ValueType >
ValueType * unsafe_any_cast (Any *)
 Retrieve the value stored in an Any without type checking.

Detailed Description

A class which can hold instances of any type.

This class is based on boost.any with the extension to support serialization through boost.serialization if the the ValueType supports this type of serialization.

Definition at line 61 of file any.h.


Constructor & Destructor Documentation

Construct a new, empty Any.

Version:
1.5.0

Referenced by operator=().

+ Here is the caller graph for this function:

template<typename ValueType >
lunchbox::Any::Any ( const ValueType &  value) [inline]

Construct a new Any with the given value.

Version:
1.5.0

Definition at line 71 of file any.h.

lunchbox::Any::Any ( const Any other)

Copy-construct a new Any with copying content of other.

Version:
1.5.0

Destruct this Any.

Version:
1.5.0

Member Function Documentation

bool lunchbox::Any::empty ( ) const
Returns:
true if this Any is not holding a value.
Version:
1.5.0
bool lunchbox::Any::operator!= ( const Any rhs) const [inline]
Returns:
true if the value from this and rhs are not equal.
Version:
1.5.0

Definition at line 122 of file any.h.

template<typename ValueType >
Any& lunchbox::Any::operator= ( const ValueType &  rhs) [inline]

Assign a new value to this Any.

Version:
1.5.0

Definition at line 90 of file any.h.

References Any().

+ Here is the call graph for this function:

Any& lunchbox::Any::operator= ( Any  rhs)

Exchange the content of this and rhs.

Version:
1.5.0
bool lunchbox::Any::operator== ( const Any rhs) const
Returns:
true if this and rhs are empty or if their values are equal.
Version:
1.5.0

Exchange the content of this and rhs.

Version:
1.5.0
const std::type_info& lunchbox::Any::type ( ) const
Returns:
the typeid of the contained value if non-empty, otherwise typeid(void).
Version:
1.5.0

Referenced by lunchbox::any_cast().

+ Here is the caller graph for this function:


Friends And Related Function Documentation

template<typename ValueType >
ValueType* any_cast ( Any operand) [friend]

Retrieve the value stored in an Any including type checking.

Returns:
the value stored in the given Any, 0 if types are not matching
Version:
1.5.0

Definition at line 232 of file any.h.

template<typename ValueType >
ValueType* unsafe_any_cast ( Any operand) [friend]

Retrieve the value stored in an Any without type checking.

Returns:
the value stored in the given Any
Version:
1.5.0

Definition at line 298 of file any.h.


The documentation for this class was generated from the following file: